From 1cf0e51e9ad5e6407ff5b9f731223827589a0640 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 3 Feb 2021 18:50:34 +0100 Subject: [PATCH] fix https://framagit.org/Chill-project/Chill-Person/-/issues/22 bug --- .../Entity/ChillEntityRenderExtension.php | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/Templating/Entity/ChillEntityRenderExtension.php b/Templating/Entity/ChillEntityRenderExtension.php index e3f14d270..32aa12d85 100644 --- a/Templating/Entity/ChillEntityRenderExtension.php +++ b/Templating/Entity/ChillEntityRenderExtension.php @@ -24,28 +24,33 @@ use Twig\Extension\AbstractExtension; use Twig\TwigFilter; /** - * + * Class ChillEntityRenderExtension * + * @package Chill\MainBundle\Templating\Entity */ class ChillEntityRenderExtension extends AbstractExtension { /** - * * @var ChillEntityRenderInterface */ protected $renders = []; /** - * * @var ChillEntityRender */ protected $defaultRender; + /** + * ChillEntityRenderExtension constructor. + */ public function __construct() { $this->defaultRender = new ChillEntityRender(); } + /** + * @return array|TwigFilter[] + */ public function getFilters() { return [ @@ -58,31 +63,47 @@ class ChillEntityRenderExtension extends AbstractExtension ]; } + /** + * @param $entity + * @param array $options + * @return string + */ public function renderString($entity, array $options = []): string { if (NULL === $entity) { return ''; } - return $this->getRender($entity, $options) ->renderString($entity, $options); } + /** + * @param $entity + * @param array $options + * @return string + */ public function renderBox($entity, array $options = []): string { if (NULL === $entity) { return ''; } - return $this->getRender($entity, $options) ->renderBox($entity, $options); } + /** + * @param ChillEntityRenderInterface $render + */ public function addRender(ChillEntityRenderInterface $render) { $this->renders[] = $render; } + /** + * @param $entity + * @param $options + * @return ChillEntityRenderInterface|null + */ protected function getRender($entity, $options): ?ChillEntityRenderInterface { foreach ($this->renders as $render) { @@ -90,7 +111,6 @@ class ChillEntityRenderExtension extends AbstractExtension return $render; } } - return $this->defaultRender; } }