After this separation, search engine may be registered once for visitor area (with one presenter) and once for admin area (with different presenter).
116 lines
3.4 KiB
PHP
116 lines
3.4 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Handlers\Registrators\SearchEngineRegistrator;
|
|
use App\Handlers\Registrators\SettingsExtensionRegistrator;
|
|
use App\Handlers\Registrators\TemplateRegistrator;
|
|
use App\Handlers\Registrators\WidgetRegistrator;
|
|
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\Widgets\HtmlCode\HtmlCode;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Bootstrap any application services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function boot()
|
|
{
|
|
$this->registerWidgets();
|
|
$this->registerTemplates();
|
|
$this->registerSettings();
|
|
$this->registerSearch();
|
|
}
|
|
|
|
/**
|
|
* Register any application services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function register()
|
|
{
|
|
if ($this->app->environment() == 'local') {
|
|
$this->app->register('Iber\Generator\ModelGeneratorProvider');
|
|
$this->app->register('Barryvdh\Debugbar\ServiceProvider');
|
|
}
|
|
|
|
// register PingPong module extension
|
|
$this->app->register('Pingpong\Modules\ModulesServiceProvider');
|
|
$this->app->register('Pingpong\Menus\MenusServiceProvider');
|
|
|
|
// create singletons for registering widgets
|
|
$this->app->singleton('registerWidget', function ($app) {
|
|
return new WidgetRegistrator($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);
|
|
}
|
|
|
|
/**
|
|
* Register path with editable contents
|
|
*/
|
|
private function registerTemplates()
|
|
{
|
|
/**
|
|
* @var $registrator TemplateRegistrator
|
|
*/
|
|
$registrator = $this->app->make('registerTemplateDir');
|
|
$registrator->setBaseDirectory('resources/views/visitor');
|
|
|
|
$registrator->register(config('app.theme'), 'admin/templates.core');
|
|
}
|
|
|
|
/**
|
|
* 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');
|
|
}
|
|
|
|
/**
|
|
* 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);
|
|
}
|
|
}
|