mirror of
https://github.com/getgrav/grav.git
synced 2026-03-23 21:10:08 +01:00
Added RenderInterface
This commit is contained in:
@@ -245,7 +245,7 @@ class FlexCollection extends ObjectCollection implements FlexCollectionInterface
|
||||
* {@inheritdoc}
|
||||
* @see FlexCollectionInterface::render()
|
||||
*/
|
||||
public function render($layout = null, array $context = [])
|
||||
public function render(string $layout = null, array $context = [])
|
||||
{
|
||||
if (null === $layout) {
|
||||
$layout = 'default';
|
||||
|
||||
@@ -221,7 +221,7 @@ class FlexIndex extends ObjectIndex implements FlexCollectionInterface, FlexInde
|
||||
* {@inheritdoc}
|
||||
* @see FlexCollectionInterface::render()
|
||||
*/
|
||||
public function render($layout = null, array $context = [])
|
||||
public function render(string $layout = null, array $context = [])
|
||||
{
|
||||
return $this->__call('render', [$layout, $context]);
|
||||
}
|
||||
|
||||
@@ -357,7 +357,7 @@ class FlexObject implements FlexObjectInterface, FlexAuthorizeInterface
|
||||
* {@inheritdoc}
|
||||
* @see FlexObjectInterface::render()
|
||||
*/
|
||||
public function render($layout = null, array $context = [])
|
||||
public function render(string $layout = null, array $context = [])
|
||||
{
|
||||
if (null === $layout) {
|
||||
$layout = 'default';
|
||||
|
||||
@@ -11,11 +11,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Grav\Framework\Flex\Interfaces;
|
||||
|
||||
use Grav\Framework\ContentBlock\ContentBlockInterface;
|
||||
use Grav\Framework\ContentBlock\HtmlBlock;
|
||||
use Grav\Framework\Flex\FlexDirectory;
|
||||
use Twig\Error\LoaderError;
|
||||
use Twig\Error\SyntaxError;
|
||||
use Grav\Framework\Interfaces\RenderInterface;
|
||||
|
||||
/**
|
||||
* Defines common interface shared with both Flex Objects and Collections.
|
||||
@@ -23,7 +20,7 @@ use Twig\Error\SyntaxError;
|
||||
* @used-by \Grav\Framework\Flex\FlexObject
|
||||
* @since 1.6
|
||||
*/
|
||||
interface FlexCommonInterface
|
||||
interface FlexCommonInterface extends RenderInterface
|
||||
{
|
||||
/**
|
||||
* Get Flex Type of the object / collection.
|
||||
@@ -64,22 +61,4 @@ interface FlexCommonInterface
|
||||
* @return string Returns cache checksum.
|
||||
*/
|
||||
public function getCacheChecksum(): string;
|
||||
|
||||
/**
|
||||
* Renders the object / collection.
|
||||
*
|
||||
* @example {% render object layout 'edit' with { limited: true } %}
|
||||
* @example {% render collection layout 'list' %}
|
||||
*
|
||||
* @param string $layout Layout name.
|
||||
* @param array $context Context given to the renderer.
|
||||
*
|
||||
* @return ContentBlockInterface|HtmlBlock Returns `HtmlBlock` containing the rendered output.
|
||||
* @throws \Exception
|
||||
* @throws \Throwable
|
||||
* @throws LoaderError
|
||||
* @throws SyntaxError
|
||||
* @api
|
||||
*/
|
||||
public function render($layout = null, array $context = []);
|
||||
}
|
||||
|
||||
38
system/src/Grav/Framework/Interfaces/RenderInterface.php
Normal file
38
system/src/Grav/Framework/Interfaces/RenderInterface.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @package Grav\Framework\Interfaces
|
||||
*
|
||||
* @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
|
||||
* @license MIT License; see LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Grav\Framework\Interfaces;
|
||||
|
||||
use Grav\Framework\ContentBlock\ContentBlockInterface;
|
||||
use Grav\Framework\ContentBlock\HtmlBlock;
|
||||
|
||||
/**
|
||||
* Defines common interface to render any object.
|
||||
*
|
||||
* @used-by \Grav\Framework\Flex\FlexObject
|
||||
* @since 1.6
|
||||
*/
|
||||
interface RenderInterface
|
||||
{
|
||||
/**
|
||||
* Renders the object.
|
||||
*
|
||||
* @example $block = $object->render('custom', ['variable' => 'value']);
|
||||
* @example {% render object layout 'custom' with { variable: 'value' } %}
|
||||
*
|
||||
* @param string|null $layout Layout to be used.
|
||||
* @param array|null $context Extra context given to the renderer.
|
||||
*
|
||||
* @return ContentBlockInterface|HtmlBlock Returns `HtmlBlock` containing the rendered output.
|
||||
* @api
|
||||
*/
|
||||
public function render(string $layout = null, array $context = []);
|
||||
}
|
||||
Reference in New Issue
Block a user