public function init()
 {
     // Disable plugin if the allowed domain is not yet set
     $settingDomain = WebsiteSetting::getByName("subdomainAdmin");
     if (!is_object($settingDomain) || $settingDomain->getData() == "") {
         return;
     }
     // Create temporary request object - not available yet in front controller
     $currentUrl = 'http' . (isset($_SERVER['HTTPS']) ? 's' : '') . '://' . "{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
     $request = new \Zend_Controller_Request_Http($currentUrl);
     // Disable main domain setting to allow admin access on another domain
     $conf = Config::getSystemConfig();
     $mainDomain = $conf->general->domain;
     if (Tool::isRequestToAdminBackend($request) && Tool::isDomainAllowedToAdminBackend($request)) {
         $confArr = $conf->toArray();
         $mainDomain = $confArr['general']['domain'];
         $confArr['general']['domain'] = "";
         Config::setSystemConfig(new \Zend_Config($confArr));
     }
     // Register plugin
     \Pimcore::getEventManager()->attach("system.startup", function ($event) use(&$mainDomain) {
         $front = \Zend_Controller_Front::getInstance();
         $frontControllerPlugin = new FrontControllerPlugin();
         $front->registerPlugin($frontControllerPlugin);
         // Restore main domain
         $conf = Config::getSystemConfig();
         $confArr = $conf->toArray();
         $confArr['general']['domain'] = $mainDomain;
         Config::setSystemConfig(new \Zend_Config($confArr));
     });
 }
 public function preDispatch(\Zend_Controller_Request_Http $request)
 {
     parent::preDispatch($request);
     if (Tool::isRequestToAdminBackend($request) && !Tool::isDomainAllowedToAdminBackend($request)) {
         $this->handleErrorPage();
     }
 }