DeniedJson.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Backend\Controller\Adminhtml\Auth;
  8. use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
  9. class DeniedJson extends \Magento\Backend\Controller\Adminhtml\Auth implements HttpGetActionInterface
  10. {
  11. /**
  12. * @var \Magento\Framework\Controller\Result\JsonFactory
  13. */
  14. protected $resultJsonFactory;
  15. /**
  16. * @param \Magento\Backend\App\Action\Context $context
  17. * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
  18. */
  19. public function __construct(
  20. \Magento\Backend\App\Action\Context $context,
  21. \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
  22. ) {
  23. parent::__construct($context);
  24. $this->resultJsonFactory = $resultJsonFactory;
  25. }
  26. /**
  27. * Retrieve response for deniedJsonAction()
  28. *
  29. * @return array
  30. */
  31. protected function _getDeniedJson()
  32. {
  33. return [
  34. 'ajaxExpired' => 1,
  35. 'ajaxRedirect' => $this->_helper->getHomePageUrl()
  36. ];
  37. }
  38. /**
  39. * Denied JSON action
  40. *
  41. * @return \Magento\Framework\Controller\Result\Json
  42. */
  43. public function execute()
  44. {
  45. /** @var \Magento\Framework\Controller\Result\Json $resultJson */
  46. $resultJson = $this->resultJsonFactory->create();
  47. return $resultJson->setData($this->_getDeniedJson());
  48. }
  49. }