128 lines
4.1 KiB
PHP
128 lines
4.1 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\CMS\Handlers\Registrators\MenuExtensionRegistrator;
|
|
use App\CMS\Handlers\Registrators\SearchEngineRegistrator;
|
|
use App\CMS\Handlers\Registrators\SettingsExtensionRegistrator;
|
|
use App\CMS\Handlers\Registrators\TemplateRegistrator;
|
|
use App\CMS\Handlers\Registrators\WidgetRegistrator;
|
|
use App\CMS\Handlers\Search\Content;
|
|
use App\CMS\Handlers\Search\Files;
|
|
use App\CMS\Handlers\Search\Presenters\AdminContent as AdminContentPresenter;
|
|
use App\CMS\Handlers\Search\Presenters\AdminFiles;
|
|
use App\Models\Templates\Template;
|
|
use App\CMS\Widgets\HtmlCode\HtmlCode;
|
|
use App\CMS\Widgets\Menu\Menu;
|
|
use App\CMS\Widgets\OrbitSlider\OrbitSlider;
|
|
use Illuminate\Support\Facades\App;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\File;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use Symfony\Component\Process\Exception\InvalidArgumentException;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Bootstrap any application services.
|
|
* @return void
|
|
*/
|
|
public function boot()
|
|
{
|
|
// ignore running from artisan
|
|
if (App::runningInConsole()) {
|
|
return;
|
|
}
|
|
|
|
$this->registerWidgets();
|
|
$this->registerSettings();
|
|
$this->registerSearch();
|
|
}
|
|
|
|
/**
|
|
* Register any application services.
|
|
* @return void
|
|
*/
|
|
public function register()
|
|
{
|
|
if ($this->app->environment() == 'local') {
|
|
try {
|
|
$this->app->register('Barryvdh\Debugbar\ServiceProvider');
|
|
} catch (\Exception $e) {
|
|
// this service provider may not exist when switching from other environment than local
|
|
// until composer install is run
|
|
// just ignore this exception and when no service provider is available, do not use debugbar
|
|
}
|
|
}
|
|
|
|
// register PingPong module extension
|
|
$this->app->register('Pingpong\Modules\ModulesServiceProvider');
|
|
$this->app->register('Pingpong\Menus\MenusServiceProvider');
|
|
$this->app->register(LaravelLocalizationServiceProvider::class);
|
|
|
|
// create singletons for registering widgets
|
|
$this->app->singleton('registerWidget', function ($app) {
|
|
return new WidgetRegistrator($app);
|
|
});
|
|
|
|
$this->app->singleton('registerMenuExtension', function ($app) {
|
|
return new MenuExtensionRegistrator($app);
|
|
});
|
|
|
|
// create registrator for template directories
|
|
$this->app->singleton('registerTemplateDir', function ($app) {
|
|
return new TemplateRegistrator($app);
|
|
});
|
|
|
|
$this->app->singleton('registerSettingsExtension', function ($app) {
|
|
return new SettingsExtensionRegistrator($app);
|
|
});
|
|
|
|
$this->app->singleton('registerSearchEngine', function ($app) {
|
|
return new SearchEngineRegistrator($app);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Method for registering widgets.
|
|
*/
|
|
private function registerWidgets()
|
|
{
|
|
/**
|
|
* @var $registrator WidgetRegistrator
|
|
*/
|
|
$registrator = $this->app->make('registerWidget');
|
|
|
|
// register all available widgets
|
|
$registrator->register(HtmlCode::class);
|
|
$registrator->register(Menu::class);
|
|
// $registrator->register(OrbitSlider::class);
|
|
}
|
|
|
|
/**
|
|
* Register setting sections
|
|
*/
|
|
private function registerSettings()
|
|
{
|
|
$registrator = $this->app->make('registerSettingsExtension');
|
|
|
|
$registrator->register('basic', 'admin/settings.basic', 'admin.settings.parts.basic');
|
|
$registrator->register('meta', 'admin/settings.meta', 'admin.settings.parts.meta');
|
|
$registrator->register('social', 'admin/settings.socialSites', 'admin.settings.parts.social');
|
|
|
|
}
|
|
|
|
/**
|
|
* Register callbacks used for searching
|
|
*/
|
|
private function registerSearch()
|
|
{
|
|
$registrator = $this->app->make('registerSearchEngine');
|
|
|
|
$registrator->register(new Content(), new AdminContentPresenter(), SearchEngineRegistrator::ADMIN);
|
|
$registrator->register(new Files(), new AdminFiles(), SearchEngineRegistrator::ADMIN);
|
|
}
|
|
|
|
|
|
}
|