Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
InvalidateToken.php
Go to the documentation of this file.
1 <?php
9 
14 use Magento\Customer\Api\Data\AddressInterfaceFactory;
15 use Magento\Customer\Api\Data\CustomerInterfaceFactory;
17 use Magento\Framework\DataObjectFactory;
19 
29 {
33  protected $tokenService;
34 
65  public function __construct(
66  \Magento\Backend\App\Action\Context $context,
67  \Magento\Framework\Registry $coreRegistry,
68  \Magento\Framework\App\Response\Http\FileFactory $fileFactory,
69  \Magento\Customer\Model\CustomerFactory $customerFactory,
70  \Magento\Customer\Model\AddressFactory $addressFactory,
71  \Magento\Customer\Model\Metadata\FormFactory $formFactory,
72  \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory,
73  \Magento\Customer\Helper\View $viewHelper,
74  \Magento\Framework\Math\Random $random,
76  \Magento\Framework\Api\ExtensibleDataObjectConverter $extensibleDataObjectConverter,
80  CustomerInterfaceFactory $customerDataFactory,
81  AddressInterfaceFactory $addressDataFactory,
82  \Magento\Customer\Model\Customer\Mapper $customerMapper,
83  \Magento\Framework\Reflection\DataObjectProcessor $dataObjectProcessor,
85  DataObjectFactory $objectFactory,
86  \Magento\Framework\View\LayoutFactory $layoutFactory,
87  \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory,
88  \Magento\Framework\View\Result\PageFactory $resultPageFactory,
89  \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory,
90  \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
92  ) {
93  $this->tokenService = $tokenService;
94  parent::__construct(
95  $context,
96  $coreRegistry,
97  $fileFactory,
100  $formFactory,
101  $subscriberFactory,
102  $viewHelper,
103  $random,
105  $extensibleDataObjectConverter,
114  $objectFactory,
120  );
121  }
122 
128  public function execute()
129  {
130  $resultRedirect = $this->resultRedirectFactory->create();
131  if ($customerId = $this->getRequest()->getParam('customer_id')) {
132  try {
133  $this->tokenService->revokeCustomerAccessToken($customerId);
134  $this->messageManager->addSuccess(__('You have revoked the customer\'s tokens.'));
135  $resultRedirect->setPath('customer/index/edit', ['id' => $customerId, '_current' => true]);
136  } catch (\Exception $e) {
137  $this->messageManager->addError($e->getMessage());
138  $resultRedirect->setPath('customer/index/edit', ['id' => $customerId, '_current' => true]);
139  }
140  } else {
141  $this->messageManager->addError(__('We can\'t find a customer to revoke.'));
142  $resultRedirect->setPath('customer/index/index');
143  }
144  return $resultRedirect;
145  }
146 }
__construct(\Magento\Backend\App\Action\Context $context, \Magento\Framework\Registry $coreRegistry, \Magento\Framework\App\Response\Http\FileFactory $fileFactory, \Magento\Customer\Model\CustomerFactory $customerFactory, \Magento\Customer\Model\AddressFactory $addressFactory, \Magento\Customer\Model\Metadata\FormFactory $formFactory, \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory, \Magento\Customer\Helper\View $viewHelper, \Magento\Framework\Math\Random $random, CustomerRepositoryInterface $customerRepository, \Magento\Framework\Api\ExtensibleDataObjectConverter $extensibleDataObjectConverter, Mapper $addressMapper, AccountManagementInterface $customerAccountManagement, AddressRepositoryInterface $addressRepository, CustomerInterfaceFactory $customerDataFactory, AddressInterfaceFactory $addressDataFactory, \Magento\Customer\Model\Customer\Mapper $customerMapper, \Magento\Framework\Reflection\DataObjectProcessor $dataObjectProcessor, DataObjectHelper $dataObjectHelper, DataObjectFactory $objectFactory, \Magento\Framework\View\LayoutFactory $layoutFactory, \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory, \Magento\Framework\View\Result\PageFactory $resultPageFactory, \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory, \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, CustomerTokenServiceInterface $tokenService)
__()
Definition: __.php:13
$customerRepository
$addressFactory
Definition: quote.php:20