InvalidateTokenButton.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 InvalidateTokenButton
  10. *
  11. * @package Magento\Customer\Block\Adminhtml\Edit
  12. */
  13. class InvalidateTokenButton extends GenericButton implements ButtonProviderInterface
  14. {
  15. /**
  16. * Get button data.
  17. *
  18. * @return array
  19. */
  20. public function getButtonData()
  21. {
  22. $customerId = $this->getCustomerId();
  23. $data = [];
  24. if ($customerId) {
  25. $deleteConfirmMsg = __("Are you sure you want to revoke the customer's tokens?");
  26. $data = [
  27. 'label' => __('Force Sign-In'),
  28. 'class' => 'invalidate-token',
  29. 'on_click' => 'deleteConfirm("' . $deleteConfirmMsg . '", "' . $this->getInvalidateTokenUrl() . '")',
  30. 'sort_order' => 65,
  31. 'aclResource' => 'Magento_Customer::invalidate_tokens',
  32. ];
  33. }
  34. return $data;
  35. }
  36. /**
  37. * Get invalidate token url.
  38. *
  39. * @return string
  40. */
  41. public function getInvalidateTokenUrl()
  42. {
  43. return $this->getUrl('customer/customer/invalidateToken', ['customer_id' => $this->getCustomerId()]);
  44. }
  45. }