SaveAndContinueButton.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Customer\Block\Adminhtml\Edit;
  7. use Magento\Customer\Api\AccountManagementInterface;
  8. use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
  9. /**
  10. * Class SaveAndContinueButton
  11. */
  12. class SaveAndContinueButton extends GenericButton implements ButtonProviderInterface
  13. {
  14. /**
  15. * @var AccountManagementInterface
  16. */
  17. protected $customerAccountManagement;
  18. /**
  19. * Constructor
  20. *
  21. * @param \Magento\Backend\Block\Widget\Context $context
  22. * @param \Magento\Framework\Registry $registry
  23. * @param AccountManagementInterface $customerAccountManagement
  24. */
  25. public function __construct(
  26. \Magento\Backend\Block\Widget\Context $context,
  27. \Magento\Framework\Registry $registry,
  28. AccountManagementInterface $customerAccountManagement
  29. ) {
  30. parent::__construct($context, $registry);
  31. $this->customerAccountManagement = $customerAccountManagement;
  32. }
  33. /**
  34. * @return array
  35. */
  36. public function getButtonData()
  37. {
  38. $customerId = $this->getCustomerId();
  39. $canModify = !$customerId || !$this->customerAccountManagement->isReadonly($this->getCustomerId());
  40. $data = [];
  41. if ($canModify) {
  42. $data = [
  43. 'label' => __('Save and Continue Edit'),
  44. 'class' => 'save',
  45. 'data_attribute' => [
  46. 'mage-init' => [
  47. 'button' => ['event' => 'saveAndContinueEdit'],
  48. ],
  49. ],
  50. 'sort_order' => 80,
  51. ];
  52. }
  53. return $data;
  54. }
  55. }