Example #1
0
 /**
  * Bese controller constructor: restores user object by using session data and
  * checks a permission to a requested action
  *
  * @param LiveCart $application Application instance
  * @throws AccessDeniedExeption
  */
 public function __construct(LiveCart $application)
 {
     parent::__construct($application);
     $this->router = $this->application->getRouter();
     if (!$application->isInstalled() && !$this instanceof InstallController) {
         header('Location: ' . $this->router->createUrl(array('controller' => 'install', 'action' => 'index')));
         exit;
     }
     unset($this->locale);
     unset($this->config);
     unset($this->user);
     unset($this->session);
     $this->checkAccess();
     $this->application->setRequestLanguage($this->request->get('requestLanguage'));
     $this->configFiles = $this->getConfigFiles();
     $this->application->setConfigFiles($this->configFiles);
     $localeCode = $this->application->getLocaleCode();
     // add language code to URL for non-default languages
     if ($localeCode != $this->application->getDefaultLanguageCode()) {
         $this->router->setAutoAppendVariables(array('requestLanguage' => $localeCode));
     }
     // verify that the action is accessed via HTTPS if it is required
     if ($this->router->isSSL($this->request->getControllerName(), $this->request->getActionName()) && !$this->router->isHttps()) {
         header('Location: ' . $this->router->createFullUrl($_SERVER['REQUEST_URI'], true));
         exit;
     }
 }