protected function getThemeData($dirName) { if (!($theme = CmsTheme::load($dirName))) { throw new Exception(Lang::get('Unable to find theme with name :name', $dirName)); } $model = ThemeData::forTheme($theme); return $model; }
/** * Returns a cached version of this model, based on a Theme object. * @param $theme Cms\Classes\Theme * @return self */ public static function forTheme($theme) { $dirName = $theme->getDirName(); if ($themeData = array_get(self::$instances, $dirName)) { return $themeData; } $themeData = ThemeData::firstOrCreate(['theme' => $dirName]); return self::$instances[$dirName] = $themeData; }
/** * Returns a cached version of this model, based on a Theme object. * @param $theme Cms\Classes\Theme * @return self */ public static function forTheme($theme) { $dirName = $theme->getDirName(); if ($themeData = array_get(self::$instances, $dirName)) { return $themeData; } try { $themeData = ThemeData::firstOrCreate(['theme' => $dirName]); } catch (Exception $ex) { // Database failed $themeData = new ThemeData(['theme' => $dirName]); } return self::$instances[$dirName] = $themeData; }
/** * Determine if an attribute exists on the object. * @param string $key * @return void */ public function __isset($key) { if ($this->hasCustomData()) { $theme = ThemeData::forTheme($this); return isset($theme->{$key}); } return false; }
protected function getThemeData($dirName) { $theme = $this->findThemeObject($dirName); $model = ThemeData::forTheme($theme); return $model; }
/** * Registers events for the asset combiner. */ protected function registerCombinerEvents() { if (App::runningInBackend() || App::runningInConsole()) { return; } Event::listen('cms.combiner.beforePrepare', function ($combiner, $assets) { $filters = array_flatten($combiner->getFilters()); ThemeData::applyAssetVariablesToCombinerFilters($filters); }); Event::listen('cms.combiner.getCacheKey', function ($combiner, $holder) { $holder->key = $holder->key . ThemeData::getCombinerCacheKey(); }); }
/** * Returns data specific to this theme * @return Cms\Models\ThemeData */ public function getCustomData() { return ThemeData::forTheme($this); }