Пример #1
0
 /**
  * Initialize the theme.  This needs to be triggered as part of the dispatch
  * event.
  *
  * @throws \Exception
  * @return void
  */
 public function init()
 {
     // Determine the current theme:
     $currentTheme = $this->pickTheme($this->event->getRequest());
     // Determine theme options:
     $this->sendThemeOptionsToView();
     // Make sure the current theme is set correctly in the tools object:
     try {
         $this->tools->setTheme($currentTheme);
     } catch (\Exception $error) {
         // If an illegal value is passed in, the setter may throw an exception.
         // We should ignore it for now and throw it after we have set up the
         // theme (the setter will use a safe value instead of the illegal one).
     }
     // Using the settings we initialized above, actually configure the themes; we
     // need to do this even if there is an error, since we need a theme in order
     // to display an error message!
     $this->setUpThemes(array_reverse($this->tools->getThemeInfo()));
     // If we encountered an error loading theme settings, fail now.
     if (isset($error)) {
         throw new \Exception($error->getMessage());
     }
 }