Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AfterCustomUrlChangedObserver.php
Go to the documentation of this file.
1 <?php
7 
9 
11 {
17  protected $_backendData;
18 
24  protected $_coreRegistry;
25 
29  protected $_authSession;
30 
34  protected $_response;
35 
42  public function __construct(
43  \Magento\Backend\Helper\Data $backendData,
44  \Magento\Framework\Registry $coreRegistry,
45  \Magento\Backend\Model\Auth\Session $authSession,
46  \Magento\Framework\App\ResponseInterface $response
47  ) {
48  $this->_backendData = $backendData;
49  $this->_coreRegistry = $coreRegistry;
50  $this->_authSession = $authSession;
51  $this->_response = $response;
52  }
53 
62  public function execute(\Magento\Framework\Event\Observer $observer)
63  {
64  if ($this->_coreRegistry->registry('custom_admin_path_redirect') === null) {
65  return;
66  }
67 
68  $this->_authSession->destroy();
69  $adminUrl = $this->_backendData->getHomePageUrl();
70  $this->_response->setRedirect($adminUrl)->sendResponse();
71  exit(0);
72  }
73 }
$response
Definition: 404.php:11
exit
Definition: redirect.phtml:12
__construct(\Magento\Backend\Helper\Data $backendData, \Magento\Framework\Registry $coreRegistry, \Magento\Backend\Model\Auth\Session $authSession, \Magento\Framework\App\ResponseInterface $response)