121 lines
3.3 KiB
PHP
121 lines
3.3 KiB
PHP
<?php
|
|
namespace Templates\Binarity;
|
|
|
|
use App\Handlers\Contracts\TemplateHandler;
|
|
use App\Http\Requests\Request;
|
|
use App\Models\Content;
|
|
use App\Models\Module;
|
|
use App\Models\User;
|
|
use App\Models\WidgetArea;
|
|
use Templates\Binarity\Shortcodes\DarkBlock;
|
|
use Templates\Binarity\Shortcodes\TechnologiesWrapper;
|
|
use Templates\Binarity\Shortcodes\Technology;
|
|
use Webwizo\Shortcodes\Facades\Shortcode;
|
|
|
|
class Handler implements TemplateHandler
|
|
{
|
|
/**
|
|
* Register admin menu (or multiple ones)
|
|
*
|
|
* This cannot be in ServiceProvider because Session is started at middleware. And ServiceProvider is called before
|
|
* starting any middleware..
|
|
*
|
|
* @param User $user model of logged user
|
|
*/
|
|
public static function registerAdminMenu(User $user)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Install module.
|
|
*
|
|
* This method is called after inserting info about module into database. It can be called only using Artisan in
|
|
* CLI.
|
|
*/
|
|
public static function install()
|
|
{
|
|
WidgetArea::create(['deletable' => 0, 'code' => 'mainMenu', 'name' => 'Menu']);
|
|
}
|
|
|
|
/**
|
|
* Uninstall template
|
|
*
|
|
* Delete some items in database, delete files etc.
|
|
*
|
|
* @param Module $template
|
|
*/
|
|
public static function uninstall(Module $template)
|
|
{
|
|
WidgetArea::where('code', 'mainMenu')->delete();
|
|
}
|
|
|
|
/**
|
|
* 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::admin.templatePath'
|
|
],
|
|
[
|
|
'module' => 'ArticleList',
|
|
'templateName' => 'articlelist::admin.templatePath'
|
|
],
|
|
[
|
|
'module' => 'Article',
|
|
'templateName' => 'article::admin.templatePath'
|
|
],
|
|
|
|
[
|
|
'module' => 'ContactForm',
|
|
'templateName' => 'contactform::admin/adminMenu.templatePath'
|
|
]
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Prepare Content object to be rendered using Blade template
|
|
*
|
|
* @param Content $content
|
|
*/
|
|
public static function beforeRender(Content & $content)
|
|
{
|
|
Shortcode::register('technologies', TechnologiesWrapper::class);
|
|
Shortcode::register('tech', Technology::class);
|
|
Shortcode::register('dark', DarkBlock::class);
|
|
|
|
}
|
|
|
|
/**
|
|
* 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)
|
|
{
|
|
}
|
|
} |