mirror of
https://github.com/flarum/framework.git
synced 2024-11-28 11:34:36 +08:00
Tweak ContentInterface so that callables can be used as well
This commit is contained in:
parent
eafc637475
commit
86b26ce2fb
|
@ -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();
|
||||
|
||||
|
|
|
@ -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'));
|
||||
}
|
||||
|
|
|
@ -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'));
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user