ResetPasswordButton.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
  8. /**
  9. * Class ResetPasswordButton
  10. */
  11. class ResetPasswordButton extends GenericButton implements ButtonProviderInterface
  12. {
  13. /**
  14. * Retrieve button-specified settings
  15. *
  16. * @return array
  17. */
  18. public function getButtonData()
  19. {
  20. $customerId = $this->getCustomerId();
  21. $data = [];
  22. if ($customerId) {
  23. $data = [
  24. 'label' => __('Reset Password'),
  25. 'class' => 'reset reset-password',
  26. 'on_click' => sprintf("location.href = '%s';", $this->getResetPasswordUrl()),
  27. 'sort_order' => 60,
  28. 'aclResource' => 'Magento_Customer::reset_password',
  29. ];
  30. }
  31. return $data;
  32. }
  33. /**
  34. * Get reset password url
  35. *
  36. * @return string
  37. */
  38. public function getResetPasswordUrl()
  39. {
  40. return $this->getUrl('customer/index/resetPassword', ['customer_id' => $this->getCustomerId()]);
  41. }
  42. }