FEATURE #2350 @2h: add pipeline for displaying content
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user