FIX: lots of bugfixes, sorry for ugly commit

This commit is contained in:
Michal Kváček
2017-02-09 23:10:11 +01:00
parent 99ed8806da
commit b7d4ab9515
47 changed files with 180 additions and 199 deletions
+12 -5
View File
@@ -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';