[chill entity render] fix usage of default entity rendering

This commit is contained in:
Julien Fastré 2020-03-26 13:13:50 +01:00
parent a5c9562a4b
commit d5e9747e80
3 changed files with 16 additions and 1 deletions

View File

@ -110,3 +110,5 @@ Master branch
============= =============
- [translation] in french, replace "Modifier" by "Enregistrer" in the edit form - [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())

View File

@ -33,7 +33,7 @@ class ChillEntityRender extends AbstractChillEntityRender
public function renderString($entity, array $options): string public function renderString($entity, array $options): string
{ {
return $entity; return (string) $entity;
} }
public function supports($entity, array $options): bool public function supports($entity, array $options): bool

View File

@ -41,6 +41,11 @@ class ChillEntityRenderExtension extends AbstractExtension
*/ */
protected $defaultRender; protected $defaultRender;
public function __construct()
{
$this->defaultRender = new ChillEntityRender();
}
public function getFilters() public function getFilters()
{ {
return [ return [
@ -55,12 +60,20 @@ class ChillEntityRenderExtension extends AbstractExtension
public function renderString($entity, array $options = []): string public function renderString($entity, array $options = []): string
{ {
if (NULL === $entity) {
return '';
}
return $this->getRender($entity, $options) return $this->getRender($entity, $options)
->renderString($entity, $options); ->renderString($entity, $options);
} }
public function renderBox($entity, array $options = []): string public function renderBox($entity, array $options = []): string
{ {
if (NULL === $entity) {
return '';
}
return $this->getRender($entity, $options) return $this->getRender($entity, $options)
->renderBox($entity, $options); ->renderBox($entity, $options);
} }