From d335ce8eef30f27395f5cf25013d64400ef1c851 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sun, 21 Oct 2018 20:41:10 +0200 Subject: [PATCH] Tweak ContentInterface so that callables can be used as well --- framework/core/src/Admin/Content/AdminPayload.php | 2 +- framework/core/src/Forum/Content/AssertRegistered.php | 2 +- framework/core/src/Forum/Content/Discussion.php | 2 +- framework/core/src/Forum/Content/Index.php | 2 +- framework/core/src/Frontend/Content/ContentInterface.php | 2 +- framework/core/src/Frontend/Content/CorePayload.php | 2 +- framework/core/src/Frontend/Content/Layout.php | 2 +- framework/core/src/Frontend/Content/Meta.php | 2 +- framework/core/src/Frontend/HtmlDocumentFactory.php | 4 ++-- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/framework/core/src/Admin/Content/AdminPayload.php b/framework/core/src/Admin/Content/AdminPayload.php index 59fdf45ab..b5b7c3f15 100644 --- a/framework/core/src/Admin/Content/AdminPayload.php +++ b/framework/core/src/Admin/Content/AdminPayload.php @@ -52,7 +52,7 @@ class AdminPayload implements ContentInterface $this->events = $events; } - public function populate(HtmlDocument $document, Request $request) + public function __invoke(HtmlDocument $document, Request $request) { $settings = $this->settings->all(); diff --git a/framework/core/src/Forum/Content/AssertRegistered.php b/framework/core/src/Forum/Content/AssertRegistered.php index 8bceb4761..fba9c3639 100644 --- a/framework/core/src/Forum/Content/AssertRegistered.php +++ b/framework/core/src/Forum/Content/AssertRegistered.php @@ -20,7 +20,7 @@ class AssertRegistered implements ContentInterface { use AssertPermissionTrait; - public function populate(HtmlDocument $document, Request $request) + public function __invoke(HtmlDocument $document, Request $request) { $this->assertRegistered($request->getAttribute('actor')); } diff --git a/framework/core/src/Forum/Content/Discussion.php b/framework/core/src/Forum/Content/Discussion.php index 15e8d9bd4..78dc042c2 100644 --- a/framework/core/src/Forum/Content/Discussion.php +++ b/framework/core/src/Forum/Content/Discussion.php @@ -49,7 +49,7 @@ class Discussion implements ContentInterface $this->view = $view; } - public function populate(HtmlDocument $document, Request $request) + public function __invoke(HtmlDocument $document, Request $request) { $queryParams = $request->getQueryParams(); $page = max(1, array_get($queryParams, 'page')); diff --git a/framework/core/src/Forum/Content/Index.php b/framework/core/src/Forum/Content/Index.php index d83de36e6..21db56c60 100644 --- a/framework/core/src/Forum/Content/Index.php +++ b/framework/core/src/Forum/Content/Index.php @@ -44,7 +44,7 @@ class Index implements ContentInterface /** * {@inheritdoc} */ - public function populate(HtmlDocument $document, Request $request) + public function __invoke(HtmlDocument $document, Request $request) { $queryParams = $request->getQueryParams(); diff --git a/framework/core/src/Frontend/Content/ContentInterface.php b/framework/core/src/Frontend/Content/ContentInterface.php index cbf167272..4a4a2f614 100644 --- a/framework/core/src/Frontend/Content/ContentInterface.php +++ b/framework/core/src/Frontend/Content/ContentInterface.php @@ -20,5 +20,5 @@ interface ContentInterface * @param HtmlDocument $document * @param Request $request */ - public function populate(HtmlDocument $document, Request $request); + public function __invoke(HtmlDocument $document, Request $request); } diff --git a/framework/core/src/Frontend/Content/CorePayload.php b/framework/core/src/Frontend/Content/CorePayload.php index 87a390f6d..51f5b1524 100644 --- a/framework/core/src/Frontend/Content/CorePayload.php +++ b/framework/core/src/Frontend/Content/CorePayload.php @@ -41,7 +41,7 @@ class CorePayload implements ContentInterface $this->api = $api; } - public function populate(HtmlDocument $document, Request $request) + public function __invoke(HtmlDocument $document, Request $request) { $document->payload = array_merge( $document->payload, diff --git a/framework/core/src/Frontend/Content/Layout.php b/framework/core/src/Frontend/Content/Layout.php index 07896215d..08105ed0f 100644 --- a/framework/core/src/Frontend/Content/Layout.php +++ b/framework/core/src/Frontend/Content/Layout.php @@ -29,7 +29,7 @@ class Layout implements ContentInterface $this->layoutView = $layoutView; } - public function populate(HtmlDocument $document, Request $request) + public function __invoke(HtmlDocument $document, Request $request) { $document->layoutView = $this->layoutView; } diff --git a/framework/core/src/Frontend/Content/Meta.php b/framework/core/src/Frontend/Content/Meta.php index 6d037c3ae..772ffb191 100644 --- a/framework/core/src/Frontend/Content/Meta.php +++ b/framework/core/src/Frontend/Content/Meta.php @@ -16,7 +16,7 @@ use Psr\Http\Message\ServerRequestInterface as Request; class Meta implements ContentInterface { - public function populate(HtmlDocument $document, Request $request) + public function __invoke(HtmlDocument $document, Request $request) { $document->meta = array_merge($document->meta, $this->buildMeta($document)); $document->head = array_merge($document->head, $this->buildHead($document)); diff --git a/framework/core/src/Frontend/HtmlDocumentFactory.php b/framework/core/src/Frontend/HtmlDocumentFactory.php index a588e1138..846e9e345 100644 --- a/framework/core/src/Frontend/HtmlDocumentFactory.php +++ b/framework/core/src/Frontend/HtmlDocumentFactory.php @@ -61,7 +61,7 @@ class HtmlDocumentFactory } /** - * @param ContentInterface $content + * @param ContentInterface|callable $content */ public function add($content) { @@ -116,7 +116,7 @@ class HtmlDocumentFactory protected function populate(HtmlDocument $view, Request $request) { foreach ($this->content as $content) { - $content->populate($view, $request); + $content($view, $request); } }