From d5e9747e80340f9b0ef3c4bdc5a939f809b6f61c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 26 Mar 2020 13:13:50 +0100 Subject: [PATCH] [chill entity render] fix usage of default entity rendering --- CHANGELOG.md | 2 ++ Templating/Entity/ChillEntityRender.php | 2 +- Templating/Entity/ChillEntityRenderExtension.php | 13 +++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9f72b469..ec47315d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -110,3 +110,5 @@ Master branch ============= - [translation] in french, replace "Modifier" by "Enregistrer" in the edit form +- [chill entity render] fix error when fallback to default entity render (usage of __toString()) + diff --git a/Templating/Entity/ChillEntityRender.php b/Templating/Entity/ChillEntityRender.php index fec14a594..8f8f58263 100644 --- a/Templating/Entity/ChillEntityRender.php +++ b/Templating/Entity/ChillEntityRender.php @@ -33,7 +33,7 @@ class ChillEntityRender extends AbstractChillEntityRender public function renderString($entity, array $options): string { - return $entity; + return (string) $entity; } public function supports($entity, array $options): bool diff --git a/Templating/Entity/ChillEntityRenderExtension.php b/Templating/Entity/ChillEntityRenderExtension.php index 98cb90ee5..23a90240f 100644 --- a/Templating/Entity/ChillEntityRenderExtension.php +++ b/Templating/Entity/ChillEntityRenderExtension.php @@ -41,6 +41,11 @@ class ChillEntityRenderExtension extends AbstractExtension */ protected $defaultRender; + public function __construct() + { + $this->defaultRender = new ChillEntityRender(); + } + public function getFilters() { return [ @@ -55,12 +60,20 @@ class ChillEntityRenderExtension extends AbstractExtension public function renderString($entity, array $options = []): string { + if (NULL === $entity) { + return ''; + } + return $this->getRender($entity, $options) ->renderString($entity, $options); } public function renderBox($entity, array $options = []): string { + if (NULL === $entity) { + return ''; + } + return $this->getRender($entity, $options) ->renderBox($entity, $options); }