Esempio n. 1
0
 /**
  * Initialize administration plugin if admin path matches.
  *
  * Disables system cache.
  */
 public function initializeGantryTheme()
 {
     if (!class_exists('Gantry\\Framework\\Gantry')) {
         return;
     }
     $gantry = Gantry::instance();
     if (!isset($gantry['theme.name'])) {
         return;
     }
     // Initialize theme stream.
     $gantry['platform']->set('streams.gantry-theme.prefixes', ['' => ["user://gantry5/themes/{$gantry['theme.name']}", "gantry-themes://{$gantry['theme.name']}", "gantry-themes://{$gantry['theme.name']}/common"]]);
     $gantry['locator'];
     $gantry['streams'];
     /** @var \Gantry\Framework\Theme $theme */
     $theme = $gantry['theme'];
     $version = isset($this->grav['theme']->gantry) ? $this->grav['theme']->gantry : 0;
     if (!$gantry->isCompatible($version)) {
         $message = "Theme requires Gantry v{$version} (or later) in order to work! Please upgrade Gantry Framework.";
         if ($this->isAdmin()) {
             $messages = $this->grav['messages'];
             $messages->add($message, 'error');
             return;
         } else {
             throw new \LogicException($message);
         }
     }
     $this->theme = $theme;
     $this->theme->setLayout('default');
     if (!isset($this->grav['admin'])) {
         $this->enable(['onTwigInitialized' => ['onThemeTwigInitialized', 0], 'onTwigSiteVariables' => ['onThemeTwigVariables', 0]]);
     }
 }
Esempio n. 2
0
 public function detectGantrySite()
 {
     $this->theme->setLayout('default');
     $this->enable(['onTwigInitialized' => ['onThemeTwigInitialized', 0], 'onTwigSiteVariables' => ['onThemeTwigVariables', 0]]);
 }