improve title rendering on workflows

This commit is contained in:
2022-02-25 12:09:53 +01:00
parent b7d6d69101
commit 2b257cc402
5 changed files with 39 additions and 12 deletions

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Workflow;
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\MainBundle\Workflow\EntityWorkflowHandlerInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
@@ -23,9 +24,15 @@ class AccompanyingPeriodWorkWorkflowHandler implements EntityWorkflowHandlerInte
private TranslatorInterface $translator;
public function __construct(AccompanyingPeriodWorkRepository $repository, TranslatorInterface $translator)
{
private TranslatableStringHelperInterface $translatableStringHelper;
public function __construct(
AccompanyingPeriodWorkRepository $repository,
TranslatableStringHelperInterface $translatableStringHelper,
TranslatorInterface $translator
) {
$this->repository = $repository;
$this->translatableStringHelper = $translatableStringHelper;
$this->translator = $translator;
}
@@ -39,7 +46,11 @@ class AccompanyingPeriodWorkWorkflowHandler implements EntityWorkflowHandlerInte
public function getEntityTitle(EntityWorkflow $entityWorkflow, array $options = []): string
{
return $this->translator->trans('workflow.Work (n°%w%)', ['%w%' => $entityWorkflow->getRelatedEntityId()]);
$work = $this->getRelatedEntity($entityWorkflow);
return
$this->translator->trans('workflow.Work (n°%w%)', ['%w%' => $entityWorkflow->getRelatedEntityId()])
.' - '.$this->translatableStringHelper->localize($work->getSocialAction()->getTitle());
}
public function getRelatedEntity(EntityWorkflow $entityWorkflow): ?AccompanyingPeriodWork