mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
person search rendering more reponsive
This commit is contained in:
@@ -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
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user