예제 #1
0
 /**
  * Returns the active theme code.
  * By default the active theme is loaded from the cms.activeTheme parameter,
  * but this behavior can be overridden by the cms.theme.getActiveTheme event listeners.
  * @return string
  * If the theme doesn't exist, returns null.
  */
 public static function getActiveThemeCode()
 {
     $activeTheme = Config::get('cms.activeTheme');
     if (App::hasDatabase()) {
         try {
             try {
                 $dbResult = Cache::remember(self::ACTIVE_KEY, 1440, function () {
                     return Parameter::applyKey(self::ACTIVE_KEY)->pluck('value');
                 });
             } catch (Exception $ex) {
                 // Cache failed
                 $dbResult = Parameter::applyKey(self::ACTIVE_KEY)->pluck('value');
             }
         } catch (Exception $ex) {
             // Database failed
             $dbResult = null;
         }
         if ($dbResult !== null && static::exists($dbResult)) {
             $activeTheme = $dbResult;
         }
     }
     $apiResult = Event::fire('cms.theme.getActiveTheme', [], true);
     if ($apiResult !== null) {
         $activeTheme = $apiResult;
     }
     if (!strlen($activeTheme)) {
         throw new SystemException(Lang::get('cms::lang.theme.active.not_set'));
     }
     return $activeTheme;
 }