FEATURE: add functionality for modifying content page on template level

This commit is contained in:
Michal Kváček
2016-09-20 20:14:02 +02:00
parent d9feb92612
commit f3873ed61c
6 changed files with 125 additions and 19 deletions
@@ -32,9 +32,4 @@ abstract class OnePage implements TemplateHandler
public static function uninstall(Module $template)
{
}
public static function beforeRender(Content $content)
{
return $content;
}
}
+44 -7
View File
@@ -1,11 +1,55 @@
<?php
namespace Templates\Jednostrankovka;
use App\Http\Requests\Request;
use App\Models\Content;
use Templates\Base\OnePage\Handlers\OnePage;
class Handler extends OnePage
{
/**
* Prepare Content object to be rendered using Blade template
*
* @param Content $content
*/
public static function beforeRender(Content & $content)
{
}
/**
* 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)
{
}
/**
* 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 [
@@ -19,11 +63,4 @@ class Handler extends OnePage
]
];
}
public static function beforeRender(Content $content)
{
$content->content = str_replace('a', 'AAAA', $content->content);
return $content;
}
}