entity render: options, html classes, corrections

note: span.chill-entity tag is replaced by section.chill-entity tag.
because some cases are not valid html :
* span.chill-entity > div
* span.badge > div.chill-entity
This commit is contained in:
2021-07-28 11:39:27 +02:00
parent df3d32c653
commit 57a8b49f49
9 changed files with 141 additions and 112 deletions

View File

@@ -22,7 +22,7 @@ namespace Chill\ThirdPartyBundle\Templating\Entity;
use Chill\MainBundle\Templating\Entity\AbstractChillEntityRender;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Symfony\Bridge\Twig\TwigEngine;
use Symfony\Component\Templating\EngineInterface;
/**
*
@@ -30,15 +30,12 @@ use Symfony\Bridge\Twig\TwigEngine;
*/
class ThirdPartyRender extends AbstractChillEntityRender
{
/**
*
* @var TwigEngine
*/
protected $templating;
public function __construct(TwigEngine $templating)
protected EngineInterface $engine;
public function __construct(EngineInterface $engine)
{
$this->templating = $templating;
$this->engine = $engine;
}
/**
@@ -49,17 +46,21 @@ class ThirdPartyRender extends AbstractChillEntityRender
*/
public function renderBox($entity, array $options): string
{
$params = [
'with_valid_from' => $options['with_valid_from'] ?? true,
'addLink' => $options['addLink'] ?? false,
'addEntity' => $options['addEntity'] ?? false,
'addInfo' => $options['addInfo'] ?? false,
'hLevel' => $options['hLevel'] ?? 3,
];
return
$this->getDefaultOpeningBox('_3party').
$this->templating->render('@ChillThirdParty/Entity/thirdparty.html.twig', [
$this->getDefaultOpeningBox('thirdparty') .
$this->engine->render('@ChillThirdParty/Entity/thirdparty.html.twig', [
'thirdparty' => $entity,
'with_valid_from' => $options['with_valid_from'] ?? true,
'addLink' => $options['addLink'] ?? false,
'addEntity' => $options['addEntity'] ?? false,
'addInfo' => $options['addInfo'] ?? false,
'display' => $options['display'] ?? 'raw',
'options' => $options
]).
'render' => $options['render'] ?? 'raw',
'options' => $params
]) .
$this->getDefaultClosingBox();
}