98 lines
2.9 KiB
PHP
98 lines
2.9 KiB
PHP
<?php
|
|
namespace Templates\DoucovaniNeratovice\Handlers;
|
|
|
|
use App\Http\Requests\Request;
|
|
use App\Models\Content;
|
|
use App\Models\Module;
|
|
use App\Models\Widget;
|
|
use App\Models\WidgetArea;
|
|
use App\Models\WidgetInWidgetArea;
|
|
use Illuminate\Support\Facades\Artisan;
|
|
use Templates\Base\OnePage\Handlers\OnePage;
|
|
use Templates\Base\OnePage\Widgets\OnePageMenu\OnePageMenu;
|
|
|
|
class Handler extends OnePage
|
|
{
|
|
/**
|
|
* Modify input data into format which can be understood by edit template
|
|
*
|
|
* @param Content $content
|
|
*/
|
|
public static function beforePopulatingEditForm(Content & $content)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Slightly modify Content object before saving into database.
|
|
*
|
|
* This way we can do almost whatever we want - even in template
|
|
*
|
|
* @param Content $content
|
|
* @param Request $request
|
|
*/
|
|
public static function beforeSave(Content & $content, Request $request)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Install template
|
|
*/
|
|
public static function install()
|
|
{
|
|
parent::install();
|
|
|
|
try {
|
|
Artisan::call('install-module', ['name' => 'StaticPages']);
|
|
Artisan::call('install-module', ['name' => 'ContactForm']);
|
|
Artisan::call('install-module', ['name' => 'Categories']);
|
|
} catch (\Exception $e) {
|
|
//
|
|
}
|
|
|
|
$area = WidgetArea::create(['name' => 'Top menu', 'code' => 'topMenu', 'deletable' => 0]);
|
|
$widget = Widget::create([
|
|
'widget_type_handler' => OnePageMenu::class,
|
|
'name' => 'Menu',
|
|
'settings' => '{"containerClass": null}',
|
|
'deletable' => 0
|
|
]);
|
|
|
|
// bind widget with widget area
|
|
WidgetInWidgetArea::create(['widget_id' => $widget->id, 'widget_area_id' => $area->id, 'position' => 1]);
|
|
}
|
|
|
|
/**
|
|
* Get list of registered templates and supported modules.
|
|
*
|
|
* Returned array is expected to be array of arrays with following items: module, namespace and templateName.
|
|
* Example:
|
|
* return [
|
|
* ['module' => 'Article', 'templateName' => 'article::template.name']
|
|
* ];
|
|
*
|
|
* When no "namespace" is specified, value strtolower(module) is used instaed.
|
|
*
|
|
* @return array
|
|
*/
|
|
public static function getPublicTemplatePaths()
|
|
{
|
|
return [
|
|
[
|
|
'module' => 'StaticPages',
|
|
'templateName' => 'staticpages::adminMenu.templatePath'
|
|
],
|
|
[
|
|
'module' => 'ContactForm',
|
|
'templateName' => 'contactform::adminMenu.templatePath'
|
|
]
|
|
];
|
|
}
|
|
|
|
public static function uninstall(Module $template)
|
|
{
|
|
parent::uninstall($template);
|
|
|
|
WidgetArea::where('code', 'topMenu')->delete();
|
|
}
|
|
}
|