FEATURE: prepare for installing templates

This commit is contained in:
Michal Kváček
2016-09-20 00:46:32 +02:00
parent 7a681fd7f7
commit f087da1b43
22 changed files with 397 additions and 253 deletions
+4 -6
View File
@@ -1,8 +1,7 @@
APP_ENV=testing APP_ENV=
APP_DEBUG=true APP_DEBUG=
APP_KEY=ZKZAzM23wQ6BPji6zffBjaTzZ3yW7zKQ
DB_HOST=localhost DB_HOST=
DB_DATABASE= DB_DATABASE=
DB_USERNAME= DB_USERNAME=
DB_PASSWORD= DB_PASSWORD=
@@ -16,5 +15,4 @@ MAIL_PASSWORD=
SITE_URL=/ SITE_URL=/
UPLOAD_URL=/public/uploads UPLOAD_URL=/public/uploads
THUMBNAILS_URL=/uploads/thumbnails THUMBNAILS_URL=/uploads/thumbnails
THEME=
+71
View File
@@ -0,0 +1,71 @@
<?php
namespace App\Console\Commands;
use App\Models\Module;
use Illuminate\Console\Command;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class SetTemplate extends Command
{
/**
* The name and signature of the console command.
* @var string
*/
protected $signature = 'template:set {template}';
/**
* The console command description.
* @var string
*/
protected $description = 'Install template';
/**
* Execute the console command.
* @return mixed
*/
public function handle()
{
$template = $this->argument('template');
$templatePath = app_path('../templates/' . $template);
if (!is_dir($templatePath) || !file_exists($templatePath . '/config.php')) {
throw new NotFoundHttpException('Invalid template ' . $template . '!');
}
// try to find currently installed template
$current = Module::where('is_template', true)->first();
if ($current) {
$this->line('Template is already set up. Currently using '.trans($current->name).'.');
$confirm = $this->ask('Uninstall it and install '.$template.'? [y/n]');
if ($confirm === 'y') {
$this->line('Uninstalling '.$current->name.'.');
$current->uninstall();
} else {
$this->line('Aborting installation.');
return;
}
}
// install template
$config = @include $templatePath . '/config.php';
try {
$config['staticName'] = $template;
Module::install($config['name'], $config['alias'], $config['description'], $config['handler'], false, $config);
} catch (\Exception $e) {
$this->error('Cannot install template '.$template.'.');
return;
}
// theme written
$this->line('Template successfully setup.');
// $this->line('');
// $this->line(' ** PUBLISHING ASSETS AND VIEWS **');
// // publish assets and views for module and theme
// $this->call('vendor:publish', ['--tag' => ['public-assets'], '--force' => true]);
// $this->call('vendor:publish', ['--tag' => ['module-views'], '--force' => true]);
// $this->call('vendor:publish');
}
}
-70
View File
@@ -1,70 +0,0 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Str;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class SetTheme extends Command
{
/**
* The name and signature of the console command.
* @var string
*/
protected $signature = 'theme:set {theme_name}';
/**
* The console command description.
* @var string
*/
protected $description = 'Set theme for visitor area';
/**
* Create a new command instance.
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
* @return mixed
*/
public function handle()
{
$theme = $this->argument('theme_name');
if (!is_dir(resource_path('views/visitor/' . $theme))) {
throw new NotFoundHttpException('Invalid theme ' . $theme . '!');
}
// load .env file
$envFile = base_path('.env');
$env = file_get_contents($envFile);
if (!Str::contains($env, 'THEME=')) {
$env = sprintf("%s\nTHEME=%s\n", $env, $theme);
} else {
$env = preg_replace('/THEME=(.*)/i', 'THEME=' . $theme, $env, -1, $cnt);
}
// try to write content
$bytesWritten = file_put_contents($envFile, $env);
// check if write was successfull
if (!$bytesWritten) {
throw new \Exception('Cannot write to ' . base_path('.env') . '. Add THEME=' . $theme . ' to your .env file manualy.');
}
// theme written
$this->line('Theme successfully setup.');
$this->line('');
$this->line(' ** PUBLISHING ASSETS AND VIEWS **');
// publish assets and views for module and theme
$this->call('vendor:publish', ['--tag' => ['public-assets'], '--force' => true]);
$this->call('vendor:publish', ['--tag' => ['module-views'], '--force' => true]);
$this->call('vendor:publish');
}
}
+1 -1
View File
@@ -21,7 +21,7 @@ class Kernel extends ConsoleKernel
Commands\Translations::class, Commands\Translations::class,
Commands\TranslateAll::class, Commands\TranslateAll::class,
Commands\InitDatabaseSchema::class, Commands\InitDatabaseSchema::class,
Commands\SetTheme::class, Commands\SetTemplate::class,
AddLanguage::class AddLanguage::class
]; ];
+1 -1
View File
@@ -5,7 +5,7 @@ use App\Models\User;
interface BaseModuleHandler interface BaseModuleHandler
{ {
public static function getModuleId(); // public static function getModuleId();
/** /**
* Register admin menu (or multiple ones) * Register admin menu (or multiple ones)
@@ -0,0 +1,11 @@
<?php
namespace App\Handlers\Contracts;
use App\Models\Module;
interface TemplateHandler extends BaseModuleHandler
{
public static function uninstall(Module $template);
public static function getPublicTemplatePaths();
}
@@ -187,7 +187,6 @@ class TemplateRegistrator
$registeredTemplates = Templates::getWithTranslations(); $registeredTemplates = Templates::getWithTranslations();
if (!in_array($templateName, $registeredTemplates)) { if (!in_array($templateName, $registeredTemplates)) {
$params = [ $params = [
'template_name' => $templateName, 'template_name' => $templateName,
'name' => $templateName, 'name' => $templateName,
@@ -197,8 +196,6 @@ class TemplateRegistrator
'editable' => 1 'editable' => 1
]; ];
echo 'ukladam do db '.$templateName."\n";
// save template into database // save template into database
$newTemplate = Template::create($params); $newTemplate = Template::create($params);
+34 -3
View File
@@ -2,6 +2,7 @@
namespace App\Models; namespace App\Models;
use App\Handlers\Contracts\TemplateHandler;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\App;
@@ -20,7 +21,8 @@ class Module extends Model
'module_settings', 'module_settings',
'enabled', 'enabled',
'support_categories', 'support_categories',
'manages_content' 'manages_content',
'is_template'
]; ];
protected $guarded = []; protected $guarded = [];
@@ -45,6 +47,7 @@ class Module extends Model
} }
$managesContent = $handler ? in_array('App\Handlers\Contracts\AppHandler', class_implements($handler)) : false; $managesContent = $handler ? in_array('App\Handlers\Contracts\AppHandler', class_implements($handler)) : false;
$isTemplate = $handler ? in_array(TemplateHandler::class, class_implements($handler)) : false;
$supportCategories = $managesContent ? call_user_func([$handler, 'supportCategories']) : false; $supportCategories = $managesContent ? call_user_func([$handler, 'supportCategories']) : false;
if ($parentModuleId) { if ($parentModuleId) {
@@ -62,8 +65,9 @@ class Module extends Model
'support_categories' => $supportCategories, 'support_categories' => $supportCategories,
'alias' => $alias, 'alias' => $alias,
'module_settings' => json_encode($settings), 'module_settings' => json_encode($settings),
'parent_id' => $parentModuleId, 'parent_id' => $parentModuleId ? $parentModuleId : null,
'enabled' => 1 'enabled' => 1,
'is_template' => $isTemplate
]); ]);
// install something module-specific // install something module-specific
@@ -73,4 +77,31 @@ class Module extends Model
return $module; return $module;
} }
public function uninstall() {
// check if user does not want to install module in runtime
if (!App::runningInConsole()) {
throw new \ErrorException('Modules can be uninstalled only via Artisan!');
}
// delete everything in /resources/views/visitor
$directories = \File::directories(resource_path('views/visitor'));
foreach ($directories as $directory) {
$success = \File::deleteDirectory($directory);
if (!$success) {
throw new \ErrorException('Cannot delete '.$directory);
}
}
$handler = $this->handler;
if ($handler) {
call_user_func([$handler, 'uninstall'], $this);
}
$this->delete();
}
} }
+3 -10
View File
@@ -39,13 +39,6 @@ class AppServiceProvider extends ServiceProvider
$this->registerTemplates(); $this->registerTemplates();
$this->registerSettings(); $this->registerSettings();
$this->registerSearch(); $this->registerSearch();
// check if given template is valid
$theme = config('app.theme');
$themeDir = resource_path('views/visitor/' . $theme);
if (!$theme || empty($theme) || !is_dir($themeDir)) {
throw new InvalidArgumentException('No or invalid theme set! Use artisan theme:set or edit .env file manually and include THEME option, please');
}
} }
/** /**
@@ -120,10 +113,10 @@ class AppServiceProvider extends ServiceProvider
/** /**
* @var $registrator TemplateRegistrator * @var $registrator TemplateRegistrator
*/ */
$registrator = $this->app->make('registerTemplateDir'); // $registrator = $this->app->make('registerTemplateDir');
$registrator->setBaseDirectory('resources/views/visitor'); // $registrator->setBaseDirectory('resources/views/visitor');
$registrator->register(config('app.theme'), 'admin/templates.core'); // $registrator->register(config('app.theme'), 'admin/templates.core');
} }
/** /**
@@ -5,18 +5,13 @@ use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use Mcamara\LaravelLocalization\Facades\LaravelLocalization; use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
use Symfony\Component\Translation\Translator;
class LaravelLocalizationServiceProvider extends ServiceProvider class LaravelLocalizationServiceProvider extends ServiceProvider
{ {
public function register() public function register()
{ {
try { $languages = DB::table('languages')
$languages = DB::table('languages') ->get();
->get();
} catch (\Exception $e) {
$languages = [];
}
$supportedLocales = []; $supportedLocales = [];
if (empty($languages)) { if (empty($languages)) {
@@ -28,11 +23,7 @@ class LaravelLocalizationServiceProvider extends ServiceProvider
]; ];
// create default language // create default language
try { Language::create($supportedLocales[config('app.locale')]);
Language::create($supportedLocales[config('app.locale')]);
} catch (\Exception $e) {
// ignore, table languages probably does not exist.
}
} }
foreach ($languages as $language) { foreach ($languages as $language) {
+3 -2
View File
@@ -21,7 +21,8 @@ class ModuleManager extends ServiceProvider
} }
// this service provider needs published config - config is merged right after this service provider // this service provider needs published config - config is merged right after this service provider
$modules = Module::get(); $modules = Module::where('is_template', false)
->get();
// iterate over all modules and enable or disable them // iterate over all modules and enable or disable them
foreach ($modules as $module) { foreach ($modules as $module) {
@@ -58,7 +59,7 @@ class ModuleManager extends ServiceProvider
// check if module config is writable // check if module config is writable
if (!is_writable(dirname($path))) { if (!is_writable(dirname($path))) {
Log::warning('Cannot write to '.$path); Log::warning('Cannot write to ' . $path);
return; return;
} }
+75
View File
@@ -0,0 +1,75 @@
<?php
namespace App\Providers;
use App\Handlers\Registrators\TemplateRegistrator;
use App\Models\Module;
use Illuminate\Support\Facades\App;
use Illuminate\Support\ServiceProvider;
use InvalidArgumentException;
class TemplateServiceProvider extends ServiceProvider
{
public function boot()
{
if (App::runningInConsole())
return;
parent::boot();
// select template
$template = Module::where('is_template', true)
->first();
if (!$template) {
throw new \ErrorException('Template is not set, cannot continue');
}
$templateSettings = json_decode($template->module_settings);
// include files
$files = isset($templateSettings->files) ? $templateSettings->files : [];
foreach ($files as $file) {
include_once app_path('../templates/' . $templateSettings->staticName . '/' . $file);
}
// register templates
$publicTemplates = call_user_func([$template->handler, 'getPublicTemplatePaths']);
if (!is_array($publicTemplates)) {
throw new \ErrorException($template->handler . '::getPublicTemplatePaths() must return array!');
}
if (empty($publicTemplates)) {
return;
}
/**
* @var $registrator TemplateRegistrator
*/
$registrator = $this->app->make('registerTemplateDir');
foreach ($publicTemplates as $template) {
// setup some global variables
// try {
// $registrator->setBaseDirectory('resources/views/modules/gallery/visitor');
// $registrator->setNamespace('gallery');
// $registrator->setModuleId(call_user_func([config('gallery.handler'), 'getModuleId']));
//
// // register path with current template name
// $registrator->register(config('app.theme'), 'gallery::admin/adminMenu.templatePath');
// } catch (InvalidArgumentException $e) {
// // ignore this exception
// }
}
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
}
}
+2 -1
View File
@@ -30,7 +30,8 @@
], ],
"psr-4": { "psr-4": {
"App\\": "app/", "App\\": "app/",
"Modules\\": "modules/" "Modules\\": "modules/",
"Templates\\": "templates/"
} }
}, },
"scripts": { "scripts": {
+77 -76
View File
@@ -129,49 +129,50 @@ return [
'providers' => [ 'providers' => [
/* /*
* Laravel Framework Service Providers... * Laravel Framework Service Providers...
*/ */
Illuminate\Auth\AuthServiceProvider::class, Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class, Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class, Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class, Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class, Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class, Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class, Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class, Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class, Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class, Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class, Illuminate\Mail\MailServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class, Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class, Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class, Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class, Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class, Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class, Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class, Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class, Illuminate\View\ViewServiceProvider::class,
Mcamara\LaravelLocalization\LaravelLocalizationServiceProvider::class, Mcamara\LaravelLocalization\LaravelLocalizationServiceProvider::class,
// this class must be before ModulesServiceProvider from PingPong, because it handles files module.json // this class must be before ModulesServiceProvider from PingPong, because it handles files module.json
App\Providers\ModuleManager::class, App\Providers\ModuleManager::class,
Pingpong\Modules\ModulesServiceProvider::class, Pingpong\Modules\ModulesServiceProvider::class,
Pingpong\Menus\MenusServiceProvider::class, Pingpong\Menus\MenusServiceProvider::class,
App\Providers\SubmodulesManager::class, App\Providers\SubmodulesManager::class,
\App\Providers\TemplateServiceProvider::class,
Franzose\ClosureTable\ClosureTableServiceProvider::class, Franzose\ClosureTable\ClosureTableServiceProvider::class,
\Watson\Sitemap\SitemapServiceProvider::class, \Watson\Sitemap\SitemapServiceProvider::class,
/* /*
* Application Service Providers... * Application Service Providers...
*/ */
App\Providers\AppServiceProvider::class, App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class, App\Providers\AuthServiceProvider::class,
App\Providers\EventServiceProvider::class, App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class, App\Providers\RouteServiceProvider::class,
App\Providers\GlobalViewDataProvider::class, App\Providers\GlobalViewDataProvider::class,
], ],
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Class Aliases | Class Aliases
@@ -185,41 +186,41 @@ return [
'aliases' => [ 'aliases' => [
'App' => Illuminate\Support\Facades\App::class, 'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class, 'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class, 'Auth' => Illuminate\Support\Facades\Auth::class,
'Blade' => Illuminate\Support\Facades\Blade::class, 'Blade' => Illuminate\Support\Facades\Blade::class,
'Cache' => Illuminate\Support\Facades\Cache::class, 'Cache' => Illuminate\Support\Facades\Cache::class,
'Config' => Illuminate\Support\Facades\Config::class, 'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class, 'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class, 'Crypt' => Illuminate\Support\Facades\Crypt::class,
'DB' => Illuminate\Support\Facades\DB::class, 'DB' => Illuminate\Support\Facades\DB::class,
'Eloquent' => Illuminate\Database\Eloquent\Model::class, 'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class, 'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class, 'File' => Illuminate\Support\Facades\File::class,
'Gate' => Illuminate\Support\Facades\Gate::class, 'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class, 'Hash' => Illuminate\Support\Facades\Hash::class,
'Lang' => Illuminate\Support\Facades\Lang::class, 'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class, 'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class, 'Mail' => Illuminate\Support\Facades\Mail::class,
'Menu' => Pingpong\Menus\MenuFacade::class, 'Menu' => Pingpong\Menus\MenuFacade::class,
'Module' => Pingpong\Modules\Facades\Module::class, 'Module' => Pingpong\Modules\Facades\Module::class,
'Password' => Illuminate\Support\Facades\Password::class, 'Password' => Illuminate\Support\Facades\Password::class,
'Queue' => Illuminate\Support\Facades\Queue::class, 'Queue' => Illuminate\Support\Facades\Queue::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class, 'Redirect' => Illuminate\Support\Facades\Redirect::class,
'Redis' => Illuminate\Support\Facades\Redis::class, 'Redis' => Illuminate\Support\Facades\Redis::class,
'Request' => Illuminate\Support\Facades\Request::class, 'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class, 'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class, 'Route' => Illuminate\Support\Facades\Route::class,
'Schema' => Illuminate\Support\Facades\Schema::class, 'Schema' => Illuminate\Support\Facades\Schema::class,
'Session' => Illuminate\Support\Facades\Session::class, 'Session' => Illuminate\Support\Facades\Session::class,
'Sitemap' => Watson\Sitemap\Facades\Sitemap::class, 'Sitemap' => Watson\Sitemap\Facades\Sitemap::class,
'Storage' => Illuminate\Support\Facades\Storage::class, 'Storage' => Illuminate\Support\Facades\Storage::class,
'URL' => Illuminate\Support\Facades\URL::class, 'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class, 'Validator' => Illuminate\Support\Facades\Validator::class,
'LaravelLocalization' => Mcamara\LaravelLocalization\Facades\LaravelLocalization::class, 'LaravelLocalization' => Mcamara\LaravelLocalization\Facades\LaravelLocalization::class,
'View' => Illuminate\Support\Facades\View::class, 'View' => Illuminate\Support\Facades\View::class,
], ],
]; ];
@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
class SaveTemplatesIntoModulesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('modules', function (Blueprint $table){
$table->boolean('is_template')->default(false)->comment('Templates can be treated as modules.');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('modules', function (Blueprint $table){
$table->dropColumn('is_template');
});
}
}
@@ -63,21 +63,21 @@ class ArticleServiceProvider extends ServiceProvider {
return $path . '/modules/article'; return $path . '/modules/article';
}, \Config::get('view.paths')), [$sourcePath]), 'article'); }, \Config::get('view.paths')), [$sourcePath]), 'article');
/** // /**
* @var $registrator TemplateRegistrator // * @var $registrator TemplateRegistrator
*/ // */
try { // try {
// setup some global variables // // setup some global variables
$registrator = $this->app->make('registerTemplateDir'); // $registrator = $this->app->make('registerTemplateDir');
$registrator->setBaseDirectory('resources/views/modules/article/visitor'); // $registrator->setBaseDirectory('resources/views/modules/article/visitor');
$registrator->setNamespace('article'); // $registrator->setNamespace('article');
$registrator->setModuleId(Article::getModuleId()); // $registrator->setModuleId(Article::getModuleId());
//
// register path with current template name // // register path with current template name
$registrator->register(config('app.theme'), 'article::admin/adminMenu.templatePath'); // $registrator->register(config('app.theme'), 'article::admin/adminMenu.templatePath');
} catch (InvalidArgumentException $e) { // } catch (InvalidArgumentException $e) {
// ignore this exception // // ignore this exception
} // }
} }
/** /**
@@ -63,21 +63,21 @@ class ContactFormServiceProvider extends ServiceProvider
return $path . '/modules/contactform'; return $path . '/modules/contactform';
}, \Config::get('view.paths')), [$sourcePath]), 'contactform'); }, \Config::get('view.paths')), [$sourcePath]), 'contactform');
/** // /**
* @var $registrator TemplateRegistrator // * @var $registrator TemplateRegistrator
*/ // */
$registrator = $this->app->make('registerTemplateDir'); // $registrator = $this->app->make('registerTemplateDir');
try { // try {
// setup some global variables // // setup some global variables
$registrator->setBaseDirectory('resources/views/modules/contactform/visitor'); // $registrator->setBaseDirectory('resources/views/modules/contactform/visitor');
$registrator->setNamespace('contactform'); // $registrator->setNamespace('contactform');
$registrator->setModuleId(call_user_func([config('contactform.handler'), 'getModuleId'])); // $registrator->setModuleId(call_user_func([config('contactform.handler'), 'getModuleId']));
//
// register path with current template name // // register path with current template name
$registrator->register(config('app.theme'), 'contactform::admin/adminMenu.templatePath'); // $registrator->register(config('app.theme'), 'contactform::admin/adminMenu.templatePath');
} catch (InvalidArgumentException $e) { // } catch (InvalidArgumentException $e) {
// ignore this exception // // ignore this exception
} // }
} }
/** /**
@@ -63,21 +63,21 @@ class GalleryServiceProvider extends ServiceProvider
return $path.'/modules/gallery'; return $path.'/modules/gallery';
}, \Config::get('view.paths')), [$sourcePath]), 'gallery'); }, \Config::get('view.paths')), [$sourcePath]), 'gallery');
/** // /**
* @var $registrator TemplateRegistrator // * @var $registrator TemplateRegistrator
*/ // */
$registrator = $this->app->make('registerTemplateDir'); // $registrator = $this->app->make('registerTemplateDir');
try { // try {
// setup some global variables // // setup some global variables
$registrator->setBaseDirectory('resources/views/modules/gallery/visitor'); // $registrator->setBaseDirectory('resources/views/modules/gallery/visitor');
$registrator->setNamespace('gallery'); // $registrator->setNamespace('gallery');
$registrator->setModuleId(call_user_func([config('gallery.handler'), 'getModuleId'])); // $registrator->setModuleId(call_user_func([config('gallery.handler'), 'getModuleId']));
//
// register path with current template name // // register path with current template name
$registrator->register(config('app.theme'), 'gallery::admin/adminMenu.templatePath'); // $registrator->register(config('app.theme'), 'gallery::admin/adminMenu.templatePath');
} catch (InvalidArgumentException $e) { // } catch (InvalidArgumentException $e) {
// ignore this exception // // ignore this exception
} // }
} }
/** /**
@@ -38,18 +38,6 @@ class StaticPagesServiceProvider extends ServiceProvider
{ {
} }
// /**
// * Method for installing module into database
// */
// protected function install()
// {
// $handler = config('staticpages.handler');
// $installedModules = ModulesHandlerToId::getWithTranslations();
// if (!isset($installedModules[$handler])) {
// Module::install('staticpages::module.name', 'staticpages', 'staticpages::module.description');
// }
// }
/** /**
* Register config. * Register config.
* *
@@ -82,17 +70,17 @@ class StaticPagesServiceProvider extends ServiceProvider
* @var $registrator TemplateRegistrator * @var $registrator TemplateRegistrator
*/ */
$registrator = $this->app->make('registerTemplateDir'); $registrator = $this->app->make('registerTemplateDir');
try { // try {
// setup some global variables // // setup some global variables
$registrator->setBaseDirectory('resources/views/modules/staticpages/visitor'); // $registrator->setBaseDirectory('resources/views/modules/staticpages/visitor');
$registrator->setNamespace('staticpages'); // $registrator->setNamespace('staticpages');
$registrator->setModuleId(call_user_func([config('staticpages.handler'), 'getModuleId'])); // $registrator->setModuleId(call_user_func([config('staticpages.handler'), 'getModuleId']));
//
// register path with current template name // // register path with current template name
$registrator->register(config('app.theme'), 'staticpages::admin.templatePath'); // $registrator->register(config('app.theme'), 'staticpages::admin.templatePath');
} catch (InvalidArgumentException $e) { // } catch (InvalidArgumentException $e) {
// ignore this exception // // ignore this exception
} // }
} }
/** /**
@@ -0,0 +1,8 @@
<?php
namespace Templates\Base\OnePage\Handlers;
use App\Handlers\Contracts\TemplateHandler;
abstract class OnePage implements TemplateHandler
{
}
+10
View File
@@ -0,0 +1,10 @@
<?php
return [
'handler' => \Templates\Base\OnePage\Handlers\OnePage::class,
'name' => 'Sablona',
'alias' => 'sablona',
'description' => 'Sablona jednostrankova',
'files' => [
'routes.php'
]
];
+6
View File
@@ -0,0 +1,6 @@
<?php
Route::group(['middleware' => 'web', 'prefix' => 'test', 'namespace' => 'Modules\Blog\Comments\Http\Controllers'], function()
{
Route::get('/neco-neco', 'CommentsController@index')->name('template.route');
});