Fix closing motive render

This commit is contained in:
Julien Fastré 2023-10-16 17:58:22 +02:00
parent b32fa42afa
commit 8523f14214
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB

View File

@ -23,12 +23,15 @@ use Symfony\Contracts\Translation\TranslatorInterface;
*
* @implements ChillEntityRenderInterface<ClosingMotive>
*/
class ClosingMotiveRender implements ChillEntityRenderInterface
final readonly class ClosingMotiveRender implements ChillEntityRenderInterface
{
use BoxUtilsChillEntityRenderTrait;
private const SEPARATOR = ' > ';
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper) {}
public function __construct(
private TranslatableStringHelper $translatableStringHelper,
private TranslatorInterface $translator
) {}
public function renderBox($entity, array $options): string
{
@ -55,7 +58,7 @@ class ClosingMotiveRender implements ChillEntityRenderInterface
private function renderStringRecursive(ClosingMotive $motive, string $existing, array $options)
{
$newExisting = $this->translatableStringHelper->localize($motive->getName());
$isCancled = $motive->getIsCanceledAccompanyingPeriod() ? $this->translator->trans('( Canceled period )') : '';
$isCanceled = $motive->getIsCanceledAccompanyingPeriod() ? $this->translator->trans('( Canceled period )') : '';
if ($motive->hasParent()) {
if ('' !== $existing) {
@ -64,7 +67,7 @@ class ClosingMotiveRender implements ChillEntityRenderInterface
return $this->renderStringRecursive(
$motive->getParent(),
$newExisting . ' ' . $isCancled,
$newExisting . ' ' . $isCanceled,
$options
);
}
@ -73,6 +76,6 @@ class ClosingMotiveRender implements ChillEntityRenderInterface
return $newExisting . self::SEPARATOR . $existing;
}
return $newExisting . ' ' . $isCancled;
return $newExisting . ' ' . $isCanceled;
}
}