Added a Theme::databaseLayerEnabled method to make checking for the db layer easier

This commit is contained in:
Luke Towers 2018-11-22 13:41:11 -06:00
parent 0a8450b21c
commit 7809f9ada5
2 changed files with 26 additions and 8 deletions

View File

@ -505,6 +505,21 @@ class Theme
return ThemeData::forTheme($this);
}
/**
* Checks to see if the database layer has been enabled
*
* @return boolean
*/
public static function databaseLayerEnabled()
{
$enableDbLayer = Config::get('cms.enableDatabaseLayer', false);
if (is_null($enableDbLayer)) {
$enableDbLayer = !Config::get('app.debug');
}
return $enableDbLayer && App::hasDatabase();
}
/**
* Ensures this theme is registered as a Halcyon them datasource.
* @return void
@ -514,12 +529,7 @@ class Theme
$resolver = App::make('halcyon');
if (!$resolver->hasDatasource($this->dirName)) {
$enableDbLayer = Config::get('cms.enableDatabaseLayer', false);
if (is_null($enableDbLayer)) {
$enableDbLayer = !Config::get('app.debug');
}
if ($enableDbLayer && App::hasDatabase()) {
if (static::databaseLayerEnabled()) {
$datasource = new AutoDatasource([
new DbDatasource($this->dirName, 'cms_theme_contents'),
new FileDatasource($this->getPath(), App::make('files')),

View File

@ -464,7 +464,11 @@ class Index extends Controller
*/
protected function canCommitTemplate($template)
{
$result = true;
$result = true; // will set to false by default
if (Theme::databaseLayerEnabled()) {
}
return $result;
}
@ -477,7 +481,11 @@ class Index extends Controller
*/
protected function canResetTemplate($template)
{
$result = true;
$result = true; // will set to false by default
if (Theme::databaseLayerEnabled()) {
}
return $result;
}