FIX: lots of bugfixes, sorry for ugly commit
This commit is contained in:
@@ -25,13 +25,11 @@ class ModuleManager extends ServiceProvider
|
||||
|
||||
// iterate over all modules and enable or disable them
|
||||
foreach ($modules as $module) {
|
||||
|
||||
$module->moduleSettings = json_decode($module->moduleSettings);
|
||||
$module->module_settings = json_decode($module->module_settings);
|
||||
|
||||
if ($module->is_template) {
|
||||
|
||||
if (isset($module->moduleSettings->providers) && !empty($module->moduleSettings->providers)) {
|
||||
foreach ($module->moduleSettings->providers as $provider) {
|
||||
if (isset($module->module_settings->providers) && !empty($module->module_settings->providers)) {
|
||||
foreach ($module->module_settings->providers as $provider) {
|
||||
$this->app->register($provider);
|
||||
}
|
||||
}
|
||||
@@ -61,7 +59,7 @@ class ModuleManager extends ServiceProvider
|
||||
*/
|
||||
private function createModulesJson(Module $module)
|
||||
{
|
||||
$config = $module->moduleSettings;
|
||||
$config = $module->module_settings;
|
||||
|
||||
if (is_null($config)) {
|
||||
return;
|
||||
|
||||
@@ -3,18 +3,19 @@ namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
abstract class ModuleServiceProvider extends ServiceProvider {
|
||||
abstract class ModuleServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Indicates if loading of the provider is deferred.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $defer = false;
|
||||
|
||||
protected $alias = false;
|
||||
protected $path = false;
|
||||
|
||||
abstract protected function setModuleAlias();
|
||||
|
||||
abstract protected function setModulePath();
|
||||
|
||||
/**
|
||||
@@ -26,7 +27,7 @@ abstract class ModuleServiceProvider extends ServiceProvider {
|
||||
{
|
||||
$this->setModuleAlias();
|
||||
$this->setModulePath();
|
||||
|
||||
|
||||
$this->registerTranslations();
|
||||
$this->registerConfig();
|
||||
$this->registerViews();
|
||||
@@ -39,7 +40,7 @@ abstract class ModuleServiceProvider extends ServiceProvider {
|
||||
*/
|
||||
protected function registerConfig()
|
||||
{
|
||||
$this->publishes([$this->path . '/../Config/config.php' => config_path($this->alias.'.php')]);
|
||||
$this->publishes([$this->path . '/../Config/config.php' => config_path($this->alias . '.php')]);
|
||||
$this->mergeConfigFrom($this->path . '/../Config/config.php', $this->alias);
|
||||
}
|
||||
|
||||
@@ -54,14 +55,16 @@ abstract class ModuleServiceProvider extends ServiceProvider {
|
||||
*/
|
||||
protected function registerViews()
|
||||
{
|
||||
$viewPath = base_path('resources/views/modules/'.$this->alias);
|
||||
$viewPath = base_path('resources/views/modules/' . $this->alias);
|
||||
$sourcePath = $this->path . '/../Resources/views';
|
||||
|
||||
$this->publishes([$sourcePath => $viewPath], 'module-views');
|
||||
|
||||
$this->loadViewsFrom(array_merge(array_map(function ($path) {
|
||||
return $path . '/modules/'.$this->alias;
|
||||
return $path . '/modules/' . $this->alias;
|
||||
}, \Config::get('view.paths')), [$sourcePath]), $this->alias);
|
||||
|
||||
if (is_dir($sourcePath)) {
|
||||
$this->publishes([$sourcePath => $viewPath], 'module-views');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,5 +76,4 @@ abstract class ModuleServiceProvider extends ServiceProvider {
|
||||
{
|
||||
$this->loadTranslationsFrom($this->path . '/../Resources/lang', $this->alias);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -44,7 +44,7 @@ class SubmodulesManager extends ServiceProvider
|
||||
$initFiles = $config->get('files', []);
|
||||
|
||||
foreach ($initFiles as $file) {
|
||||
@include $submodulePath . DIRECTORY_SEPARATOR . $file;
|
||||
require $submodulePath . DIRECTORY_SEPARATOR . $file;
|
||||
}
|
||||
} catch (FileNotFoundException $e) {
|
||||
// ignore missing module and do not register this submodule
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Providers;
|
||||
use App\CMS\Contracts\Repositories\Template as TemplateContract;
|
||||
use App\CMS\Handlers\Registrators\TemplateRegistrator;
|
||||
use App\CMS\Helpers\CurrentTemplate;
|
||||
use App\Models\Module;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
@@ -44,6 +45,9 @@ class TemplateServiceProvider extends ServiceProvider
|
||||
|
||||
public function registerTemplatePaths($publicTemplates)
|
||||
{
|
||||
$modules = Module::all()
|
||||
->pluck('id', 'alias');
|
||||
|
||||
/**
|
||||
* @var $registrator TemplateRegistrator
|
||||
*/
|
||||
@@ -51,14 +55,17 @@ class TemplateServiceProvider extends ServiceProvider
|
||||
foreach ($publicTemplates as $template) {
|
||||
// setup some global variables
|
||||
$module = strtolower($template['module']);
|
||||
$alias = isset($template['alias']) ? $template['alias'] : $module;
|
||||
$namespace = isset($template['namespace']) ? $template['namespace'] : strtolower($template['module']);
|
||||
|
||||
if (!$modules->get($alias)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// register path with current template name
|
||||
|
||||
$registrator->setNamespace($namespace);
|
||||
if (is_callable([config($module . '.handler'), 'getModuleId'])) {
|
||||
$registrator->setModuleId(call_user_func([config($module . '.handler'), 'getModuleId']));
|
||||
}
|
||||
$registrator->setModuleId($modules->get($alias));
|
||||
$registrator->register('resources/views/modules/' . $module, 'visitor', $template['templateName']);
|
||||
}
|
||||
|
||||
@@ -81,11 +88,11 @@ class TemplateServiceProvider extends ServiceProvider
|
||||
private function publishViewResources()
|
||||
{
|
||||
$template = CurrentTemplate::get();
|
||||
if (!$template || is_null($template->moduleSettings)) {
|
||||
if (!$template || is_null($template->module_settings)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$templateDir = base_path('templates/' . $template->moduleSettings->staticName . '/Resources');
|
||||
$templateDir = base_path('templates/' . $template->module_settings->staticName . '/Resources');
|
||||
$assetsDir = $templateDir . '/' . TemplateContract::ASSETS_DIRECTORY;
|
||||
$viewsDir = $templateDir . '/views';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user