58 lines
1.3 KiB
PHP
58 lines
1.3 KiB
PHP
<?php
|
|
namespace App\CMS\Pipeline\DisplayPipeline;
|
|
|
|
use App\CMS\Contracts\Content\DisplayPipeline\Pipeline;
|
|
use App\CMS\Contracts\Content\DisplayPipeline\Process;
|
|
use App\CMS\Pipeline\AbstractPipeline;
|
|
use App\Models\Content\Content;
|
|
|
|
class DisplayPipeline extends AbstractPipeline implements Pipeline
|
|
{
|
|
/**
|
|
* DisplayPipeline constructor.
|
|
*/
|
|
public function __construct()
|
|
{
|
|
$this->acceptedProcessInterface = Process::class;
|
|
}
|
|
|
|
/**
|
|
* Run pipeline
|
|
*
|
|
* @param Content $page
|
|
*
|
|
* @return Content
|
|
*/
|
|
function run(Content $page)
|
|
{
|
|
$this->runBeforeStart($page);
|
|
|
|
foreach ($this->processes as $process) {
|
|
/**
|
|
* @var $run Process
|
|
*/
|
|
$run = new $process;
|
|
$run->handle($page);
|
|
}
|
|
|
|
$this->runBeforeRender($page);
|
|
|
|
return $page;
|
|
}
|
|
|
|
protected function runBeforeStart($page)
|
|
{
|
|
if (!is_null($this->beforeStart)) {
|
|
$process = new $this->beforeStart;
|
|
$process->handle($page);
|
|
}
|
|
}
|
|
|
|
protected function runBeforeRender($page)
|
|
{
|
|
if (!is_null($this->beforeRender)) {
|
|
$process = new $this->beforeRender;
|
|
$process->handle($page);
|
|
}
|
|
}
|
|
} |