INIT: initial commit

This commit is contained in:
Michal Kváček
2017-09-14 11:36:05 +02:00
commit 1fc1601e68
18 changed files with 488 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
<?php
namespace Modules\ContentFilter\Pipelines\Display;
use App\CMS\Contracts\Content\DisplayPipeline\Process;
use App\Models\Content\Content;
use Modules\ContentFilter\Entities\ContentFilter;
class Filter implements Process
{
protected $filters;
public function __construct()
{
$this->filters = collect();
}
/**
* Process and modify given page
*
* @param Content $page
*
* @return void
*/
function handle(Content & $page)
{
$this->initFilters();
$page->pageContent = $this->applyFilters($page->pageContent);
}
protected function applyFilters($content)
{
foreach ($this->filters as $filter) {
$content = str_replace($filter->search, $filter->replace, $content);
}
return $content;
}
protected function initFilters()
{
$this->filters = ContentFilter::where('active', true)
->get();
}
}