mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
51 lines
1.5 KiB
PHP
51 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Chill\PersonBundle\Templating\Entity;
|
|
|
|
use Chill\MainBundle\Templating\Entity\ChillEntityRenderInterface;
|
|
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
|
|
|
class SocialIssueRender implements ChillEntityRenderInterface
|
|
{
|
|
private TranslatableStringHelper $translatableStringHelper;
|
|
|
|
public const SEPARATOR_KEY = 'default.separator';
|
|
|
|
public const DEFAULT_ARGS = [
|
|
self::SEPARATOR_KEY => ' > ',
|
|
];
|
|
|
|
public function __construct(TranslatableStringHelper $translatableStringHelper)
|
|
{
|
|
$this->translatableStringHelper = $translatableStringHelper;
|
|
}
|
|
|
|
public function supports($entity, array $options): bool
|
|
{
|
|
return $entity instanceof SocialIssueRender;
|
|
}
|
|
|
|
public function renderString($socialIssue, array $options): string
|
|
{
|
|
/** @var $socialIssue SocialIssue */
|
|
$options = \array_merge(self::DEFAULT_ARGS, $options);
|
|
|
|
$str = $this->translatableStringHelper->localize($socialIssue->getTitle());
|
|
|
|
while ($socialIssue->hasParent()) {
|
|
$socialIssue = $socialIssue->getParent();
|
|
$str .= $options[self::SEPARATOR_KEY].$this->translatableStringHelper->localize(
|
|
$socialIssue->getTitle()
|
|
);
|
|
}
|
|
|
|
return $str;
|
|
}
|
|
|
|
public function renderBox($entity, array $options): string
|
|
{
|
|
return "renderBox not implemented for social issue";
|
|
}
|
|
}
|