Move halcyon registration to model boot

Attempt to fix issue where service provider looks at system_preferences database table that doesn't exist yet as part of the boot() method
Fixes #1897
This commit is contained in:
Samuel Georges 2016-04-04 18:37:09 +10:00
parent 838f836051
commit f68eb3f20f
3 changed files with 33 additions and 18 deletions

View File

@ -48,7 +48,6 @@ class ServiceProvider extends ModuleServiceProvider
{
parent::boot('cms');
$this->bootDefaultTheme();
$this->bootMenuItemEvents();
$this->bootRichEditorEvents();
}
@ -285,21 +284,4 @@ class ServiceProvider extends ModuleServiceProvider
}
});
}
/**
* Boot the default theme.
*/
protected function bootDefaultTheme()
{
$resolver = App::make('halcyon');
if ($resolver->getDefaultDatasource()) {
return;
}
$defaultTheme = App::runningInBackend()
? CmsTheme::getEditThemeCode()
: CmsTheme::getActiveThemeCode();
$resolver->setDefaultDatasource($defaultTheme);
}
}

View File

@ -1,5 +1,6 @@
<?php namespace Cms\Classes;
use App;
use Lang;
use Config;
use October\Rain\Halcyon\Model as HalcyonModel;
@ -62,6 +63,36 @@ class CmsObject extends HalcyonModel implements CmsObjectContract
parent::__construct($attributes);
}
/**
* The "booting" method of the model.
* @return void
*/
protected static function boot()
{
parent::boot();
static::bootDefaultTheme();
}
/**
* Boot all of the bootable traits on the model.
* @return void
*/
protected static function bootDefaultTheme()
{
$resolver = static::getDatasourceResolver();
if ($resolver->getDefaultDatasource()) {
return;
}
$defaultTheme = App::runningInBackend()
? Theme::getEditThemeCode()
: Theme::getActiveThemeCode();
Theme::load($defaultTheme);
$resolver->setDefaultDatasource($defaultTheme);
}
/**
* Loads the object from a file.
* This method is used in the CMS back-end. It doesn't use any caching.

View File

@ -97,9 +97,11 @@ class ServiceProvider extends ModuleServiceProvider
App::singleton('backend.helper', function () {
return new \Backend\Helpers\Backend;
});
App::singleton('backend.menu', function () {
return \Backend\Classes\NavigationManager::instance();
});
App::singleton('backend.auth', function () {
return \Backend\Classes\AuthManager::instance();
});