mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
89 lines
2.9 KiB
PHP
89 lines
2.9 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Chill is a software for social workers
|
|
*
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
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;
|
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
|
|
|
class AccompanyingPeriodWorkWorkflowHandler implements EntityWorkflowHandlerInterface
|
|
{
|
|
private AccompanyingPeriodWorkRepository $repository;
|
|
|
|
private TranslatableStringHelperInterface $translatableStringHelper;
|
|
|
|
private TranslatorInterface $translator;
|
|
|
|
public function __construct(
|
|
AccompanyingPeriodWorkRepository $repository,
|
|
TranslatableStringHelperInterface $translatableStringHelper,
|
|
TranslatorInterface $translator
|
|
) {
|
|
$this->repository = $repository;
|
|
$this->translatableStringHelper = $translatableStringHelper;
|
|
$this->translator = $translator;
|
|
}
|
|
|
|
public function getEntityData(EntityWorkflow $entityWorkflow, array $options = []): array
|
|
{
|
|
return [
|
|
'persons' => $this->getRelatedEntity($entityWorkflow)
|
|
->getPersons(),
|
|
];
|
|
}
|
|
|
|
public function getEntityTitle(EntityWorkflow $entityWorkflow, array $options = []): string
|
|
{
|
|
$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
|
|
{
|
|
return $this->repository->find($entityWorkflow->getRelatedEntityId());
|
|
}
|
|
|
|
public function getRoleShow(EntityWorkflow $entityWorkflow): ?string
|
|
{
|
|
return null;
|
|
}
|
|
|
|
public function getTemplate(EntityWorkflow $entityWorkflow, array $options = []): string
|
|
{
|
|
return '@ChillPerson/Workflow/_accompanying_period_work.html.twig';
|
|
}
|
|
|
|
public function getTemplateData(EntityWorkflow $entityWorkflow, array $options = []): array
|
|
{
|
|
return [
|
|
'entity_workflow' => $entityWorkflow,
|
|
'work' => $this->getRelatedEntity($entityWorkflow),
|
|
];
|
|
}
|
|
|
|
public function supports(EntityWorkflow $entityWorkflow, array $options = []): bool
|
|
{
|
|
return $entityWorkflow->getRelatedEntityClass() === AccompanyingPeriodWork::class;
|
|
}
|
|
|
|
public function supportsFreeze(EntityWorkflow $entityWorkflow, array $options = []): bool
|
|
{
|
|
return false;
|
|
}
|
|
}
|