Always return an active theme and data
This commit is contained in:
parent
a544c6822b
commit
6ca828a1fa
|
|
@ -149,12 +149,19 @@ class Theme
|
|||
|
||||
if (App::hasDatabase()) {
|
||||
try {
|
||||
$dbResult = Cache::remember(self::ACTIVE_KEY, 1440, function() {
|
||||
return Parameter::applyKey(self::ACTIVE_KEY)->pluck('value');
|
||||
});
|
||||
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) {
|
||||
$dbResult = Parameter::applyKey(self::ACTIVE_KEY)->pluck('value');
|
||||
// Database failed
|
||||
$dbResult = null;
|
||||
}
|
||||
|
||||
if ($dbResult !== null && static::exists($dbResult)) {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use Lang;
|
|||
use Model;
|
||||
use Cms\Classes\Theme as CmsTheme;
|
||||
use System\Classes\CombineAssets;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Customization data used by a theme
|
||||
|
|
@ -82,7 +83,14 @@ class ThemeData extends Model
|
|||
return $themeData;
|
||||
}
|
||||
|
||||
$themeData = ThemeData::firstOrCreate(['theme' => $dirName]);
|
||||
try {
|
||||
$themeData = ThemeData::firstOrCreate(['theme' => $dirName]);
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
// Database failed
|
||||
$themeData = new ThemeData(['theme' => $dirName]);
|
||||
}
|
||||
|
||||
return self::$instances[$dirName] = $themeData;
|
||||
}
|
||||
|
||||
|
|
@ -162,8 +170,9 @@ class ThemeData extends Model
|
|||
*/
|
||||
public function getFormFields()
|
||||
{
|
||||
if (!$theme = CmsTheme::load($this->theme))
|
||||
if (!$theme = CmsTheme::load($this->theme)) {
|
||||
throw new Exception(Lang::get('Unable to find theme with name :name', $this->theme));
|
||||
}
|
||||
|
||||
$config = $theme->getConfigArray('form');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue