Fix filtres and scopes to take into account job and scope when the refferrer is add to the accompanying period work

This commit is contained in:
2023-10-16 10:58:41 +02:00
parent 63e9d1a96f
commit 68d28f3e28
24 changed files with 352 additions and 173 deletions

View File

@@ -28,10 +28,14 @@ class UserRender implements ChillEntityRenderInterface
'main_scope' => true,
'user_job' => true,
'absence' => true,
'at' => null,
];
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly \Twig\Environment $engine, private readonly TranslatorInterface $translator) {}
/**
* @param mixed $entity
*/
public function renderBox($entity, array $options): string
{
$opts = array_merge(self::DEFAULT_OPTIONS, $options);
@@ -42,20 +46,23 @@ class UserRender implements ChillEntityRenderInterface
]);
}
/**
* @param mixed $entity
*/
public function renderString($entity, array $options): string
{
$opts = array_merge(self::DEFAULT_OPTIONS, $options);
$str = $entity->getLabel();
if (null !== $entity->getUserJob() && $opts['user_job']) {
if (null !== $entity->getUserJob($opts['at']) && $opts['user_job']) {
$str .= ' (' . $this->translatableStringHelper
->localize($entity->getUserJob()->getLabel()) . ')';
->localize($entity->getUserJob($opts['at'])->getLabel()) . ')';
}
if (null !== $entity->getMainScope() && $opts['main_scope']) {
if (null !== $entity->getMainScope($opts['at']) && $opts['main_scope']) {
$str .= ' (' . $this->translatableStringHelper
->localize($entity->getMainScope()->getName()) . ')';
->localize($entity->getMainScope($opts['at'])->getName()) . ')';
}
if ($entity->isAbsent() && $opts['absence']) {