diff --git a/system/src/Grav/Framework/Flex/FlexCollection.php b/system/src/Grav/Framework/Flex/FlexCollection.php index 86671bdc2..beacea8d8 100644 --- a/system/src/Grav/Framework/Flex/FlexCollection.php +++ b/system/src/Grav/Framework/Flex/FlexCollection.php @@ -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'; diff --git a/system/src/Grav/Framework/Flex/FlexIndex.php b/system/src/Grav/Framework/Flex/FlexIndex.php index 9fa1a603c..b3b133edc 100644 --- a/system/src/Grav/Framework/Flex/FlexIndex.php +++ b/system/src/Grav/Framework/Flex/FlexIndex.php @@ -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]); } diff --git a/system/src/Grav/Framework/Flex/FlexObject.php b/system/src/Grav/Framework/Flex/FlexObject.php index 78cbcfed5..8fe8602d6 100644 --- a/system/src/Grav/Framework/Flex/FlexObject.php +++ b/system/src/Grav/Framework/Flex/FlexObject.php @@ -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'; diff --git a/system/src/Grav/Framework/Flex/Interfaces/FlexCommonInterface.php b/system/src/Grav/Framework/Flex/Interfaces/FlexCommonInterface.php index 89f12100f..482aef226 100644 --- a/system/src/Grav/Framework/Flex/Interfaces/FlexCommonInterface.php +++ b/system/src/Grav/Framework/Flex/Interfaces/FlexCommonInterface.php @@ -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 = []); } diff --git a/system/src/Grav/Framework/Interfaces/RenderInterface.php b/system/src/Grav/Framework/Interfaces/RenderInterface.php new file mode 100644 index 000000000..9185c1712 --- /dev/null +++ b/system/src/Grav/Framework/Interfaces/RenderInterface.php @@ -0,0 +1,38 @@ +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 = []); +}