mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-09 00:04:59 +00:00
Merge remote-tracking branch 'origin/master' into fix-person-tests
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,14 +18,15 @@ 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
|
||||
{
|
||||
return $entity instanceof SocialIssueRender;
|
||||
return $entity instanceof SocialIssue;
|
||||
}
|
||||
|
||||
public function renderString($socialIssue, array $options): string
|
||||
@@ -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