/** * 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; }