Merge branch 'dev' into widget_menu
This commit is contained in:
@@ -11,20 +11,30 @@ use App\Handlers\Search\Content;
|
||||
use App\Handlers\Search\Files;
|
||||
use App\Handlers\Search\Presenters\AdminContent as AdminContentPresenter;
|
||||
use App\Handlers\Search\Presenters\AdminFiles;
|
||||
use App\Models\Template;
|
||||
use App\Widgets\HtmlCode\HtmlCode;
|
||||
use App\Widgets\Menu\Extensions\URL;
|
||||
use App\Widgets\Menu\Menu;
|
||||
use App\Widgets\OrbitSlider\OrbitSlider;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
// ignore running from artisan
|
||||
if (App::runningInConsole()) {
|
||||
$this->publishViewResources();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->registerWidgets();
|
||||
$this->registerTemplates();
|
||||
$this->registerSettings();
|
||||
@@ -33,7 +43,6 @@ class AppServiceProvider extends ServiceProvider
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
@@ -87,6 +96,7 @@ class AppServiceProvider extends ServiceProvider
|
||||
// register some menu extensions
|
||||
$menuExtensions = $this->app->make('registerMenuExtension');
|
||||
$menuExtensions->register(new URL());
|
||||
$registrator->register(OrbitSlider::class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,7 +131,48 @@ class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
$registrator = $this->app->make('registerSearchEngine');
|
||||
|
||||
$registrator->register(new Content(), new AdminContentPresenter());
|
||||
$registrator->register(new Files(), new AdminFiles());
|
||||
$registrator->register(new Content(), new AdminContentPresenter(), SearchEngineRegistrator::ADMIN);
|
||||
$registrator->register(new Files(), new AdminFiles(), SearchEngineRegistrator::ADMIN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish all public assets from all themes
|
||||
*/
|
||||
private function publishViewResources()
|
||||
{
|
||||
$themes = File::directories(resource_path('views/visitor'));
|
||||
|
||||
$assets = [];
|
||||
foreach ($themes as $theme) {
|
||||
$themeName = basename($theme);
|
||||
|
||||
if (is_dir($theme . '/'.Template::ASSETS_DIRECTORY)) {
|
||||
$assets[$theme . '/'.Template::ASSETS_DIRECTORY] = public_path('assets/' . $themeName);
|
||||
}
|
||||
|
||||
if (is_dir($theme . '/'.Template::MODULES_DIRECTORY)) {
|
||||
$this->publishModuleViews($theme . '/'.Template::MODULES_DIRECTORY, $themeName);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($assets)) {
|
||||
$this->publishes($assets, 'public-assets');
|
||||
}
|
||||
}
|
||||
|
||||
private function publishModuleViews($themeModules, $themeName)
|
||||
{
|
||||
$modules = File::directories($themeModules);
|
||||
|
||||
$moduleViews = [];
|
||||
foreach ($modules as $module) {
|
||||
$moduleName = strtolower(basename($module));
|
||||
|
||||
$moduleViews[$module] = resource_path('views/modules/' . $moduleName . '/visitor/' . $themeName);
|
||||
}
|
||||
|
||||
if (!empty($moduleViews)) {
|
||||
$this->publishes($moduleViews, 'module-views');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\Settings;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
@@ -15,6 +16,11 @@ class GlobalViewDataProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
// ignore running from artisan
|
||||
if (App::runningInConsole()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$settings = new Settings();
|
||||
|
||||
foreach ($settings->getForView() as $key => $value) {
|
||||
@@ -33,7 +39,7 @@ class GlobalViewDataProvider extends ServiceProvider
|
||||
*/
|
||||
private function createPattern($function)
|
||||
{
|
||||
return '/(?<!\w)(\s*)@' . $function . '\(\s*(.*)\)/';
|
||||
return '/(?<!\w)(\s*)@' . $function.'\(([^)]+)*\)/';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,6 +65,13 @@ class GlobalViewDataProvider extends ServiceProvider
|
||||
return preg_replace($pattern, $code, $view);
|
||||
});
|
||||
|
||||
Blade::extend(function ($view) {
|
||||
$pattern = $this->createPattern('asset');
|
||||
$code = '<?php echo \App\Helpers\Template::asset($2); ?>';
|
||||
|
||||
return preg_replace($pattern, $code, $view);
|
||||
});
|
||||
|
||||
// register extension for rendering widget areas
|
||||
Blade::extend(function ($view) {
|
||||
$pattern = $this->createPattern('widgetArea');
|
||||
|
||||
@@ -3,17 +3,22 @@
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\Module;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class ModuleManager extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap the application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
// ignore running from artisan
|
||||
if (App::runningInConsole()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// this service provider needs published config - config is merged right after this service provider
|
||||
$modules = Module::get();
|
||||
|
||||
@@ -25,7 +30,6 @@ class ModuleManager extends ServiceProvider
|
||||
|
||||
/**
|
||||
* Register the application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
@@ -34,7 +38,6 @@ class ModuleManager extends ServiceProvider
|
||||
|
||||
/**
|
||||
* Read config file and merge it with module config in database.
|
||||
*
|
||||
* This method REQUIRES published config of given module (otherwise config(modulename) is not available)!
|
||||
*
|
||||
* @param Module $module
|
||||
@@ -53,7 +56,7 @@ class ModuleManager extends ServiceProvider
|
||||
$path = config('modules.paths.modules') . DIRECTORY_SEPARATOR . $config->staticName . DIRECTORY_SEPARATOR . 'module.json';
|
||||
|
||||
// check if module config is writable
|
||||
if (!is_writable($path)) {
|
||||
if (!is_writable(dirname($path))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user