mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-29 11:03:50 +00:00
FEATURE [absence][render] add absence tag to renderbox and renderstring
This commit is contained in:
@@ -13,8 +13,10 @@ namespace Chill\MainBundle\Templating\Entity;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
use DateTimeImmutable;
|
||||
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use function array_merge;
|
||||
|
||||
class UserRender implements ChillEntityRenderInterface
|
||||
@@ -22,16 +24,20 @@ class UserRender implements ChillEntityRenderInterface
|
||||
public const DEFAULT_OPTIONS = [
|
||||
'main_scope' => true,
|
||||
'user_job' => true,
|
||||
'absence' => true,
|
||||
];
|
||||
|
||||
private EngineInterface $engine;
|
||||
|
||||
private TranslatableStringHelper $translatableStringHelper;
|
||||
|
||||
public function __construct(TranslatableStringHelper $translatableStringHelper, EngineInterface $engine)
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
public function __construct(TranslatableStringHelper $translatableStringHelper, EngineInterface $engine, TranslatorInterface $translator)
|
||||
{
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
$this->engine = $engine;
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
public function renderBox($entity, array $options): string
|
||||
@@ -63,6 +69,12 @@ class UserRender implements ChillEntityRenderInterface
|
||||
->localize($entity->getMainScope()->getName()) . ')';
|
||||
}
|
||||
|
||||
$current_date = new DateTimeImmutable();
|
||||
|
||||
if (null !== $entity->getAbsenceStart() && $entity->getAbsenceStart() < $current_date && $opts['main_scope']) {
|
||||
$str .= ' (' . $this->translator->trans('absence.Absent') . ')';
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user