FEATURE: add pipeline for saving also into prague-tennis-camp template

This commit is contained in:
Michal Kváček
2017-03-10 09:52:31 +01:00
parent 9bec808d38
commit 0e2aecb529
3 changed files with 39 additions and 36 deletions
+12 -36
View File
@@ -66,46 +66,22 @@ class Handler implements TemplateHandler
'module' => 'StaticPages',
'templateName' => 'staticpages::admin.templatePath'
],
[
'module' => 'ArticleList',
'alias' => config('articlelist.alias'),
'templateName' => 'articlelist::module.templatePath'
],
[
'module' => 'Article',
'alias' => config('articleias'),
'templateName' => 'article::module.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)
{
// if ($content->isHomepage) {
$category = Category::where('url', 'trenersky-tym')
->first();
$content->traineeTeamCategory = $category;
// }
}
/**
* 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
*/
public static function beforeSave(Content & $content, $inputData)
{
}
}
@@ -0,0 +1,23 @@
<?php
namespace Templates\PragueTennisCamp\Pipeline;
use App\CMS\Contracts\Content\DisplayPipeline\Process;
use App\Models\Content\Content;
use Modules\Categories\Entities\Category;
class AddTraineeTeamCategory implements Process {
/**
* Process and modify given page
*
* @param Content $page
*
* @return mixed
*/
function handle(Content & $page)
{
$category = Category::where('url', 'trenersky-tym')
->first();
$page->traineeTeamCategory = $category;
}
}
@@ -3,6 +3,7 @@ namespace Templates\PragueTennisCamp\Providers;
use App\CMS\Helpers\Template;
use Modules\ContactForm\Widgets\Form\Presenter;
use Templates\PragueTennisCamp\Pipeline\AddTraineeTeamCategory;
class ServiceProvider extends \Illuminate\Support\ServiceProvider {
/**
@@ -20,5 +21,8 @@ class ServiceProvider extends \Illuminate\Support\ServiceProvider {
return;
Presenter::$template = Template::name('widgets.contact.form');
$pipeline = app('displayPipeline');
$pipeline->add(AddTraineeTeamCategory::class);
}
}