FEATURE #2350 @2h: add pipeline for displaying content

This commit is contained in:
Michal Kváček
2017-03-08 23:38:37 +01:00
parent 44fb6b1be5
commit 450000fadd
10 changed files with 222 additions and 11 deletions
+16 -7
View File
@@ -3,7 +3,6 @@
namespace App\Http\Controllers\Visitor;
use App\CMS\Contracts\Repositories\Content;
use App\CMS\Helpers\PageRenderer;
use App\Http\Controllers\Controller;
use App\Models\Content\Content as ContentModel;
use Illuminate\Support\Facades\Auth;
@@ -24,11 +23,20 @@ class ContentPage extends Controller
$this->content = $content;
}
/**
* Load page by URL
*
* This method also caches content
*
* @param $url
*
* @return mixed
*/
public function getPage($url)
{
$contentModel = $this->content;
$page = Cache::remember('content-' . $url, setting('contentCacheLifetime', 5), function () use ($contentModel, $url) {
return $contentModel->getByURL($url);
$contentRepository = $this->content;
$page = Cache::remember('content-' . $url, setting('contentCacheLifetime', 5), function () use ($contentRepository, $url) {
return $contentRepository->getByURL($url);
});
// no page available
@@ -54,9 +62,10 @@ class ContentPage extends Controller
abort(404);
}
// add one new "view" for page
$page->view();
$displayPipeline = app('displayPipeline');
$page = $displayPipeline->run($page);
return Controller::VisitorsView($page->template, ['page' => $page]);
return PageRenderer::render($page);
}
}