mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-07 13:59:43 +00:00
Partage d'export enregistré et génération asynchrone des exports
This commit is contained in:
@@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Templating\Entity;
|
||||
use Chill\MainBundle\Templating\Entity\ChillEntityRenderInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||
use Symfony\Component\Clock\ClockInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
@@ -28,6 +29,8 @@ class SocialActionRender implements ChillEntityRenderInterface
|
||||
self::NO_BADGE => false,
|
||||
self::SHOW_AND_CHILDREN => false,
|
||||
self::AND_CHILDREN_MENTION => 'social_action.and children',
|
||||
self::SHOW_SOCIAL_ISSUE => false,
|
||||
self::SHOW_DEACTIVATED => false,
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -43,7 +46,27 @@ class SocialActionRender implements ChillEntityRenderInterface
|
||||
*/
|
||||
final public const SHOW_AND_CHILDREN = 'show_and_children';
|
||||
|
||||
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, private readonly \Twig\Environment $engine, private readonly TranslatorInterface $translator) {}
|
||||
/**
|
||||
* Append the related social issue next to the social action name, in parenthesis.
|
||||
*
|
||||
* Currently only in string rendering.
|
||||
*/
|
||||
final public const SHOW_SOCIAL_ISSUE = 'show_social_issue';
|
||||
|
||||
/**
|
||||
* Append a mention "deactivated" next to the social action name, in parenthesis, if the social action is deactivated.
|
||||
*
|
||||
* Currently only in string rendering.
|
||||
*/
|
||||
final public const SHOW_DEACTIVATED = 'show_deactivated';
|
||||
|
||||
public function __construct(
|
||||
private readonly TranslatableStringHelper $translatableStringHelper,
|
||||
private readonly \Twig\Environment $engine,
|
||||
private readonly TranslatorInterface $translator,
|
||||
private readonly SocialIssueRender $socialIssueRender,
|
||||
private readonly ClockInterface $clock,
|
||||
) {}
|
||||
|
||||
public function renderBox($socialAction, array $options): string
|
||||
{
|
||||
@@ -79,6 +102,14 @@ class SocialActionRender implements ChillEntityRenderInterface
|
||||
$title .= ' ('.$this->translator->trans($options[self::AND_CHILDREN_MENTION]).')';
|
||||
}
|
||||
|
||||
if ($options[self::SHOW_SOCIAL_ISSUE]) {
|
||||
$title .= ' ('.$this->socialIssueRender->renderString($socialAction->getIssue(), []).')';
|
||||
}
|
||||
|
||||
if ($options[self::SHOW_DEACTIVATED] && $socialAction->isDesactivated(\DateTime::createFromImmutable($this->clock->now()))) {
|
||||
$title .= ' ('.$this->translator->trans('Disabled').')';
|
||||
}
|
||||
|
||||
return $title;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user