person search rendering more reponsive

This commit is contained in:
2021-05-20 19:20:06 +02:00
parent 6a62b46dec
commit 8ae113c872
7 changed files with 86 additions and 23 deletions

View File

@@ -5,10 +5,12 @@ namespace Chill\PersonBundle\Templating\Entity;
use Chill\MainBundle\Templating\Entity\ChillEntityRenderInterface;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Symfony\Component\Templating\EngineInterface;
class SocialIssueRender implements ChillEntityRenderInterface
{
private TranslatableStringHelper $translatableStringHelper;
private EngineInterface $engine;
public const SEPARATOR_KEY = 'default.separator';
@@ -16,9 +18,10 @@ class SocialIssueRender implements ChillEntityRenderInterface
self::SEPARATOR_KEY => ' > ',
];
public function __construct(TranslatableStringHelper $translatableStringHelper)
public function __construct(TranslatableStringHelper $translatableStringHelper, EngineInterface $engine)
{
$this->translatableStringHelper = $translatableStringHelper;
$this->engine = $engine;
}
public function supports($entity, array $options): bool
@@ -42,9 +45,27 @@ class SocialIssueRender implements ChillEntityRenderInterface
return $str;
}
public function renderBox($entity, array $options): string
protected function buildParents($socialIssue): array
{
return "renderBox not implemented for social issue";
$parents = [];
while ($socialIssue->hasParent()) {
$socialIssue = $parents[] = $socialIssue->getParent();
}
return $parents;
}
public function renderBox($socialIssue, array $options): string
{
$options = \array_merge(self::DEFAULT_ARGS, $options);
// give some help to twig: an array of parents
$parents = $this->buildParents($socialIssue);
return $this->engine->render('@ChillPerson/Entity/social_issue.html.twig', [
'socialIssue' => $socialIssue,
'parents' => $parents,
'options' => $options
]);
}
}