do not throw an exception when null element are passed to chill_entity_render_box and chill_entity_render_string

This commit is contained in:
2020-03-13 16:27:39 +01:00
parent a5c9562a4b
commit 2aa9188fbc
2 changed files with 12 additions and 3 deletions

View File

@@ -55,12 +55,20 @@ class ChillEntityRenderExtension extends AbstractExtension
public function renderString($entity, array $options = []): string
{
if ($entity === NULL) {
return '';
}
return $this->getRender($entity, $options)
->renderString($entity, $options);
}
public function renderBox($entity, array $options = []): string
{
if ($entity === null) {
return '';
}
return $this->getRender($entity, $options)
->renderBox($entity, $options);
}
@@ -70,7 +78,7 @@ class ChillEntityRenderExtension extends AbstractExtension
$this->renders[] = $render;
}
protected function getRender($entity, $options): ChillEntityRenderInterface
protected function getRender($entity, $options): ?ChillEntityRenderInterface
{
foreach ($this->renders as $render) {
if ($render->supports($entity, $options)) {