mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Merge branch 'upgrade-sf5' into 'master'
Upgrade chill to symfony 5 See merge request Chill-Projet/chill-bundles!735
This commit is contained in:
@@ -22,9 +22,7 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class PersonAddressMoveEventSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
public function __construct(private readonly \Twig\Environment $engine, private readonly NotificationPersisterInterface $notificationPersister, private readonly Security $security, private readonly TranslatorInterface $translator)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly \Twig\Environment $engine, private readonly NotificationPersisterInterface $notificationPersister, private readonly Security $security, private readonly TranslatorInterface $translator) {}
|
||||
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
|
@@ -23,9 +23,7 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class UserRefEventSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
public function __construct(private readonly Security $security, private readonly TranslatorInterface $translator, private readonly \Twig\Environment $engine, private readonly NotificationPersisterInterface $notificationPersister)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly Security $security, private readonly TranslatorInterface $translator, private readonly \Twig\Environment $engine, private readonly NotificationPersisterInterface $notificationPersister) {}
|
||||
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
|
@@ -20,8 +20,7 @@ readonly class AccompanyingPeriodStepChangeCronjob implements CronJobInterface
|
||||
public function __construct(
|
||||
private ClockInterface $clock,
|
||||
private AccompanyingPeriodStepChangeRequestor $requestor,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function canRun(?CronJobExecution $cronJobExecution): bool
|
||||
{
|
||||
|
@@ -23,8 +23,7 @@ class AccompanyingPeriodStepChangeMessageHandler implements MessageHandlerInterf
|
||||
public function __construct(
|
||||
private readonly AccompanyingPeriodRepository $accompanyingPeriodRepository,
|
||||
private readonly AccompanyingPeriodStepChanger $changer,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function __invoke(AccompanyingPeriodStepChangeRequestMessage $message): void
|
||||
{
|
||||
|
@@ -30,8 +30,7 @@ class AccompanyingPeriodStepChanger
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly LoggerInterface $logger,
|
||||
private readonly Registry $workflowRegistry,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function __invoke(AccompanyingPeriod $period, string $transition, ?string $workflowName = null): void
|
||||
{
|
||||
|
@@ -52,8 +52,7 @@ class ActionEvent extends \Symfony\Contracts\EventDispatcher\Event
|
||||
* an array of key value data to describe the movement.
|
||||
*/
|
||||
protected $metadata = [],
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Add Sql which will be executed **after** the delete statement.
|
||||
|
@@ -19,8 +19,7 @@ class PersonMoveCenterHistoryHandler implements PersonMoveSqlHandlerInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly PersonCenterHistoryRepository $centerHistoryRepository,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function supports(string $className, string $field): bool
|
||||
{
|
||||
|
@@ -33,8 +33,7 @@ class PersonMove
|
||||
private readonly EntityManagerInterface $em,
|
||||
private readonly PersonMoveManager $personMoveManager,
|
||||
private readonly EventDispatcherInterface $eventDispatcher,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Return the sql used to move or delete entities associated to a person to
|
||||
|
@@ -20,8 +20,7 @@ class PersonMoveManager
|
||||
* @var iterable<PersonMoveSqlHandlerInterface>
|
||||
*/
|
||||
private readonly iterable $handlers,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @param class-string $className
|
||||
|
@@ -23,6 +23,17 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
*/
|
||||
class EntityPersonCRUDController extends CRUDController
|
||||
{
|
||||
public function __construct(protected readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {}
|
||||
|
||||
protected function generateTemplateParameter(string $action, mixed $entity, Request $request, array $defaultTemplateParameters = [])
|
||||
{
|
||||
$templateParameters = parent::generateTemplateParameter($action, $entity, $request, $defaultTemplateParameters);
|
||||
|
||||
$templateParameters['person'] = $this->getPerson($request);
|
||||
|
||||
return $templateParameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the base method to add a filtering step to a person.
|
||||
*
|
||||
@@ -64,25 +75,6 @@ class EntityPersonCRUDController extends CRUDController
|
||||
return $qb;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function generateTemplateParameter(string $action, $entity, Request $request, array $defaultTemplateParameters = []): array
|
||||
{
|
||||
$person = $this->getPerson($request);
|
||||
|
||||
if (null === $person) {
|
||||
throw new \Exception('the `person_id` parameter is not set in the query. You should set it or override the current method to allow another behaviour: '.__METHOD__);
|
||||
}
|
||||
|
||||
return parent::generateTemplateParameter(
|
||||
$action,
|
||||
$entity,
|
||||
$request,
|
||||
\array_merge(['person' => $person], $defaultTemplateParameters)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the person from the request.
|
||||
*
|
||||
@@ -102,7 +94,7 @@ class EntityPersonCRUDController extends CRUDController
|
||||
return null;
|
||||
}
|
||||
|
||||
$person = $this->getDoctrine()
|
||||
$person = $this->managerRegistry
|
||||
->getRepository(Person::class)
|
||||
->find($request->query->getInt('person_id'));
|
||||
|
||||
|
@@ -20,6 +20,8 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class OneToOneEntityPersonCRUDController extends CRUDController
|
||||
{
|
||||
public function __construct(private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {}
|
||||
|
||||
protected function generateRedirectOnCreateRoute($action, Request $request, $entity): string
|
||||
{
|
||||
throw new \BadMethodCallException('Not implemented yet.');
|
||||
@@ -31,7 +33,7 @@ class OneToOneEntityPersonCRUDController extends CRUDController
|
||||
|
||||
if (null === $entity) {
|
||||
$entity = $this->createEntity($action, $request);
|
||||
$person = $this->getDoctrine()
|
||||
$person = $this->managerRegistry
|
||||
->getManager()
|
||||
->getRepository(Person::class)
|
||||
->find($id);
|
||||
@@ -58,7 +60,7 @@ class OneToOneEntityPersonCRUDController extends CRUDController
|
||||
|
||||
protected function onPostFetchEntity($action, Request $request, $entity): ?Response
|
||||
{
|
||||
if (false === $this->getDoctrine()->getManager()->contains($entity)) {
|
||||
if (false === $this->managerRegistry->getManager()->contains($entity)) {
|
||||
return new RedirectResponse($this->generateRedirectOnCreateRoute($action, $request, $entity));
|
||||
}
|
||||
|
||||
@@ -67,6 +69,6 @@ class OneToOneEntityPersonCRUDController extends CRUDController
|
||||
|
||||
protected function onPreFlush(string $action, $entity, FormInterface $form, Request $request)
|
||||
{
|
||||
$this->getDoctrine()->getManager()->persist($entity);
|
||||
$this->managerRegistry->getManager()->persist($entity);
|
||||
}
|
||||
}
|
||||
|
@@ -23,6 +23,8 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
final class ChillPersonMoveCommand extends Command
|
||||
{
|
||||
protected static $defaultDescription = 'Move all the associated entities on a "from" person to a "to" person and remove the old person';
|
||||
|
||||
public function __construct(
|
||||
private readonly PersonMove $mover,
|
||||
private readonly EntityManagerInterface $em,
|
||||
@@ -53,7 +55,6 @@ final class ChillPersonMoveCommand extends Command
|
||||
{
|
||||
$this
|
||||
->setName('chill:person:move')
|
||||
->setDescription('Move all the associated entities on a "from" person to a "to" person and remove the old person')
|
||||
->addOption('from', 'f', InputOption::VALUE_REQUIRED, 'The person id to delete, all associated data will be moved before')
|
||||
->addOption('to', 't', InputOption::VALUE_REQUIRED, 'The person id which will received data')
|
||||
->addOption('dump-sql', null, InputOption::VALUE_NONE, 'dump sql to stdout')
|
||||
@@ -99,7 +100,7 @@ final class ChillPersonMoveCommand extends Command
|
||||
$this->chillLogger->notice('Move a person from command line succeeded', $ctxt);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
protected function interact(InputInterface $input, OutputInterface $output)
|
||||
|
@@ -41,7 +41,6 @@ final class ImportSocialWorkMetadata extends Command
|
||||
->setName('chill:person:import-socialwork')
|
||||
->addOption('filepath', 'f', InputOption::VALUE_REQUIRED, 'The file to import.')
|
||||
->addOption('language', 'l', InputOption::VALUE_OPTIONAL, 'The default language')
|
||||
->setDescription($description)
|
||||
->setHelp($help);
|
||||
}
|
||||
|
||||
|
@@ -20,6 +20,8 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class RemoveOldDraftAccompanyingPeriodCommand extends Command
|
||||
{
|
||||
protected static $defaultDescription = 'Remove draft accompanying period which are still draft and unused';
|
||||
|
||||
public function __construct(private readonly LoggerInterface $logger, private readonly OldDraftAccompanyingPeriodRemoverInterface $remover)
|
||||
{
|
||||
parent::__construct('chill:person:remove-old-draft-period');
|
||||
@@ -28,7 +30,6 @@ class RemoveOldDraftAccompanyingPeriodCommand extends Command
|
||||
protected function configure(): void
|
||||
{
|
||||
$this
|
||||
->setDescription('Remove draft accompanying period which are still draft and unused')
|
||||
->addArgument('interval', InputArgument::OPTIONAL, 'The interval for unactive periods', 'P15D');
|
||||
}
|
||||
|
||||
@@ -50,6 +51,6 @@ class RemoveOldDraftAccompanyingPeriodCommand extends Command
|
||||
|
||||
$this->logger->info('['.$this->getName().'] end of command');
|
||||
|
||||
return 0;
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@@ -24,8 +24,7 @@ class ConfigPersonAltNamesHelper
|
||||
* the raw config, directly from the container parameter.
|
||||
*/
|
||||
private $config,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
/**
|
||||
* get the choices as key => values.
|
||||
|
@@ -46,9 +46,7 @@ use Symfony\Component\Workflow\Registry;
|
||||
|
||||
final class AccompanyingCourseApiController extends ApiController
|
||||
{
|
||||
public function __construct(private readonly AccompanyingPeriodRepository $accompanyingPeriodRepository, private readonly AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository, private readonly EventDispatcherInterface $eventDispatcher, private readonly ReferralsSuggestionInterface $referralAvailable, private readonly Registry $registry, private readonly ValidatorInterface $validator)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly AccompanyingPeriodRepository $accompanyingPeriodRepository, private readonly AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository, private readonly EventDispatcherInterface $eventDispatcher, private readonly ReferralsSuggestionInterface $referralAvailable, private readonly Registry $registry, private readonly ValidatorInterface $validator, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {}
|
||||
|
||||
public function commentApi($id, Request $request, string $_format): Response
|
||||
{
|
||||
@@ -74,16 +72,14 @@ final class AccompanyingCourseApiController extends ApiController
|
||||
|
||||
$workflow->apply($accompanyingPeriod, 'confirm');
|
||||
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
$this->managerRegistry->getManager()->flush();
|
||||
|
||||
return $this->json($accompanyingPeriod, Response::HTTP_OK, [], [
|
||||
'groups' => ['read'],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/api/1.0/person/accompanying-course/list/by-recent-attributions")
|
||||
*/
|
||||
#[Route(path: '/api/1.0/person/accompanying-course/list/by-recent-attributions')]
|
||||
public function findMyRecentCourseAttribution(Request $request): JsonResponse
|
||||
{
|
||||
$this->denyAccessUnlessGranted('ROLE_USER');
|
||||
@@ -174,7 +170,7 @@ final class AccompanyingCourseApiController extends ApiController
|
||||
return $this->json($errors, 422);
|
||||
}
|
||||
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
$this->managerRegistry->getManager()->flush();
|
||||
|
||||
return $this->json($participation, 200, [], ['groups' => ['read']]);
|
||||
}
|
||||
@@ -222,7 +218,7 @@ final class AccompanyingCourseApiController extends ApiController
|
||||
return $this->json($errors, 422);
|
||||
}
|
||||
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
$this->managerRegistry->getManager()->flush();
|
||||
|
||||
return $this->json($accompanyingPeriod->getRequestor(), 200, [], ['groups' => ['read']]);
|
||||
}
|
||||
@@ -249,11 +245,7 @@ final class AccompanyingCourseApiController extends ApiController
|
||||
return $this->addRemoveSomething('socialissue', $id, $request, $_format, 'socialIssue', SocialIssue::class, ['groups' => ['read']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/api/1.0/person/accompanying-course/{id}/referrers-suggested.{_format}",
|
||||
* requirements={ "_format": "json"},
|
||||
* name="chill_api_person_accompanying_period_referrers_suggested")
|
||||
*/
|
||||
#[Route(path: '/api/1.0/person/accompanying-course/{id}/referrers-suggested.{_format}', requirements: ['_format' => 'json'], name: 'chill_api_person_accompanying_period_referrers_suggested')]
|
||||
public function suggestReferrals(AccompanyingPeriod $period, string $_format = 'json'): JsonResponse
|
||||
{
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::EDIT, $period);
|
||||
@@ -280,10 +272,9 @@ final class AccompanyingCourseApiController extends ApiController
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/api/1.0/person/accompanying-course/{id}/confidential.json", name="chill_api_person_accompanying_period_confidential")
|
||||
*
|
||||
* @ParamConverter("accompanyingCourse", options={"id": "id"})
|
||||
*/
|
||||
#[Route(path: '/api/1.0/person/accompanying-course/{id}/confidential.json', name: 'chill_api_person_accompanying_period_confidential')]
|
||||
public function toggleConfidentialApi(AccompanyingPeriod $accompanyingCourse, mixed $id, Request $request)
|
||||
{
|
||||
if ('POST' === $request->getMethod()) {
|
||||
@@ -291,17 +282,16 @@ final class AccompanyingCourseApiController extends ApiController
|
||||
|
||||
$accompanyingCourse->setConfidential(!$accompanyingCourse->isConfidential());
|
||||
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
$this->managerRegistry->getManager()->flush();
|
||||
}
|
||||
|
||||
return $this->json($accompanyingCourse->isConfidential(), Response::HTTP_OK, [], ['groups' => ['read']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/api/1.0/person/accompanying-course/{id}/intensity.json", name="chill_api_person_accompanying_period_intensity")
|
||||
*
|
||||
* @ParamConverter("accompanyingCourse", options={"id": "id"})
|
||||
*/
|
||||
#[Route(path: '/api/1.0/person/accompanying-course/{id}/intensity.json', name: 'chill_api_person_accompanying_period_intensity')]
|
||||
public function toggleIntensityApi(AccompanyingPeriod $accompanyingCourse, Request $request)
|
||||
{
|
||||
if ('POST' === $request->getMethod()) {
|
||||
@@ -309,7 +299,7 @@ final class AccompanyingCourseApiController extends ApiController
|
||||
|
||||
$status = 'regular' === $accompanyingCourse->getIntensity() ? 'occasional' : 'regular';
|
||||
$accompanyingCourse->setIntensity($status);
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
$this->managerRegistry->getManager()->flush();
|
||||
}
|
||||
|
||||
return $this->json($accompanyingCourse->getIntensity(), Response::HTTP_OK, [], ['groups' => ['read']]);
|
||||
|
@@ -16,6 +16,7 @@ use Chill\PersonBundle\Form\AccompanyingCourseCommentType;
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodCommentVoter;
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||
@@ -30,22 +31,24 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class AccompanyingCourseCommentController extends AbstractController
|
||||
{
|
||||
public function __construct(private readonly EntityManagerInterface $entityManager, private readonly FormFactoryInterface $formFactory, private readonly TranslatorInterface $translator)
|
||||
{
|
||||
}
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly FormFactoryInterface $formFactory,
|
||||
private readonly TranslatorInterface $translator,
|
||||
private readonly ManagerRegistry $managerRegistry,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Page of comments in Accompanying Course section.
|
||||
*
|
||||
* @Route("/{_locale}/parcours/{accompanying_period_id}/comments", name="chill_person_accompanying_period_comment_list")
|
||||
*
|
||||
* @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
|
||||
*/
|
||||
#[Route(path: '/{_locale}/parcours/{accompanying_period_id}/comments', name: 'chill_person_accompanying_period_comment_list')]
|
||||
public function commentAction(AccompanyingPeriod $accompanyingCourse, Request $request): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::SEE_DETAILS, $accompanyingCourse);
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
$afterSuccessfulRedirectResponse = $this->redirectToRoute('chill_person_accompanying_period_comment_list', [
|
||||
'accompanying_period_id' => $accompanyingCourse->getId(),
|
||||
]);
|
||||
@@ -114,12 +117,8 @@ class AccompanyingCourseCommentController extends AbstractController
|
||||
|
||||
/**
|
||||
* Delete an existing comment.
|
||||
*
|
||||
* @Route(
|
||||
* "/{_locale}/parcours/comment/{id}/delete",
|
||||
* name="chill_person_accompanying_period_comment_delete"
|
||||
* )
|
||||
*/
|
||||
#[Route(path: '/{_locale}/parcours/comment/{id}/delete', name: 'chill_person_accompanying_period_comment_delete')]
|
||||
public function deleteAction(AccompanyingPeriod\Comment $comment, Request $request): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodCommentVoter::DELETE, $comment);
|
||||
@@ -155,16 +154,14 @@ class AccompanyingCourseCommentController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/parcours/comment/{id}/pin", name="chill_person_accompanying_period_comment_pin")
|
||||
*/
|
||||
#[Route(path: '/{_locale}/parcours/comment/{id}/pin', name: 'chill_person_accompanying_period_comment_pin')]
|
||||
public function pinComment(AccompanyingPeriod\Comment $comment): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::EDIT, $comment->getAccompanyingPeriod());
|
||||
|
||||
$comment->getAccompanyingPeriod()->setPinnedComment($comment);
|
||||
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
$this->managerRegistry->getManager()->flush();
|
||||
|
||||
$this->addFlash('success', $this->translator->trans('accompanying_course.comment is pinned'));
|
||||
|
||||
@@ -173,16 +170,14 @@ class AccompanyingCourseCommentController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/parcours/comment/{id}/unpin", name="chill_person_accompanying_period_comment_unpin")
|
||||
*/
|
||||
#[Route(path: '/{_locale}/parcours/comment/{id}/unpin', name: 'chill_person_accompanying_period_comment_unpin')]
|
||||
public function unpinComment(AccompanyingPeriod\Comment $comment): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::EDIT, $comment->getAccompanyingPeriod());
|
||||
|
||||
$comment->getAccompanyingPeriod()->setPinnedComment(null);
|
||||
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
$this->managerRegistry->getManager()->flush();
|
||||
|
||||
$this->addFlash('success', $this->translator->trans('accompanying_course.comment is unpinned'));
|
||||
|
||||
|
@@ -12,40 +12,46 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Controller;
|
||||
|
||||
use Chill\ActivityBundle\Entity\Activity;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Form\AccompanyingCourseType;
|
||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
|
||||
use Chill\PersonBundle\Repository\PersonRepository;
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Validator\ConstraintViolationInterface;
|
||||
use Symfony\Component\Validator\ConstraintViolationListInterface;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
use Symfony\Component\Workflow\Registry;
|
||||
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
* Class AccompanyingCourseController.
|
||||
*/
|
||||
class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Controller\AbstractController
|
||||
final class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Controller\AbstractController
|
||||
{
|
||||
public function __construct(protected SerializerInterface $serializer, protected EventDispatcherInterface $dispatcher, protected ValidatorInterface $validator, private readonly AccompanyingPeriodWorkRepository $workRepository, private readonly Registry $registry, private readonly TranslatorInterface $translator)
|
||||
{
|
||||
}
|
||||
public function __construct(
|
||||
private readonly ValidatorInterface $validator,
|
||||
private readonly AccompanyingPeriodWorkRepository $workRepository,
|
||||
private readonly Registry $registry,
|
||||
private readonly TranslatorInterface $translator,
|
||||
private readonly Security $security,
|
||||
private readonly PersonRepository $personRepository,
|
||||
private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/parcours/{accompanying_period_id}/close", name="chill_person_accompanying_course_close")
|
||||
*
|
||||
* @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
|
||||
*/
|
||||
#[Route(path: '/{_locale}/parcours/{accompanying_period_id}/close', name: 'chill_person_accompanying_course_close')]
|
||||
public function closeAction(AccompanyingPeriod $accompanyingCourse, Request $request): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::EDIT, $accompanyingCourse);
|
||||
@@ -57,7 +63,7 @@ class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Contr
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
|
||||
$workflow = $this->registry->get($accompanyingCourse);
|
||||
|
||||
@@ -89,13 +95,12 @@ class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Contr
|
||||
/**
|
||||
* Delete page of Accompanying Course section.
|
||||
*
|
||||
* @Route("/{_locale}/parcours/{accompanying_period_id}/delete", name="chill_person_accompanying_course_delete")
|
||||
*
|
||||
* @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
|
||||
*/
|
||||
#[Route(path: '/{_locale}/parcours/{accompanying_period_id}/delete', name: 'chill_person_accompanying_course_delete')]
|
||||
public function deleteAction(Request $request, AccompanyingPeriod $accompanyingCourse)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
|
||||
$person_id = $request->query->get('person_id');
|
||||
|
||||
@@ -104,11 +109,10 @@ class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Contr
|
||||
'accompanying_period_id' => $accompanyingCourse->getId(),
|
||||
'person_id' => $person_id,
|
||||
]))
|
||||
->setMethod('DELETE')
|
||||
->add('submit', SubmitType::class, ['label' => 'Delete'])
|
||||
->getForm();
|
||||
|
||||
if (Request::METHOD_DELETE === $request->getMethod()) {
|
||||
if (Request::METHOD_POST === $request->getMethod()) {
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isValid()) {
|
||||
@@ -146,10 +150,9 @@ class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Contr
|
||||
*
|
||||
* the page edit all blocks managed by vuejs component
|
||||
*
|
||||
* @Route("/{_locale}/parcours/{accompanying_period_id}/edit", name="chill_person_accompanying_course_edit")
|
||||
*
|
||||
* @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
|
||||
*/
|
||||
#[Route(path: '/{_locale}/parcours/{accompanying_period_id}/edit', name: 'chill_person_accompanying_course_edit')]
|
||||
public function editAction(AccompanyingPeriod $accompanyingCourse): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::EDIT, $accompanyingCourse);
|
||||
@@ -164,10 +167,9 @@ class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Contr
|
||||
*
|
||||
* the page show anti chronologic history with all actions, title of page is 'Accompanying Course History'
|
||||
*
|
||||
* @Route("/{_locale}/parcours/{accompanying_period_id}/history", name="chill_person_accompanying_course_history")
|
||||
*
|
||||
* @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
|
||||
*/
|
||||
#[Route(path: '/{_locale}/parcours/{accompanying_period_id}/history', name: 'chill_person_accompanying_course_history')]
|
||||
public function historyAction(AccompanyingPeriod $accompanyingCourse): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::SEE, $accompanyingCourse);
|
||||
@@ -180,10 +182,9 @@ class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Contr
|
||||
/**
|
||||
* Homepage of Accompanying Course section.
|
||||
*
|
||||
* @Route("/{_locale}/parcours/{accompanying_period_id}", name="chill_person_accompanying_course_index")
|
||||
*
|
||||
* @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
|
||||
*/
|
||||
#[Route(path: '/{_locale}/parcours/{accompanying_period_id}', name: 'chill_person_accompanying_course_index')]
|
||||
public function indexAction(AccompanyingPeriod $accompanyingCourse): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::SEE, $accompanyingCourse);
|
||||
@@ -198,7 +199,7 @@ class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Contr
|
||||
}
|
||||
}
|
||||
|
||||
$activities = $this->getDoctrine()->getManager()->getRepository(Activity::class)->findBy(
|
||||
$activities = $this->managerRegistry->getManager()->getRepository(Activity::class)->findBy(
|
||||
['accompanyingPeriod' => $accompanyingCourse],
|
||||
['date' => 'DESC', 'id' => 'DESC'],
|
||||
);
|
||||
@@ -220,31 +221,32 @@ class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Contr
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/person/parcours/new", name="chill_person_accompanying_course_new")
|
||||
*/
|
||||
#[Route(path: '/{_locale}/person/parcours/new', name: 'chill_person_accompanying_course_new')]
|
||||
public function newAction(Request $request): Response
|
||||
{
|
||||
$user = $this->security->getUser();
|
||||
|
||||
if (!$user instanceof User) {
|
||||
throw new AccessDeniedHttpException();
|
||||
}
|
||||
|
||||
$period = new AccompanyingPeriod();
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
|
||||
if ($request->query->has('person_id')) {
|
||||
$personIds = $request->query->get('person_id');
|
||||
$personIds = $request->query->all('person_id');
|
||||
|
||||
if (false === \is_array($personIds)) {
|
||||
throw new BadRequestHttpException('person_id parameter should be an array');
|
||||
}
|
||||
foreach ($personIds as $personId) {
|
||||
$person = $this->personRepository->find($personId);
|
||||
|
||||
foreach ($personIds as $personId) {
|
||||
$person = $em->getRepository(Person::class)->find($personId);
|
||||
|
||||
if (null !== $person) {
|
||||
$period->addPerson($person);
|
||||
if (null !== $person) {
|
||||
if (!$this->isGranted(PersonVoter::SEE, $person)) {
|
||||
throw new AccessDeniedHttpException(sprintf('person with id %d cannot be seen', $person->getId()));
|
||||
}
|
||||
$period->addPerson($person);
|
||||
}
|
||||
}
|
||||
|
||||
$userLocation = $this->getUser()->getCurrentLocation();
|
||||
$userLocation = $user->getCurrentLocation();
|
||||
$period->setAdministrativeLocation($userLocation);
|
||||
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::CREATE, $period);
|
||||
@@ -257,13 +259,17 @@ class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Contr
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/person/household/parcours/new", name="chill_household_accompanying_course_new")
|
||||
*/
|
||||
#[Route(path: '/{_locale}/person/household/parcours/new', name: 'chill_household_accompanying_course_new')]
|
||||
public function newHouseholdParcoursAction(Request $request): Response
|
||||
{
|
||||
$user = $this->getUser();
|
||||
|
||||
if (!$user instanceof User || !$this->security->isGranted('ROLE_USER')) {
|
||||
throw new AccessDeniedHttpException();
|
||||
}
|
||||
|
||||
$period = new AccompanyingPeriod();
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
|
||||
if ($request->query->has('household_id')) {
|
||||
$householdId = $request->query->get('household_id');
|
||||
@@ -278,8 +284,7 @@ class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Contr
|
||||
}
|
||||
}
|
||||
|
||||
$userLocation = $this->getUser()->getCurrentLocation();
|
||||
$period->setAdministrativeLocation($userLocation);
|
||||
$period->setAdministrativeLocation($user->getCurrentLocation());
|
||||
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::CREATE, $period);
|
||||
|
||||
@@ -292,10 +297,9 @@ class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Contr
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/parcours/{accompanying_period_id}/open", name="chill_person_accompanying_course_reopen")
|
||||
*
|
||||
* @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
|
||||
*/
|
||||
#[Route(path: '/{_locale}/parcours/{accompanying_period_id}/open', name: 'chill_person_accompanying_course_reopen')]
|
||||
public function reOpenAction(AccompanyingPeriod $accompanyingCourse, Request $request): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::SEE, $accompanyingCourse);
|
||||
@@ -309,7 +313,7 @@ class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle\Contr
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$accompanyingCourse->reOpen();
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
$this->managerRegistry->getManager()->flush();
|
||||
|
||||
return $this->redirectToRoute('chill_person_accompanying_course_index', [
|
||||
'accompanying_period_id' => $accompanyingCourse->getId(),
|
||||
|
@@ -12,30 +12,38 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Controller;
|
||||
|
||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Serializer\Model\Collection;
|
||||
use Chill\MainBundle\Serializer\Model\Counter;
|
||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
class AccompanyingCourseWorkApiController extends ApiController
|
||||
{
|
||||
public function __construct(private readonly AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository)
|
||||
{
|
||||
}
|
||||
public function __construct(
|
||||
private readonly AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository,
|
||||
private readonly Security $security,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @Route("/api/1.0/person/accompanying-period/work/my-near-end")
|
||||
*/
|
||||
#[Route(path: '/api/1.0/person/accompanying-period/work/my-near-end')]
|
||||
public function myWorksNearEndDate(Request $request): JsonResponse
|
||||
{
|
||||
$user = $this->security->getUser();
|
||||
|
||||
if (!$user instanceof User) {
|
||||
throw new AccessDeniedHttpException();
|
||||
}
|
||||
|
||||
$since = (new \DateTimeImmutable('now'))
|
||||
->sub(new \DateInterval('P'.$request->query->getInt('since', 15).'D'));
|
||||
$until = (new \DateTimeImmutable('now'))
|
||||
->add(new \DateInterval('P'.$request->query->getInt('since', 15).'D'));
|
||||
$total = $this->accompanyingPeriodWorkRepository
|
||||
->countNearEndDateByUser($this->getUser(), $since, $until);
|
||||
->countNearEndDateByUser($user, $since, $until);
|
||||
|
||||
if ($request->query->getBoolean('countOnly', false)) {
|
||||
return $this->json(
|
||||
@@ -48,7 +56,7 @@ class AccompanyingCourseWorkApiController extends ApiController
|
||||
|
||||
$paginator = $this->getPaginatorFactory()->create($total);
|
||||
$works = $this->accompanyingPeriodWorkRepository
|
||||
->findNearEndDateByUser($this->getUser(), $since, $until, $paginator->getItemsPerPage(), $paginator->getCurrentPageFirstItemNumber());
|
||||
->findNearEndDateByUser($user, $since, $until, $paginator->getItemsPerPage(), $paginator->getCurrentPageFirstItemNumber());
|
||||
|
||||
$collection = new Collection($works, $paginator);
|
||||
|
||||
|
@@ -18,7 +18,6 @@ use Chill\MainBundle\Templating\Listing\FilterOrderHelperFactoryInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodWorkVoter;
|
||||
@@ -42,16 +41,10 @@ final class AccompanyingCourseWorkController extends AbstractController
|
||||
private readonly LoggerInterface $chillLogger,
|
||||
private readonly TranslatableStringHelperInterface $translatableStringHelper,
|
||||
private readonly FilterOrderHelperFactoryInterface $filterOrderHelperFactory,
|
||||
) {
|
||||
}
|
||||
private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @Route(
|
||||
* "{_locale}/person/accompanying-period/{id}/work/new",
|
||||
* name="chill_person_accompanying_period_work_new",
|
||||
* methods={"GET"}
|
||||
* )
|
||||
*/
|
||||
#[Route(path: '{_locale}/person/accompanying-period/{id}/work/new', name: 'chill_person_accompanying_period_work_new', methods: ['GET'])]
|
||||
public function createWork(AccompanyingPeriod $period): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodWorkVoter::CREATE, $period);
|
||||
@@ -78,25 +71,19 @@ final class AccompanyingCourseWorkController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(
|
||||
* "{_locale}/person/accompanying-period/work/{id}/delete",
|
||||
* name="chill_person_accompanying_period_work_delete",
|
||||
* methods={"GET", "POST", "DELETE"}
|
||||
* )
|
||||
*/
|
||||
#[Route(path: '{_locale}/person/accompanying-period/work/{id}/delete', name: 'chill_person_accompanying_period_work_delete', methods: ['GET', 'POST', 'DELETE'])]
|
||||
public function deleteWork(AccompanyingPeriodWork $work, Request $request): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodWorkVoter::UPDATE, $work);
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
|
||||
$form = $this->createDeleteForm($work->getId());
|
||||
|
||||
if (Request::METHOD_DELETE === $request->getMethod()) {
|
||||
if (Request::METHOD_POST === $request->getMethod()) {
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isValid()) {
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->chillLogger->notice('An accompanying period work has been removed', [
|
||||
'by_user' => $this->getUser()->getUsername(),
|
||||
'work_id' => $work->getId(),
|
||||
@@ -124,13 +111,7 @@ final class AccompanyingCourseWorkController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(
|
||||
* "{_locale}/person/accompanying-period/work/{id}/edit",
|
||||
* name="chill_person_accompanying_period_work_edit",
|
||||
* methods={"GET"}
|
||||
* )
|
||||
*/
|
||||
#[Route(path: '{_locale}/person/accompanying-period/work/{id}/edit', name: 'chill_person_accompanying_period_work_edit', methods: ['GET'])]
|
||||
public function editWork(AccompanyingPeriodWork $work): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodWorkVoter::UPDATE, $work);
|
||||
@@ -144,13 +125,7 @@ final class AccompanyingCourseWorkController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(
|
||||
* "{_locale}/person/accompanying-period/{id}/work",
|
||||
* name="chill_person_accompanying_period_work_list",
|
||||
* methods={"GET"}
|
||||
* )
|
||||
*/
|
||||
#[Route(path: '{_locale}/person/accompanying-period/{id}/work', name: 'chill_person_accompanying_period_work_list', methods: ['GET'])]
|
||||
public function listWorkByAccompanyingPeriod(AccompanyingPeriod $period): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodWorkVoter::SEE, $period);
|
||||
@@ -182,13 +157,7 @@ final class AccompanyingCourseWorkController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(
|
||||
* "{_locale}/person/accompanying-period/work/{id}/show",
|
||||
* name="chill_person_accompanying_period_work_show",
|
||||
* methods={"GET"}
|
||||
* )
|
||||
*/
|
||||
#[Route(path: '{_locale}/person/accompanying-period/work/{id}/show', name: 'chill_person_accompanying_period_work_show', methods: ['GET'])]
|
||||
public function showWork(AccompanyingPeriodWork $work): Response
|
||||
{
|
||||
if (null === $work) {
|
||||
@@ -210,7 +179,6 @@ final class AccompanyingCourseWorkController extends AbstractController
|
||||
|
||||
return $this->createFormBuilder()
|
||||
->setAction($this->generateUrl('chill_person_accompanying_period_work_delete', $params))
|
||||
->setMethod('DELETE')
|
||||
->add('submit', SubmitType::class, ['label' => 'Delete'])
|
||||
->getForm();
|
||||
}
|
||||
|
@@ -20,17 +20,9 @@ use Symfony\Component\Security\Core\Security;
|
||||
|
||||
class AccompanyingCourseWorkEvaluationDocumentController extends AbstractController
|
||||
{
|
||||
public function __construct(private readonly Security $security)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly Security $security) {}
|
||||
|
||||
/**
|
||||
* @Route(
|
||||
* "{_locale}/person/accompanying-period/work/evaluation/document/{id}/show",
|
||||
* name="chill_person_accompanying_period_work_evaluation_document_show",
|
||||
* methods={"GET"}
|
||||
* )
|
||||
*/
|
||||
#[Route(path: '{_locale}/person/accompanying-period/work/evaluation/document/{id}/show', name: 'chill_person_accompanying_period_work_evaluation_document_show', methods: ['GET'])]
|
||||
public function showAccompanyingCourseWork(AccompanyingPeriodWorkEvaluationDocument $document): Response
|
||||
{
|
||||
$work = $document->getAccompanyingPeriodWorkEvaluation()->getAccompanyingPeriodWork();
|
||||
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Controller;
|
||||
|
||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||
|
||||
class AccompanyingPeriodCommentApiController extends ApiController {}
|
@@ -39,14 +39,13 @@ class AccompanyingPeriodController extends AbstractController
|
||||
private readonly EventDispatcherInterface $eventDispatcher,
|
||||
private readonly ValidatorInterface $validator,
|
||||
private readonly TranslatorInterface $translator,
|
||||
) {
|
||||
}
|
||||
private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/accompanying-period/close", name="chill_person_accompanying_period_close")
|
||||
*/
|
||||
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/accompanying-period/close', name: 'chill_person_accompanying_period_close')]
|
||||
public function closeAction(int $person_id, Request $request): Response
|
||||
{
|
||||
$person = $this->_getPerson($person_id);
|
||||
@@ -87,7 +86,7 @@ class AccompanyingPeriodController extends AbstractController
|
||||
'%name%' => $person->__toString(),
|
||||
]));
|
||||
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
$this->managerRegistry->getManager()->flush();
|
||||
|
||||
return $this->redirectToRoute('chill_person_accompanying_period_list', [
|
||||
'person_id' => $person->getId(),
|
||||
@@ -123,9 +122,7 @@ class AccompanyingPeriodController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/accompanying-period/create", name="chill_person_accompanying_period_create")
|
||||
*/
|
||||
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/accompanying-period/create', name: 'chill_person_accompanying_period_create')]
|
||||
public function createAction(int $person_id, Request $request): Response
|
||||
{
|
||||
$person = $this->_getPerson($person_id);
|
||||
@@ -160,7 +157,7 @@ class AccompanyingPeriodController extends AbstractController
|
||||
$form->isValid(['Default', 'closed'])
|
||||
&& 0 === \count($errors)
|
||||
) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
$em->persist($accompanyingPeriod);
|
||||
$em->flush();
|
||||
$flashBag->add(
|
||||
@@ -190,10 +187,9 @@ class AccompanyingPeriodController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @ParamConverter("person", options={"id": "person_id"})
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/accompanying-period", name="chill_person_accompanying_period_list")
|
||||
* @ParamConverter("person", options={"id"="person_id"})
|
||||
*/
|
||||
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/accompanying-period', name: 'chill_person_accompanying_period_list')]
|
||||
public function listAction(Person $person): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::SEE, $person);
|
||||
@@ -218,9 +214,7 @@ class AccompanyingPeriodController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/accompanying-period/open", name="chill_person_accompanying_period_open")
|
||||
*/
|
||||
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/accompanying-period/open', name: 'chill_person_accompanying_period_open')]
|
||||
public function openAction(int $person_id, Request $request): Response
|
||||
{
|
||||
$person = $this->_getPerson($person_id);
|
||||
@@ -272,7 +266,7 @@ class AccompanyingPeriodController extends AbstractController
|
||||
['%name%' => $person->__toString()]
|
||||
));
|
||||
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
$this->managerRegistry->getManager()->flush();
|
||||
|
||||
return $this->redirectToRoute('chill_person_accompanying_period_list', [
|
||||
'person_id' => $person->getId(),
|
||||
@@ -303,9 +297,7 @@ class AccompanyingPeriodController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/accompanying-period/{period_id}/re-open", name="chill_person_accompanying_period_re_open")
|
||||
*/
|
||||
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/accompanying-period/{period_id}/re-open', name: 'chill_person_accompanying_period_re_open')]
|
||||
public function reOpenAction(int $person_id, int $period_id, Request $request): Response
|
||||
{
|
||||
/** @var Person $person */
|
||||
@@ -328,7 +320,7 @@ class AccompanyingPeriodController extends AbstractController
|
||||
|
||||
$this->_validatePerson($person);
|
||||
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
$this->managerRegistry->getManager()->flush();
|
||||
|
||||
$this->addFlash('success', $this->translator->trans(
|
||||
'The period has been re-opened'
|
||||
@@ -353,12 +345,11 @@ class AccompanyingPeriodController extends AbstractController
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/accompanying-period/{period_id}/update", name="chill_person_accompanying_period_update")
|
||||
*/
|
||||
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/accompanying-period/{period_id}/update', name: 'chill_person_accompanying_period_update')]
|
||||
public function updateAction(int $person_id, int $period_id, Request $request): Response
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
|
||||
/** @var AccompanyingPeriod $accompanyingPeriod */
|
||||
$accompanyingPeriod = $em->getRepository(AccompanyingPeriod::class)->find($period_id);
|
||||
@@ -431,7 +422,7 @@ class AccompanyingPeriodController extends AbstractController
|
||||
*/
|
||||
private function _getPerson(int $id): Person
|
||||
{
|
||||
$person = $this->getDoctrine()->getManager()
|
||||
$person = $this->managerRegistry->getManager()
|
||||
->getRepository(Person::class)->find($id);
|
||||
|
||||
if (null === $person) {
|
||||
|
@@ -31,13 +31,9 @@ use Symfony\Component\Security\Core\Security;
|
||||
|
||||
class AccompanyingPeriodRegulationListController
|
||||
{
|
||||
public function __construct(private readonly AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, private readonly \Twig\Environment $engine, private readonly FormFactoryInterface $formFactory, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly TranslatableStringHelperInterface $translatableStringHelper)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, private readonly \Twig\Environment $engine, private readonly FormFactoryInterface $formFactory, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly TranslatableStringHelperInterface $translatableStringHelper) {}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/person/periods/undispatched", name="chill_person_course_list_regulation")
|
||||
*/
|
||||
#[Route(path: '/{_locale}/person/periods/undispatched', name: 'chill_person_course_list_regulation')]
|
||||
public function listRegul(Request $request): Response
|
||||
{
|
||||
if (!$this->security->isGranted('ROLE_USER') || !$this->security->getUser() instanceof User) {
|
||||
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Controller;
|
||||
|
||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||
|
||||
class AccompanyingPeriodResourceApiController extends ApiController {}
|
@@ -29,14 +29,9 @@ use Symfony\Component\Serializer\SerializerInterface;
|
||||
|
||||
class AccompanyingPeriodWorkEvaluationApiController
|
||||
{
|
||||
public function __construct(private readonly AccompanyingPeriodWorkEvaluationRepository $accompanyingPeriodWorkEvaluationRepository, private readonly DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private readonly SerializerInterface $serializer, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly AccompanyingPeriodWorkEvaluationRepository $accompanyingPeriodWorkEvaluationRepository, private readonly DocGeneratorTemplateRepository $docGeneratorTemplateRepository, private readonly SerializerInterface $serializer, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security) {}
|
||||
|
||||
/**
|
||||
* @Route("/api/1.0/person/docgen/template/by-evaluation/{id}.{_format}",
|
||||
* requirements={"format": "json"})
|
||||
*/
|
||||
#[Route(path: '/api/1.0/person/docgen/template/by-evaluation/{id}.{_format}', requirements: ['format' => 'json'])]
|
||||
public function listTemplateByEvaluation(Evaluation $evaluation, string $_format): JsonResponse
|
||||
{
|
||||
if ('json' !== $_format) {
|
||||
@@ -66,9 +61,7 @@ class AccompanyingPeriodWorkEvaluationApiController
|
||||
), JsonResponse::HTTP_OK, [], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/api/1.0/person/accompanying-period/work/evaluation/my-near-end")
|
||||
*/
|
||||
#[Route(path: '/api/1.0/person/accompanying-period/work/evaluation/my-near-end')]
|
||||
public function myWorksNearEndDate(Request $request): JsonResponse
|
||||
{
|
||||
$total = $this->accompanyingPeriodWorkEvaluationRepository
|
||||
|
@@ -19,33 +19,25 @@ use Symfony\Component\Routing\Annotation\Route;
|
||||
*/
|
||||
class AdminController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @Route("/{_locale}/admin/accompanying-course", name="chill_accompanying-course_admin_index")
|
||||
*/
|
||||
#[Route(path: '/{_locale}/admin/accompanying-course', name: 'chill_accompanying-course_admin_index')]
|
||||
public function indexAccompanyingCourseAdminAction()
|
||||
{
|
||||
return $this->render('@ChillPerson/Admin/indexAccompanyingCourse.html.twig');
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/admin/household", name="chill_household_admin_index")
|
||||
*/
|
||||
#[Route(path: '/{_locale}/admin/household', name: 'chill_household_admin_index')]
|
||||
public function indexHouseholdAdminAction()
|
||||
{
|
||||
return $this->render('@ChillPerson/Admin/indexHousehold.html.twig');
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/admin/person", name="chill_person_admin_index")
|
||||
*/
|
||||
#[Route(path: '/{_locale}/admin/person', name: 'chill_person_admin_index')]
|
||||
public function indexPersonAdminAction()
|
||||
{
|
||||
return $this->render('@ChillPerson/Admin/indexPerson.html.twig');
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/admin/social-work", name="chill_social-work_admin_index")
|
||||
*/
|
||||
#[Route(path: '/{_locale}/admin/social-work', name: 'chill_social-work_admin_index')]
|
||||
public function indexSocialWorkAdminAction()
|
||||
{
|
||||
return $this->render('@ChillPerson/Admin/indexSocialWork.html.twig');
|
||||
@@ -53,9 +45,8 @@ class AdminController extends AbstractController
|
||||
|
||||
/**
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/admin/person_redirect_to_main", name="chill_person_admin_redirect_to_admin_index", options={null})
|
||||
*/
|
||||
#[Route(path: '/{_locale}/admin/person_redirect_to_main', name: 'chill_person_admin_redirect_to_admin_index', options: [null])]
|
||||
public function redirectToAdminIndexAction()
|
||||
{
|
||||
return $this->redirectToRoute('chill_main_admin_central');
|
||||
|
@@ -21,6 +21,8 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
*/
|
||||
class ClosingMotiveController extends CRUDController
|
||||
{
|
||||
public function __construct(private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {}
|
||||
|
||||
/**
|
||||
* @param string $action
|
||||
*/
|
||||
@@ -31,7 +33,7 @@ class ClosingMotiveController extends CRUDController
|
||||
if ($request->query->has('parent_id')) {
|
||||
$parentId = $request->query->getInt('parent_id');
|
||||
|
||||
$parent = $this->getDoctrine()->getManager()
|
||||
$parent = $this->managerRegistry->getManager()
|
||||
->getRepository($this->getEntityClass())
|
||||
->find($parentId);
|
||||
|
||||
|
@@ -31,16 +31,12 @@ use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
class HouseholdApiController extends ApiController
|
||||
{
|
||||
public function __construct(private readonly EventDispatcherInterface $eventDispatcher, private readonly HouseholdRepository $householdRepository, private readonly HouseholdACLAwareRepositoryInterface $householdACLAwareRepository)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly EventDispatcherInterface $eventDispatcher, private readonly HouseholdRepository $householdRepository, private readonly HouseholdACLAwareRepositoryInterface $householdACLAwareRepository, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {}
|
||||
|
||||
/**
|
||||
* @Route("/api/1.0/person/household/by-address-reference/{id}.json",
|
||||
* name="chill_api_person_household_by_address_reference")
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\JsonResponse
|
||||
*/
|
||||
#[Route(path: '/api/1.0/person/household/by-address-reference/{id}.json', name: 'chill_api_person_household_by_address_reference')]
|
||||
public function getHouseholdByAddressReference(AddressReference $addressReference): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted('ROLE_USER');
|
||||
@@ -61,10 +57,8 @@ class HouseholdApiController extends ApiController
|
||||
|
||||
/**
|
||||
* Add an address to a household.
|
||||
*
|
||||
* @Route("/api/1.0/person/household/{id}/address.{_format}", name="chill_api_single_household_address",
|
||||
* methods={"POST"}, requirements={"_format": "json"})
|
||||
*/
|
||||
#[Route(path: '/api/1.0/person/household/{id}/address.{_format}', name: 'chill_api_single_household_address', methods: ['POST'], requirements: ['_format' => 'json'])]
|
||||
public function householdAddressApi(Household $household, Request $request, string $_format): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(HouseholdVoter::EDIT, $household);
|
||||
@@ -95,7 +89,7 @@ class HouseholdApiController extends ApiController
|
||||
return $this->json($errors, 422);
|
||||
}
|
||||
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
$this->managerRegistry->getManager()->flush();
|
||||
|
||||
return $this->json(
|
||||
$address,
|
||||
@@ -106,15 +100,9 @@ class HouseholdApiController extends ApiController
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/api/1.0/person/address/suggest/by-household/{household_id}.{_format}",
|
||||
* name="chill_person_address_suggest_by_household",
|
||||
* requirements={
|
||||
* "_format": "json"
|
||||
* }
|
||||
* )
|
||||
*
|
||||
* @ParamConverter("household", options={"id": "household_id"})
|
||||
*/
|
||||
#[Route(path: '/api/1.0/person/address/suggest/by-household/{household_id}.{_format}', name: 'chill_person_address_suggest_by_household', requirements: ['_format' => 'json'])]
|
||||
public function suggestAddressByHousehold(Household $household, string $_format)
|
||||
{
|
||||
// TODO add acl
|
||||
|
@@ -44,12 +44,9 @@ class HouseholdCompositionController extends AbstractController
|
||||
private readonly TranslatorInterface $translator,
|
||||
private readonly \Twig\Environment $engine,
|
||||
private readonly UrlGeneratorInterface $urlGenerator,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/person/household/{household_id}/composition/{composition_id}/delete", name="chill_person_household_composition_delete")
|
||||
*/
|
||||
#[Route(path: '/{_locale}/person/household/{household_id}/composition/{composition_id}/delete', name: 'chill_person_household_composition_delete')]
|
||||
public function deleteAction(Request $request, mixed $household_id, mixed $composition_id): Response
|
||||
{
|
||||
$composition = $this->householdCompositionRepository->find($composition_id);
|
||||
@@ -66,11 +63,10 @@ class HouseholdCompositionController extends AbstractController
|
||||
'composition_id' => $composition_id,
|
||||
'household_id' => $household_id,
|
||||
]))
|
||||
->setMethod('DELETE')
|
||||
->add('submit', SubmitType::class, ['label' => 'Delete'])
|
||||
->getForm();
|
||||
|
||||
if (Request::METHOD_DELETE === $request->getMethod()) {
|
||||
if (Request::METHOD_POST === $request->getMethod()) {
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isValid()) {
|
||||
@@ -96,9 +92,7 @@ class HouseholdCompositionController extends AbstractController
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/person/household/{id}/composition/index", name="chill_person_household_composition_index")
|
||||
*/
|
||||
#[Route(path: '/{_locale}/person/household/{id}/composition/index', name: 'chill_person_household_composition_index')]
|
||||
public function index(Household $household, Request $request): Response
|
||||
{
|
||||
if (!$this->security->isGranted(HouseholdVoter::SEE, $household)) {
|
||||
@@ -123,9 +117,7 @@ class HouseholdCompositionController extends AbstractController
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/person/household/{id}/composition/new", name="chill_person_household_composition_new")
|
||||
*/
|
||||
#[Route(path: '/{_locale}/person/household/{id}/composition/new', name: 'chill_person_household_composition_new')]
|
||||
public function newAction(Household $household, Request $request): Response
|
||||
{
|
||||
if ($this->security->isGranted(HouseholdVoter::EDIT, $household)) {
|
||||
|
@@ -29,24 +29,15 @@ use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/person/household")
|
||||
*/
|
||||
#[Route(path: '/{_locale}/person/household')]
|
||||
class HouseholdController extends AbstractController
|
||||
{
|
||||
public function __construct(private readonly TranslatorInterface $translator, private readonly PositionRepository $positionRepository, private readonly SerializerInterface $serializer, private readonly Security $security)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly TranslatorInterface $translator, private readonly PositionRepository $positionRepository, private readonly SerializerInterface $serializer, private readonly Security $security, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {}
|
||||
|
||||
/**
|
||||
* @Route(
|
||||
* "/{household_id}/accompanying-period",
|
||||
* name="chill_person_household_accompanying_period",
|
||||
* methods={"GET", "HEAD"}
|
||||
* )
|
||||
*
|
||||
* @ParamConverter("household", options={"id": "household_id"})
|
||||
*/
|
||||
#[Route(path: '/{household_id}/accompanying-period', name: 'chill_person_household_accompanying_period', methods: ['GET', 'HEAD'])]
|
||||
public function accompanyingPeriod(Request $request, Household $household)
|
||||
{
|
||||
$currentMembers = $household->getCurrentPersons();
|
||||
@@ -94,20 +85,15 @@ class HouseholdController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(
|
||||
* "/{household_id}/address/edit",
|
||||
* name="chill_person_household_address_edit",
|
||||
* methods={"GET", "HEAD", "POST"}
|
||||
* )
|
||||
*
|
||||
* @ParamConverter("household", options={"id": "household_id"})
|
||||
*/
|
||||
#[Route(path: '/{household_id}/address/edit', name: 'chill_person_household_address_edit', methods: ['GET', 'HEAD', 'POST'])]
|
||||
public function addressEdit(Request $request, Household $household)
|
||||
{
|
||||
// TODO ACL
|
||||
|
||||
$address_id = $request->query->get('address_id');
|
||||
$address = $this->getDoctrine()->getManager()
|
||||
$address = $this->managerRegistry->getManager()
|
||||
->getRepository(Address::class)
|
||||
->find($address_id);
|
||||
|
||||
@@ -121,14 +107,9 @@ class HouseholdController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(
|
||||
* "/{household_id}/addresses",
|
||||
* name="chill_person_household_addresses",
|
||||
* methods={"GET", "HEAD"}
|
||||
* )
|
||||
*
|
||||
* @ParamConverter("household", options={"id": "household_id"})
|
||||
*/
|
||||
#[Route(path: '/{household_id}/addresses', name: 'chill_person_household_addresses', methods: ['GET', 'HEAD'])]
|
||||
public function addresses(Request $request, Household $household)
|
||||
{
|
||||
// TODO ACL
|
||||
@@ -152,14 +133,9 @@ class HouseholdController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(
|
||||
* "/{household_id}/address/move",
|
||||
* name="chill_person_household_address_move",
|
||||
* methods={"GET", "HEAD", "POST"}
|
||||
* )
|
||||
*
|
||||
* @ParamConverter("household", options={"id": "household_id"})
|
||||
*/
|
||||
#[Route(path: '/{household_id}/address/move', name: 'chill_person_household_address_move', methods: ['GET', 'HEAD', 'POST'])]
|
||||
public function addressMove(Request $request, Household $household)
|
||||
{
|
||||
// TODO ACL
|
||||
@@ -173,14 +149,9 @@ class HouseholdController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(
|
||||
* "/{household_id}/address/edit_valid_from",
|
||||
* name="chill_person_household_address_valid_from_edit",
|
||||
* methods={"GET", "HEAD", "POST"}
|
||||
* )
|
||||
*
|
||||
* @ParamConverter("household", options={"id": "household_id"})
|
||||
*/
|
||||
#[Route(path: '/{household_id}/address/edit_valid_from', name: 'chill_person_household_address_valid_from_edit', methods: ['GET', 'HEAD', 'POST'])]
|
||||
public function addressValidFromEdit(Request $request, Household $household)
|
||||
{
|
||||
$this->denyAccessUnlessGranted(HouseholdVoter::EDIT, $household);
|
||||
@@ -212,7 +183,7 @@ class HouseholdController extends AbstractController
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$household->makeAddressConsistent();
|
||||
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
$this->managerRegistry->getManager()->flush();
|
||||
|
||||
return $this->redirectToRoute('chill_person_household_addresses', [
|
||||
'household_id' => $household->getId(),
|
||||
@@ -230,14 +201,9 @@ class HouseholdController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(
|
||||
* "/{household_id}/members/metadata/edit",
|
||||
* name="chill_person_household_members_metadata_edit",
|
||||
* methods={"GET", "POST"}
|
||||
* )
|
||||
*
|
||||
* @ParamConverter("household", options={"id": "household_id"})
|
||||
*/
|
||||
#[Route(path: '/{household_id}/members/metadata/edit', name: 'chill_person_household_members_metadata_edit', methods: ['GET', 'POST'])]
|
||||
public function editHouseholdMetadata(Request $request, Household $household)
|
||||
{
|
||||
// TODO ACL
|
||||
@@ -246,7 +212,7 @@ class HouseholdController extends AbstractController
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
$this->managerRegistry->getManager()->flush();
|
||||
|
||||
$this->addFlash('success', $this->translator->trans('household.data_saved'));
|
||||
|
||||
@@ -254,6 +220,12 @@ class HouseholdController extends AbstractController
|
||||
'household_id' => $household->getId(),
|
||||
]);
|
||||
}
|
||||
if ($form->isSubmitted() && !$form->isValid()) {
|
||||
$this->addFlash('error', $this->translator->trans('This form contains errors'));
|
||||
foreach ($form->getErrors() as $error) {
|
||||
$this->addFlash('error', $error->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('@ChillPerson/Household/edit_member_metadata.html.twig', [
|
||||
'household' => $household,
|
||||
@@ -262,14 +234,9 @@ class HouseholdController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(
|
||||
* "/{household_id}/relationship",
|
||||
* name="chill_person_household_relationship",
|
||||
* methods={"GET", "HEAD"}
|
||||
* )
|
||||
*
|
||||
* @ParamConverter("household", options={"id": "household_id"})
|
||||
*/
|
||||
#[Route(path: '/{household_id}/relationship', name: 'chill_person_household_relationship', methods: ['GET', 'HEAD'])]
|
||||
public function showRelationship(Request $request, Household $household)
|
||||
{
|
||||
$jsonString = $this->serializer->serialize(
|
||||
@@ -288,14 +255,9 @@ class HouseholdController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(
|
||||
* "/{household_id}/summary",
|
||||
* name="chill_person_household_summary",
|
||||
* methods={"GET", "HEAD"}
|
||||
* )
|
||||
*
|
||||
* @ParamConverter("household", options={"id": "household_id"})
|
||||
*/
|
||||
#[Route(path: '/{household_id}/summary', name: 'chill_person_household_summary', methods: ['GET', 'HEAD'])]
|
||||
public function summary(Request $request, Household $household)
|
||||
{
|
||||
// TODO ACL
|
||||
@@ -319,7 +281,7 @@ class HouseholdController extends AbstractController
|
||||
[
|
||||
'household' => $household,
|
||||
'positions' => $positions,
|
||||
'form' => null !== $form ? $form->createView() : null,
|
||||
'form' => $form?->createView(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@@ -14,32 +14,40 @@ namespace Chill\PersonBundle\Controller;
|
||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
||||
use Chill\PersonBundle\Entity\Household\Position;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Form\HouseholdMemberType;
|
||||
use Chill\PersonBundle\Household\MembersEditor;
|
||||
use Chill\PersonBundle\Repository\AccompanyingPeriodRepository;
|
||||
use Chill\PersonBundle\Repository\Household\HouseholdRepository;
|
||||
use Chill\PersonBundle\Repository\Household\PositionRepository;
|
||||
use Chill\PersonBundle\Repository\PersonRepository;
|
||||
use Chill\PersonBundle\Security\Authorization\HouseholdVoter;
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Serializer\Exception;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class HouseholdMemberController extends ApiController
|
||||
{
|
||||
public function __construct(private readonly UrlGeneratorInterface $generator, private readonly TranslatorInterface $translator, private readonly AccompanyingPeriodRepository $periodRepository)
|
||||
{
|
||||
}
|
||||
public function __construct(
|
||||
private readonly UrlGeneratorInterface $generator,
|
||||
private readonly TranslatorInterface $translator,
|
||||
private readonly AccompanyingPeriodRepository $periodRepository,
|
||||
private readonly PersonRepository $personRepository,
|
||||
private readonly HouseholdRepository $householdRepository,
|
||||
private readonly Security $security,
|
||||
private readonly PositionRepository $positionRepository,
|
||||
private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @Route(
|
||||
* "/{_locale}/person/household/member/{id}/edit",
|
||||
* name="chill_person_household_member_edit"
|
||||
* )
|
||||
*/
|
||||
#[Route(path: '/{_locale}/person/household/member/{id}/edit', name: 'chill_person_household_member_edit')]
|
||||
public function editMembership(Request $request, HouseholdMember $member): Response
|
||||
{
|
||||
// TODO ACL
|
||||
@@ -50,7 +58,7 @@ class HouseholdMemberController extends ApiController
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
$this->managerRegistry->getManager()->flush();
|
||||
|
||||
$this->addFlash('success', $this->translator
|
||||
->trans('household.successfully saved member'));
|
||||
@@ -77,51 +85,54 @@ class HouseholdMemberController extends ApiController
|
||||
* * household: the id of the destination household
|
||||
* * allow_leave_without_household: if present, the editor will allow
|
||||
* to leave household without joining another
|
||||
*
|
||||
* @Route(
|
||||
* "/{_locale}/person/household/members/editor",
|
||||
* name="chill_person_household_members_editor"
|
||||
* )
|
||||
*/
|
||||
#[Route(path: '/{_locale}/person/household/members/editor', name: 'chill_person_household_members_editor')]
|
||||
public function editor(Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$ids = $request->query->all('persons');
|
||||
|
||||
if ($request->query->has('persons')) {
|
||||
$ids = $request->query->get('persons', []);
|
||||
if ([] !== $ids) {
|
||||
$persons = [];
|
||||
|
||||
if (0 === \count($ids)) {
|
||||
throw new BadRequestHttpException('parameters persons in query is not an array or empty');
|
||||
}
|
||||
foreach ($ids as $id) {
|
||||
if (!is_numeric($id)) {
|
||||
throw new BadRequestHttpException(sprintf('persons with id %s is not numeric', $id));
|
||||
}
|
||||
|
||||
$persons = $em->getRepository(Person::class)
|
||||
->findById($ids);
|
||||
$person = $this->personRepository->find((int) $id);
|
||||
|
||||
if (null === $person) {
|
||||
throw new NotFoundHttpException(sprintf('person with id %d not found', $id));
|
||||
}
|
||||
|
||||
foreach ($persons as $person) {
|
||||
$this->denyAccessUnlessGranted(
|
||||
PersonVoter::SEE,
|
||||
$person,
|
||||
"You are not allowed to see person with id {$person->getId()}"
|
||||
);
|
||||
|
||||
$persons[] = $person;
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->query->has('household')) {
|
||||
$householdId = $request->query->get('household', false);
|
||||
$household = $em->getRepository(Household::class)
|
||||
$household = $this->householdRepository
|
||||
->find($householdId);
|
||||
$allowHouseholdCreate = false;
|
||||
$allowHouseholdSearch = false;
|
||||
$allowLeaveWithoutHousehold = false;
|
||||
|
||||
if (null === $household) {
|
||||
throw $this->createNotFoundException('household not found');
|
||||
throw new NotFoundHttpException('household not found');
|
||||
}
|
||||
|
||||
if (!$this->security->isGranted(HouseholdVoter::EDIT, $household)) {
|
||||
throw new AccessDeniedHttpException('not allowed to edit this household');
|
||||
}
|
||||
// TODO ACL on household
|
||||
}
|
||||
|
||||
$positions = $this->getDoctrine()->getManager()
|
||||
->getRepository(Position::class)
|
||||
$positions = $this->positionRepository
|
||||
->findAll();
|
||||
|
||||
$data = [
|
||||
@@ -142,10 +153,8 @@ class HouseholdMemberController extends ApiController
|
||||
);
|
||||
|
||||
if (null === $period) {
|
||||
throw $this->createNotFoundException('period not found');
|
||||
throw new NotFoundHttpException('accompanying period not found');
|
||||
}
|
||||
|
||||
// TODO add acl on accompanying Course
|
||||
}
|
||||
|
||||
return $this->render('@ChillPerson/Household/members_editor.html.twig', [
|
||||
@@ -155,12 +164,7 @@ class HouseholdMemberController extends ApiController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(
|
||||
* "/api/1.0/person/household/members/move.{_format}",
|
||||
* name="chill_api_person_household_members_move"
|
||||
* )
|
||||
*/
|
||||
#[Route(path: '/api/1.0/person/household/members/move.{_format}', name: 'chill_api_person_household_members_move')]
|
||||
public function move(Request $request, mixed $_format): Response
|
||||
{
|
||||
try {
|
||||
@@ -187,7 +191,7 @@ class HouseholdMemberController extends ApiController
|
||||
// launch events on post move
|
||||
$editor->postMove();
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
|
||||
// if new household, persist it
|
||||
if (
|
||||
|
@@ -29,16 +29,12 @@ class PersonAddressController extends AbstractController
|
||||
/**
|
||||
* PersonAddressController constructor.
|
||||
*/
|
||||
public function __construct(private readonly ValidatorInterface $validator, private readonly TranslatorInterface $translator)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly ValidatorInterface $validator, private readonly TranslatorInterface $translator, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {}
|
||||
|
||||
/**
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/address/create", name="chill_person_address_create", methods={"POST"})
|
||||
*/
|
||||
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/address/create', name: 'chill_person_address_create', methods: ['POST'])]
|
||||
public function createAction(mixed $person_id, Request $request)
|
||||
{
|
||||
$person = $this->getDoctrine()->getManager()
|
||||
$person = $this->managerRegistry->getManager()
|
||||
->getRepository(Person::class)
|
||||
->find($person_id);
|
||||
|
||||
@@ -67,7 +63,7 @@ class PersonAddressController extends AbstractController
|
||||
$this->addFlash('error', $error->getMessage());
|
||||
}
|
||||
} elseif ($form->isValid()) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
$em->flush();
|
||||
|
||||
$this->addFlash(
|
||||
@@ -90,12 +86,10 @@ class PersonAddressController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/address/{address_id}/edit", name="chill_person_address_edit")
|
||||
*/
|
||||
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/address/{address_id}/edit', name: 'chill_person_address_edit')]
|
||||
public function editAction(mixed $person_id, mixed $address_id)
|
||||
{
|
||||
$person = $this->getDoctrine()->getManager()
|
||||
$person = $this->managerRegistry->getManager()
|
||||
->getRepository(Person::class)
|
||||
->find($person_id);
|
||||
|
||||
@@ -120,12 +114,10 @@ class PersonAddressController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/address/list", name="chill_person_address_list")
|
||||
*/
|
||||
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/address/list', name: 'chill_person_address_list')]
|
||||
public function listAction(mixed $person_id)
|
||||
{
|
||||
$person = $this->getDoctrine()->getManager()
|
||||
$person = $this->managerRegistry->getManager()
|
||||
->getRepository(Person::class)
|
||||
->find($person_id);
|
||||
|
||||
@@ -144,12 +136,10 @@ class PersonAddressController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/address/new", name="chill_person_address_new")
|
||||
*/
|
||||
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/address/new', name: 'chill_person_address_new')]
|
||||
public function newAction(mixed $person_id)
|
||||
{
|
||||
$person = $this->getDoctrine()->getManager()
|
||||
$person = $this->managerRegistry->getManager()
|
||||
->getRepository(Person::class)
|
||||
->find($person_id);
|
||||
|
||||
@@ -173,12 +163,10 @@ class PersonAddressController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/address/{address_id}/update", name="chill_person_address_update")
|
||||
*/
|
||||
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/address/{address_id}/update', name: 'chill_person_address_update')]
|
||||
public function updateAction(mixed $person_id, mixed $address_id, Request $request)
|
||||
{
|
||||
$person = $this->getDoctrine()->getManager()
|
||||
$person = $this->managerRegistry->getManager()
|
||||
->getRepository(Person::class)
|
||||
->find($person_id);
|
||||
|
||||
@@ -205,7 +193,7 @@ class PersonAddressController extends AbstractController
|
||||
$this->addFlash('error', $error->getMessage());
|
||||
}
|
||||
} elseif ($form->isValid()) {
|
||||
$this->getDoctrine()->getManager()
|
||||
$this->managerRegistry->getManager()
|
||||
->flush();
|
||||
|
||||
$this->addFlash('success', $this->translator->trans(
|
||||
@@ -278,7 +266,7 @@ class PersonAddressController extends AbstractController
|
||||
*/
|
||||
protected function findAddressById(Person $person, $address_id)
|
||||
{
|
||||
$address = $this->getDoctrine()->getManager()
|
||||
$address = $this->managerRegistry->getManager()
|
||||
->getRepository(Address::class)
|
||||
->find($address_id);
|
||||
|
||||
|
@@ -36,11 +36,7 @@ class PersonApiController extends ApiController
|
||||
$this->showCenters = $parameterBag->get('chill_main')['acl']['form_show_centers'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/api/1.0/person/creation/authorized-centers",
|
||||
* name="chill_person_person_creation_authorized_centers"
|
||||
* )
|
||||
*/
|
||||
#[Route(path: '/api/1.0/person/creation/authorized-centers', name: 'chill_person_person_creation_authorized_centers')]
|
||||
public function authorizedCentersForCreation(): Response
|
||||
{
|
||||
$centers = $this->authorizedCenterOnPersonCreation->getCenters();
|
||||
@@ -53,14 +49,7 @@ class PersonApiController extends ApiController
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/api/1.0/person/config/alt_names.{_format}",
|
||||
* name="chill_person_config_alt_names",
|
||||
* requirements={
|
||||
* "_format": "json"
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
#[Route(path: '/api/1.0/person/config/alt_names.{_format}', name: 'chill_person_config_alt_names', requirements: ['_format' => 'json'])]
|
||||
public function configAltNames(Request $request, string $_format): Response
|
||||
{
|
||||
$configAltNamesChoices = $this->configPersonAltNameHelper->getChoices();
|
||||
@@ -83,15 +72,9 @@ class PersonApiController extends ApiController
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/api/1.0/person/address/suggest/by-person/{person_id}.{_format}",
|
||||
* name="chill_person_address_suggest_by_person",
|
||||
* requirements={
|
||||
* "_format": "json"
|
||||
* }
|
||||
* )
|
||||
*
|
||||
* @ParamConverter("person", options={"id": "person_id"})
|
||||
*/
|
||||
#[Route(path: '/api/1.0/person/address/suggest/by-person/{person_id}.{_format}', name: 'chill_person_address_suggest_by_person', requirements: ['_format' => 'json'])]
|
||||
public function suggestAddress(Person $person, Request $request, string $_format): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(PersonVoter::SEE, $person);
|
||||
|
@@ -47,12 +47,9 @@ final class PersonController extends AbstractController
|
||||
private readonly ConfigPersonAltNamesHelper $configPersonAltNameHelper,
|
||||
private readonly ValidatorInterface $validator,
|
||||
private readonly EntityManagerInterface $em,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/general/edit", name="chill_person_general_edit")
|
||||
*/
|
||||
#[Route(path: '/{_locale}/person/{person_id}/general/edit', name: 'chill_person_general_edit')]
|
||||
public function editAction(int $person_id, Request $request)
|
||||
{
|
||||
$person = $this->_getPerson($person_id);
|
||||
@@ -117,14 +114,9 @@ final class PersonController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(
|
||||
* "/{_locale}/person/household/{person_id}/history",
|
||||
* name="chill_person_household_person_history",
|
||||
* methods={"GET", "POST"}
|
||||
* )
|
||||
*
|
||||
* @ParamConverter("person", options={"id": "person_id"})
|
||||
*/
|
||||
#[Route(path: '/{_locale}/person/household/{person_id}/history', name: 'chill_person_household_person_history', methods: ['GET', 'POST'])]
|
||||
public function householdHistoryByPerson(Request $request, Person $person): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(
|
||||
@@ -147,14 +139,13 @@ final class PersonController extends AbstractController
|
||||
/**
|
||||
* Method for creating a new person.
|
||||
*
|
||||
*The controller register data from a previous post on the form, and
|
||||
* The controller register data from a previous post on the form, and
|
||||
* register it in the session.
|
||||
*
|
||||
* The next post compare the data with previous one and, if yes, show a
|
||||
* review page if there are "alternate persons".
|
||||
*
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/new", name="chill_person_new")
|
||||
*/
|
||||
#[Route(path: '/{_locale}/person/new', name: 'chill_person_new')]
|
||||
public function newAction(Request $request): Response
|
||||
{
|
||||
$person = new Person();
|
||||
@@ -249,9 +240,7 @@ final class PersonController extends AbstractController
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/general", name="chill_person_view")
|
||||
*/
|
||||
#[Route(path: '/{_locale}/person/{person_id}/general', name: 'chill_person_view')]
|
||||
public function viewAction(int $person_id)
|
||||
{
|
||||
$person = $this->_getPerson($person_id);
|
||||
|
@@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Controller;
|
||||
use Chill\ActivityBundle\Entity\Activity;
|
||||
use Chill\DocStoreBundle\Entity\PersonDocument;
|
||||
use Chill\EventBundle\Entity\Participation;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Actions\Remove\PersonMove;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\PersonNotDuplicate;
|
||||
@@ -24,25 +25,28 @@ use Chill\PersonBundle\Repository\PersonNotDuplicateRepository;
|
||||
use Chill\PersonBundle\Repository\PersonRepository;
|
||||
use Chill\PersonBundle\Search\SimilarPersonMatcher;
|
||||
use Chill\TaskBundle\Entity\SingleTask;
|
||||
use http\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use function count;
|
||||
|
||||
class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controller\AbstractController
|
||||
{
|
||||
public function __construct(private readonly SimilarPersonMatcher $similarPersonMatcher, private readonly TranslatorInterface $translator, private readonly PersonRepository $personRepository, private readonly PersonMove $personMove, private readonly EventDispatcherInterface $eventDispatcher)
|
||||
{
|
||||
}
|
||||
public function __construct(
|
||||
private readonly SimilarPersonMatcher $similarPersonMatcher,
|
||||
private readonly PersonRepository $personRepository,
|
||||
private readonly PersonMove $personMove,
|
||||
private readonly EventDispatcherInterface $eventDispatcher,
|
||||
private readonly Security $security,
|
||||
private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person1_id}/duplicate/{person2_id}/confirm", name="chill_person_duplicate_confirm")
|
||||
*/
|
||||
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person1_id}/duplicate/{person2_id}/confirm', name: 'chill_person_duplicate_confirm')]
|
||||
public function confirmAction(mixed $person1_id, mixed $person2_id, Request $request)
|
||||
{
|
||||
if ($person1_id === $person2_id) {
|
||||
throw new InvalidArgumentException('Can not merge same person');
|
||||
throw new \InvalidArgumentException('Can not merge same person');
|
||||
}
|
||||
|
||||
$person1 = $this->_getPerson($person1_id);
|
||||
@@ -79,7 +83,7 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll
|
||||
|
||||
$sqls = $this->personMove->getSQL($person2, $person1);
|
||||
|
||||
$connection = $this->getDoctrine()->getConnection();
|
||||
$connection = $this->managerRegistry->getConnection();
|
||||
|
||||
$connection->beginTransaction();
|
||||
|
||||
@@ -98,9 +102,7 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/find-manually", name="chill_person_find_manually_duplicate")
|
||||
*/
|
||||
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/find-manually', name: 'chill_person_find_manually_duplicate')]
|
||||
public function findManuallyDuplicateAction(mixed $person_id, Request $request)
|
||||
{
|
||||
$person = $this->_getPerson($person_id);
|
||||
@@ -149,11 +151,15 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person1_id}/duplicate/{person2_id}/not-duplicate", name="chill_person_duplicate_not_duplicate")
|
||||
*/
|
||||
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person1_id}/duplicate/{person2_id}/not-duplicate', name: 'chill_person_duplicate_not_duplicate')]
|
||||
public function notDuplicateAction(mixed $person1_id, mixed $person2_id)
|
||||
{
|
||||
$user = $this->security->getUser();
|
||||
|
||||
if (!$user instanceof User) {
|
||||
throw new AccessDeniedHttpException();
|
||||
}
|
||||
|
||||
[$person1, $person2] = $this->_getPersonsByPriority($person1_id, $person2_id);
|
||||
|
||||
$this->denyAccessUnlessGranted(
|
||||
@@ -162,25 +168,23 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll
|
||||
'You are not allowed to see this person.'
|
||||
);
|
||||
|
||||
$personNotDuplicate = $this->getDoctrine()->getRepository(PersonNotDuplicate::class)
|
||||
$personNotDuplicate = $this->managerRegistry->getRepository(PersonNotDuplicate::class)
|
||||
->findOneBy(['person1' => $person1, 'person2' => $person2]);
|
||||
|
||||
if (!$personNotDuplicate instanceof PersonNotDuplicate) {
|
||||
$personNotDuplicate = new PersonNotDuplicate();
|
||||
$personNotDuplicate->setPerson1($person1);
|
||||
$personNotDuplicate->setPerson2($person2);
|
||||
$personNotDuplicate->setUser($this->getUser());
|
||||
$personNotDuplicate->setUser($user);
|
||||
|
||||
$this->getDoctrine()->getManager()->persist($personNotDuplicate);
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
$this->managerRegistry->getManager()->persist($personNotDuplicate);
|
||||
$this->managerRegistry->getManager()->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('chill_person_duplicate_view', ['person_id' => $person1->getId()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person1_id}/duplicate/{person2_id}/remove-not-duplicate", name="chill_person_remove_duplicate_not_duplicate")
|
||||
*/
|
||||
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person1_id}/duplicate/{person2_id}/remove-not-duplicate', name: 'chill_person_remove_duplicate_not_duplicate')]
|
||||
public function removeNotDuplicateAction(mixed $person1_id, mixed $person2_id)
|
||||
{
|
||||
[$person1, $person2] = $this->_getPersonsByPriority($person1_id, $person2_id);
|
||||
@@ -191,20 +195,18 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll
|
||||
'You are not allowed to see this person.'
|
||||
);
|
||||
|
||||
$personNotDuplicate = $this->getDoctrine()->getRepository(PersonNotDuplicate::class)
|
||||
$personNotDuplicate = $this->managerRegistry->getRepository(PersonNotDuplicate::class)
|
||||
->findOneBy(['person1' => $person1, 'person2' => $person2]);
|
||||
|
||||
if ($personNotDuplicate instanceof PersonNotDuplicate) {
|
||||
$this->getDoctrine()->getManager()->remove($personNotDuplicate);
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
$this->managerRegistry->getManager()->remove($personNotDuplicate);
|
||||
$this->managerRegistry->getManager()->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('chill_person_duplicate_view', ['person_id' => $person1->getId()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/duplicate/view", name="chill_person_duplicate_view")
|
||||
*/
|
||||
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/duplicate/view', name: 'chill_person_duplicate_view')]
|
||||
public function viewAction(mixed $person_id, PersonNotDuplicateRepository $personNotDuplicateRepository)
|
||||
{
|
||||
$person = $this->_getPerson($person_id);
|
||||
@@ -233,7 +235,7 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll
|
||||
|
||||
private function _getCounters($id): ?array
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
|
||||
$nb_activity = $em->getRepository(Activity::class)->findBy(['person' => $id]);
|
||||
$nb_document = $em->getRepository(PersonDocument::class)->findBy(['person' => $id]);
|
||||
@@ -261,7 +263,7 @@ class PersonDuplicateController extends \Symfony\Bundle\FrameworkBundle\Controll
|
||||
private function _getPersonsByPriority($person1_id, $person2_id)
|
||||
{
|
||||
if ($person1_id === $person2_id) {
|
||||
throw new InvalidArgumentException('Can not merge same person');
|
||||
throw new \InvalidArgumentException('Can not merge same person');
|
||||
}
|
||||
|
||||
if ($person1_id > $person2_id) {
|
||||
|
@@ -25,13 +25,9 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
final class PersonResourceController extends AbstractController
|
||||
{
|
||||
public function __construct(private readonly PersonResourceRepository $personResourceRepository, private readonly PersonRepository $personRepository, private readonly EntityManagerInterface $em, private readonly TranslatorInterface $translator)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly PersonResourceRepository $personResourceRepository, private readonly PersonRepository $personRepository, private readonly EntityManagerInterface $em, private readonly TranslatorInterface $translator) {}
|
||||
|
||||
/**
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/resources/{resource_id}/delete", name="chill_person_resource_delete")
|
||||
*/
|
||||
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/resources/{resource_id}/delete', name: 'chill_person_resource_delete')]
|
||||
public function deleteAction(Request $request, mixed $person_id, mixed $resource_id): Response
|
||||
{
|
||||
$personOwner = $this->personRepository->find($person_id);
|
||||
@@ -48,14 +44,13 @@ final class PersonResourceController extends AbstractController
|
||||
'resource_id' => $resource_id,
|
||||
'person_id' => $person_id,
|
||||
]))
|
||||
->setMethod('DELETE')
|
||||
->add('submit', SubmitType::class, ['label' => 'Delete'])
|
||||
->getForm();
|
||||
|
||||
if (Request::METHOD_DELETE === $request->getMethod()) {
|
||||
if (Request::METHOD_POST === $request->getMethod()) {
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isValid()) {
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->em->remove($resource);
|
||||
$this->em->flush();
|
||||
|
||||
@@ -78,9 +73,7 @@ final class PersonResourceController extends AbstractController
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/resources/{resource_id}/edit", name="chill_person_resource_edit")
|
||||
*/
|
||||
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/resources/{resource_id}/edit', name: 'chill_person_resource_edit')]
|
||||
public function editAction(Request $request, mixed $resource_id, mixed $person_id): Response
|
||||
{
|
||||
$resource = $this->personResourceRepository->find($resource_id);
|
||||
@@ -115,9 +108,7 @@ final class PersonResourceController extends AbstractController
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/resources/list", name="chill_person_resource_list")
|
||||
*/
|
||||
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/resources/list', name: 'chill_person_resource_list')]
|
||||
public function listAction(Request $request, mixed $person_id)
|
||||
{
|
||||
$personOwner = $this->personRepository->find($person_id);
|
||||
@@ -135,9 +126,7 @@ final class PersonResourceController extends AbstractController
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/resources/new", name="chill_person_resource_new")
|
||||
*/
|
||||
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/resources/new', name: 'chill_person_resource_new')]
|
||||
public function newAction(Request $request, mixed $person_id)
|
||||
{
|
||||
$personOwner = $this->personRepository->find($person_id);
|
||||
|
@@ -39,13 +39,9 @@ use Symfony\Component\Validator\Constraints\NotNull;
|
||||
|
||||
class ReassignAccompanyingPeriodController extends AbstractController
|
||||
{
|
||||
public function __construct(private readonly AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, private readonly UserRepository $userRepository, private readonly AccompanyingPeriodRepository $courseRepository, private readonly \Twig\Environment $engine, private readonly FormFactoryInterface $formFactory, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly UserRender $userRender, private readonly EntityManagerInterface $em)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, private readonly UserRepository $userRepository, private readonly AccompanyingPeriodRepository $courseRepository, private readonly \Twig\Environment $engine, private readonly FormFactoryInterface $formFactory, private readonly PaginatorFactory $paginatorFactory, private readonly Security $security, private readonly UserRender $userRender, private readonly EntityManagerInterface $em) {}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/person/accompanying-periods/reassign", name="chill_course_list_reassign")
|
||||
*/
|
||||
#[Route(path: '/{_locale}/person/accompanying-periods/reassign', name: 'chill_course_list_reassign')]
|
||||
public function listAction(Request $request): Response
|
||||
{
|
||||
if (!$this->security->isGranted(AccompanyingPeriodVoter::REASSIGN_BULK)) {
|
||||
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Controller;
|
||||
|
||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||
|
||||
class RelationApiController extends ApiController {}
|
@@ -17,13 +17,10 @@ use Chill\PersonBundle\Repository\Relationships\RelationshipRepository;
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
|
||||
class RelationshipApiController extends ApiController
|
||||
{
|
||||
public function __construct(private readonly ValidatorInterface $validator, private readonly RelationshipRepository $repository)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly RelationshipRepository $repository) {}
|
||||
|
||||
/**
|
||||
* @ParamConverter("person", options={"id": "person_id"})
|
||||
|
@@ -27,13 +27,9 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
final class ResidentialAddressController extends AbstractController
|
||||
{
|
||||
public function __construct(private readonly UrlGeneratorInterface $generator, private readonly TranslatorInterface $translator, private readonly ResidentialAddressRepository $residentialAddressRepository)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly UrlGeneratorInterface $generator, private readonly TranslatorInterface $translator, private readonly ResidentialAddressRepository $residentialAddressRepository, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/person/residential-address/{id}/delete", name="chill_person_residential_address_delete")
|
||||
*/
|
||||
#[Route(path: '/{_locale}/person/residential-address/{id}/delete', name: 'chill_person_residential_address_delete')]
|
||||
public function deleteAction(Request $request, ResidentialAddress $residentialAddress): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(PersonVoter::UPDATE, $residentialAddress->getPerson());
|
||||
@@ -43,7 +39,7 @@ final class ResidentialAddressController extends AbstractController
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->managerRegistry->getManager();
|
||||
$em->remove($residentialAddress);
|
||||
$em->flush();
|
||||
|
||||
@@ -59,9 +55,7 @@ final class ResidentialAddressController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/person/residential-address/{id}/edit", name="chill_person_residential_address_edit")
|
||||
*/
|
||||
#[Route(path: '/{_locale}/person/residential-address/{id}/edit', name: 'chill_person_residential_address_edit')]
|
||||
public function editAction(Request $request, ResidentialAddress $residentialAddress): Response
|
||||
{
|
||||
if ($request->query->has('kind')) {
|
||||
@@ -77,7 +71,7 @@ final class ResidentialAddressController extends AbstractController
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
$this->managerRegistry->getManager()->flush();
|
||||
|
||||
$this->addFlash('success', $this->translator
|
||||
->trans('The residential address was updated successfully'));
|
||||
@@ -95,9 +89,7 @@ final class ResidentialAddressController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/person/{id}/residential-address/list", name="chill_person_residential_address_list")
|
||||
*/
|
||||
#[Route(path: '/{_locale}/person/{id}/residential-address/list', name: 'chill_person_residential_address_list')]
|
||||
public function listAction(Request $request, Person $person): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(PersonVoter::SEE, $person);
|
||||
@@ -110,9 +102,7 @@ final class ResidentialAddressController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/person/{id}/residential-address/new", name="chill_person_residential_address_new")
|
||||
*/
|
||||
#[Route(path: '/{_locale}/person/{id}/residential-address/new', name: 'chill_person_residential_address_new')]
|
||||
public function newAction(Request $request, Person $person): Response
|
||||
{
|
||||
$residentialAddress = new ResidentialAddress();
|
||||
@@ -129,8 +119,8 @@ final class ResidentialAddressController extends AbstractController
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->getDoctrine()->getManager()->persist($residentialAddress);
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
$this->managerRegistry->getManager()->persist($residentialAddress);
|
||||
$this->managerRegistry->getManager()->flush();
|
||||
|
||||
$this->addFlash('success', $this->translator
|
||||
->trans('The new residential address was created successfully'));
|
||||
|
@@ -22,20 +22,12 @@ use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class SocialWorkEvaluationApiController extends AbstractController
|
||||
{
|
||||
public function __construct(private readonly PaginatorFactory $paginatorFactory)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly PaginatorFactory $paginatorFactory) {}
|
||||
|
||||
/**
|
||||
* @Route("/api/1.0/person/social-work/evaluation/by-social-action/{action_id}.json",
|
||||
* name="chill_person_evaluation_index_by_social_action",
|
||||
* requirements={
|
||||
* "_format": "json"
|
||||
* }
|
||||
* )
|
||||
*
|
||||
* @ParamConverter("action", options={"id": "action_id"})
|
||||
*/
|
||||
#[Route(path: '/api/1.0/person/social-work/evaluation/by-social-action/{action_id}.json', name: 'chill_person_evaluation_index_by_social_action', requirements: ['_format' => 'json'])]
|
||||
public function listEvaluationBySocialAction(SocialAction $action): Response
|
||||
{
|
||||
$evaluations = $action->getEvaluations()->filter(static fn (Evaluation $eval) => $eval->isActive());
|
||||
|
@@ -21,9 +21,7 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class SocialWorkGoalApiController extends ApiController
|
||||
{
|
||||
public function __construct(private readonly GoalRepository $goalRepository, private readonly PaginatorFactory $paginator)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly GoalRepository $goalRepository, private readonly PaginatorFactory $paginator) {}
|
||||
|
||||
public function listBySocialAction(Request $request, SocialAction $action): Response
|
||||
{
|
||||
|
@@ -21,9 +21,7 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class SocialWorkResultApiController extends ApiController
|
||||
{
|
||||
public function __construct(private readonly ResultRepository $resultRepository)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly ResultRepository $resultRepository) {}
|
||||
|
||||
public function listByGoal(Request $request, Goal $goal): Response
|
||||
{
|
||||
|
@@ -26,8 +26,7 @@ final class SocialWorkSocialActionApiController extends ApiController
|
||||
private readonly SocialIssueRepository $socialIssueRepository,
|
||||
private readonly PaginatorFactory $paginator,
|
||||
private readonly ClockInterface $clock,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function listBySocialIssueApi($id, Request $request)
|
||||
{
|
||||
|
@@ -22,16 +22,12 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class TimelinePersonController extends AbstractController
|
||||
{
|
||||
public function __construct(protected EventDispatcherInterface $eventDispatcher, protected TimelineBuilder $timelineBuilder, protected PaginatorFactory $paginatorFactory)
|
||||
{
|
||||
}
|
||||
public function __construct(protected EventDispatcherInterface $eventDispatcher, protected TimelineBuilder $timelineBuilder, protected PaginatorFactory $paginatorFactory, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry) {}
|
||||
|
||||
/**
|
||||
* @\Symfony\Component\Routing\Annotation\Route(path="/{_locale}/person/{person_id}/timeline", name="chill_person_timeline")
|
||||
*/
|
||||
#[\Symfony\Component\Routing\Annotation\Route(path: '/{_locale}/person/{person_id}/timeline', name: 'chill_person_timeline')]
|
||||
public function personAction(Request $request, mixed $person_id)
|
||||
{
|
||||
$person = $this->getDoctrine()
|
||||
$person = $this->managerRegistry
|
||||
->getRepository(Person::class)
|
||||
->find($person_id);
|
||||
|
||||
|
@@ -21,13 +21,9 @@ use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class UserAccompanyingPeriodController extends AbstractController
|
||||
{
|
||||
public function __construct(private readonly AccompanyingPeriodRepository $accompanyingPeriodRepository, private readonly PaginatorFactory $paginatorFactory)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly AccompanyingPeriodRepository $accompanyingPeriodRepository, private readonly PaginatorFactory $paginatorFactory) {}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/person/accompanying-periods/my", name="chill_person_accompanying_period_user")
|
||||
*/
|
||||
#[Route(path: '/{_locale}/person/accompanying-periods/my', name: 'chill_person_accompanying_period_user')]
|
||||
public function listAction(Request $request): Response
|
||||
{
|
||||
$active = $request->query->getBoolean('active', true);
|
||||
@@ -58,9 +54,7 @@ class UserAccompanyingPeriodController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/person/accompanying-periods/my/drafts", name="chill_person_accompanying_period_draft_user")
|
||||
*/
|
||||
#[Route(path: '/{_locale}/person/accompanying-periods/my/drafts', name: 'chill_person_accompanying_period_draft_user')]
|
||||
public function listDraftsAction(): Response
|
||||
{
|
||||
$total = $this->accompanyingPeriodRepository->countBy(['user' => $this->getUser(), 'step' => 'DRAFT']);
|
||||
|
@@ -26,9 +26,7 @@ class LoadAccompanyingPeriodWork extends \Doctrine\Bundle\FixturesBundle\Fixture
|
||||
*/
|
||||
private array $cacheEvaluations = [];
|
||||
|
||||
public function __construct(private readonly AccompanyingPeriodRepository $periodRepository, private readonly EvaluationRepository $evaluationRepository)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly AccompanyingPeriodRepository $periodRepository, private readonly EvaluationRepository $evaluationRepository) {}
|
||||
|
||||
public function getDependencies()
|
||||
{
|
||||
|
@@ -37,8 +37,7 @@ class LoadCustomFields extends AbstractFixture implements OrderedFixtureInterfac
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly CustomFieldChoice $customFieldChoice,
|
||||
private readonly CustomFieldText $customFieldText,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
// put your code here
|
||||
public function getOrder()
|
||||
|
@@ -24,9 +24,7 @@ class LoadRelationships extends Fixture implements DependentFixtureInterface
|
||||
{
|
||||
use PersonRandomHelper;
|
||||
|
||||
public function __construct(private readonly EntityManagerInterface $em)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly EntityManagerInterface $em) {}
|
||||
|
||||
public function getDependencies(): array
|
||||
{
|
||||
|
@@ -19,9 +19,7 @@ use League\Csv\Reader;
|
||||
|
||||
class LoadSocialWorkMetadata extends Fixture implements OrderedFixtureInterface
|
||||
{
|
||||
public function __construct(private readonly SocialWorkMetadata $importer)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly SocialWorkMetadata $importer) {}
|
||||
|
||||
public function getOrder()
|
||||
{
|
||||
|
@@ -13,7 +13,10 @@ namespace Chill\PersonBundle\DependencyInjection;
|
||||
|
||||
use Chill\MainBundle\DependencyInjection\MissingBundleException;
|
||||
use Chill\MainBundle\Security\Authorization\ChillExportVoter;
|
||||
use Chill\PersonBundle\Controller\AccompanyingPeriodCommentApiController;
|
||||
use Chill\PersonBundle\Controller\AccompanyingPeriodResourceApiController;
|
||||
use Chill\PersonBundle\Controller\HouseholdCompositionTypeApiController;
|
||||
use Chill\PersonBundle\Controller\RelationApiController;
|
||||
use Chill\PersonBundle\Doctrine\DQL\AddressPart;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodCommentVoter;
|
||||
@@ -537,6 +540,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
],
|
||||
[
|
||||
'class' => AccompanyingPeriod\Comment::class,
|
||||
'controller' => AccompanyingPeriodCommentApiController::class,
|
||||
'name' => 'accompanying_period_comment',
|
||||
'base_path' => '/api/1.0/person/accompanying-period/comment',
|
||||
'base_role' => 'ROLE_USER',
|
||||
@@ -556,6 +560,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
],
|
||||
[
|
||||
'class' => AccompanyingPeriod\Resource::class,
|
||||
'controller' => AccompanyingPeriodResourceApiController::class,
|
||||
'name' => 'accompanying_period_resource',
|
||||
'base_path' => '/api/1.0/person/accompanying-period/resource',
|
||||
'base_role' => 'ROLE_USER',
|
||||
@@ -874,6 +879,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
],
|
||||
[
|
||||
'class' => \Chill\PersonBundle\Entity\Relationships\Relation::class,
|
||||
'controller' => RelationApiController::class,
|
||||
'name' => 'relations',
|
||||
'base_path' => '/api/1.0/relations/relation',
|
||||
'base_role' => 'ROLE_USER',
|
||||
|
@@ -37,10 +37,10 @@ use Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\LocationValidity
|
||||
use Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ParticipationOverlap;
|
||||
use Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ResourceDuplicateCheck;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use DateTime;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
use Doctrine\Common\Collections\Order;
|
||||
use Doctrine\Common\Collections\ReadableCollection;
|
||||
use Doctrine\Common\Collections\Selectable;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
@@ -53,23 +53,14 @@ use UnexpectedValueException;
|
||||
|
||||
/**
|
||||
* AccompanyingPeriod Class.
|
||||
*
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(name="chill_person_accompanying_period")
|
||||
*
|
||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "accompanying_period": AccompanyingPeriod::class
|
||||
* })
|
||||
*
|
||||
* @Assert\GroupSequenceProvider
|
||||
*
|
||||
* @AccompanyingPeriodValidity(groups={AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED})
|
||||
*
|
||||
* @LocationValidity(groups={AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED})
|
||||
*
|
||||
* @ConfidentialCourseMustHaveReferrer(groups={AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED})
|
||||
*/
|
||||
#[DiscriminatorMap(typeProperty: 'type', mapping: ['accompanying_period' => AccompanyingPeriod::class])]
|
||||
#[Assert\GroupSequenceProvider]
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'chill_person_accompanying_period')]
|
||||
#[AccompanyingPeriodValidity(groups: [AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED])]
|
||||
#[LocationValidity(groups: [AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED])]
|
||||
#[ConfidentialCourseMustHaveReferrer(groups: [AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED])]
|
||||
class AccompanyingPeriod implements
|
||||
GroupSequenceProviderInterface,
|
||||
HasCentersInterface,
|
||||
@@ -135,322 +126,179 @@ class AccompanyingPeriod implements
|
||||
*/
|
||||
final public const STEP_DRAFT = 'DRAFT';
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity=Address::class
|
||||
* )
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: Address::class)]
|
||||
private ?Address $addressLocation = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Location")
|
||||
*
|
||||
* @Groups({"read", "write"})
|
||||
*
|
||||
* @Assert\NotBlank(groups={AccompanyingPeriod::STEP_CONFIRMED})
|
||||
*/
|
||||
#[Groups(['read', 'write'])]
|
||||
#[Assert\NotBlank(groups: [AccompanyingPeriod::STEP_CONFIRMED])]
|
||||
#[ORM\ManyToOne(targetEntity: Location::class)]
|
||||
private ?Location $administrativeLocation = null;
|
||||
|
||||
/**
|
||||
* @var Collection&Selectable<int, Calendar>
|
||||
*
|
||||
* @ORM\OneToMany(targetEntity="Chill\CalendarBundle\Entity\Calendar", mappedBy="accompanyingPeriod")
|
||||
* @var \Doctrine\Common\Collections\Collection<int, \Chill\CalendarBundle\Entity\Calendar>&Selectable
|
||||
*/
|
||||
#[ORM\OneToMany(mappedBy: 'accompanyingPeriod', targetEntity: Calendar::class)]
|
||||
private Collection&Selectable $calendars;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date", nullable=true)
|
||||
*
|
||||
* @Groups({"read", "write", "docgen:read"})
|
||||
*
|
||||
* @Assert\NotBlank(groups={AccompanyingPeriod::STEP_CLOSED})
|
||||
*
|
||||
* @Assert\GreaterThanOrEqual(
|
||||
* propertyPath="openingDate",
|
||||
* groups={AccompanyingPeriod::STEP_CLOSED},
|
||||
* message="The closing date must be later than the date of creation"
|
||||
* )
|
||||
*/
|
||||
#[Groups(['read', 'write', 'docgen:read'])]
|
||||
#[Assert\NotBlank(groups: [AccompanyingPeriod::STEP_CLOSED])]
|
||||
#[Assert\GreaterThanOrEqual(propertyPath: 'openingDate', message: 'The closing date must be later than the date of creation', groups: [AccompanyingPeriod::STEP_CLOSED])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_MUTABLE, nullable: true)]
|
||||
private ?\DateTime $closingDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive")
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*
|
||||
* @Groups({"read", "write"})
|
||||
*
|
||||
* @Assert\NotBlank(groups={AccompanyingPeriod::STEP_CLOSED})
|
||||
*/
|
||||
#[Groups(['read', 'write'])]
|
||||
#[Assert\NotBlank(groups: [AccompanyingPeriod::STEP_CLOSED])]
|
||||
#[ORM\ManyToOne(targetEntity: ClosingMotive::class)]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
private ?ClosingMotive $closingMotive = null;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\Comment",
|
||||
* mappedBy="accompanyingPeriod",
|
||||
* cascade={"persist", "remove"},
|
||||
* orphanRemoval=true
|
||||
* )
|
||||
*
|
||||
* @ORM\OrderBy({"createdAt": "DESC", "id": "DESC"})
|
||||
*
|
||||
* @Assert\NotBlank(groups={AccompanyingPeriod::STEP_DRAFT})
|
||||
*
|
||||
* @var Collection<Comment>
|
||||
* @var \Doctrine\Common\Collections\Collection<int, \Chill\PersonBundle\Entity\AccompanyingPeriod\Comment>
|
||||
*/
|
||||
#[Assert\NotBlank(groups: [AccompanyingPeriod::STEP_DRAFT])]
|
||||
#[ORM\OneToMany(mappedBy: 'accompanyingPeriod', targetEntity: Comment::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['createdAt' => Criteria::DESC, 'id' => 'DESC'])]
|
||||
private Collection $comments;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", options={"default": false})
|
||||
*
|
||||
* @Groups({"read", "write", "docgen:read"})
|
||||
*/
|
||||
#[Groups(['read', 'write', 'docgen:read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, options: ['default' => false])]
|
||||
private bool $confidential = false;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true, options={"default": NULL})
|
||||
*
|
||||
* @Groups({"docgen:read"})
|
||||
*/
|
||||
#[Groups(['docgen:read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE, nullable: true, options: ['default' => null])]
|
||||
private ?\DateTimeInterface $createdAt = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*
|
||||
* @Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Groups(['read', 'docgen:read'])]
|
||||
#[ORM\ManyToOne(targetEntity: User::class)]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
private ?User $createdBy = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", options={"default": false})
|
||||
*
|
||||
* @Groups({"read", "write", "docgen:read"})
|
||||
*/
|
||||
#[Groups(['read', 'write', 'docgen:read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, options: ['default' => false])]
|
||||
private bool $emergency = false;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
*
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*
|
||||
* @Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
#[ORM\GeneratedValue(strategy: 'AUTO')]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", nullable=true)
|
||||
*
|
||||
* @Groups({"read"})
|
||||
*
|
||||
* @Assert\NotBlank(groups={AccompanyingPeriod::STEP_CONFIRMED})
|
||||
*/
|
||||
#[Groups(['read'])]
|
||||
#[Assert\NotBlank(groups: [AccompanyingPeriod::STEP_CONFIRMED])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, nullable: true)]
|
||||
private ?string $intensity = self::INTENSITY_OCCASIONAL;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity=UserJob::class
|
||||
* )
|
||||
*
|
||||
* @Groups({"read", "write"})
|
||||
*
|
||||
* @Assert\NotBlank(groups={AccompanyingPeriod::STEP_CONFIRMED})
|
||||
*/
|
||||
#[Groups(['read', 'write'])]
|
||||
#[Assert\NotBlank(groups: [AccompanyingPeriod::STEP_CONFIRMED])]
|
||||
#[ORM\ManyToOne(targetEntity: UserJob::class)]
|
||||
private ?UserJob $job = null;
|
||||
|
||||
/**
|
||||
* @var Collection<AccompanyingPeriodLocationHistory>
|
||||
*
|
||||
* @ORM\OneToMany(targetEntity=AccompanyingPeriodLocationHistory::class,
|
||||
* mappedBy="period", cascade={"persist", "remove"}, orphanRemoval=true)
|
||||
* @var Collection<int, AccompanyingPeriodLocationHistory>
|
||||
*/
|
||||
#[ORM\OneToMany(mappedBy: 'period', targetEntity: AccompanyingPeriodLocationHistory::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
private Collection $locationHistories;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date")
|
||||
*
|
||||
* @Groups({"read", "write", "docgen:read"})
|
||||
*
|
||||
* @Assert\LessThan(value="tomorrow", groups={AccompanyingPeriod::STEP_CONFIRMED})
|
||||
*
|
||||
* @Assert\LessThanOrEqual(propertyPath="closingDate", groups={AccompanyingPeriod::STEP_CONFIRMED})
|
||||
*/
|
||||
#[Groups(['read', 'write', 'docgen:read'])]
|
||||
#[Assert\LessThan(value: 'tomorrow', groups: [AccompanyingPeriod::STEP_CONFIRMED])]
|
||||
#[Assert\LessThanOrEqual(propertyPath: 'closingDate', groups: [AccompanyingPeriod::STEP_CONFIRMED])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_MUTABLE)]
|
||||
private ?\DateTime $openingDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Origin::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*
|
||||
* @Groups({"read", "write"})
|
||||
*
|
||||
* @Assert\NotBlank(groups={AccompanyingPeriod::STEP_CONFIRMED})
|
||||
*/
|
||||
#[Groups(['read', 'write'])]
|
||||
#[Assert\NotBlank(groups: [AccompanyingPeriod::STEP_CONFIRMED])]
|
||||
#[ORM\ManyToOne(targetEntity: Origin::class)]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
private ?Origin $origin = null;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity=AccompanyingPeriodParticipation::class,
|
||||
* mappedBy="accompanyingPeriod", orphanRemoval=true,
|
||||
* cascade={"persist", "refresh", "remove", "merge", "detach"})
|
||||
*
|
||||
* @Groups({"read", "docgen:read"})
|
||||
*
|
||||
* @ParticipationOverlap(groups={AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED})
|
||||
*
|
||||
* @var Collection<AccompanyingPeriodParticipation>
|
||||
* @var Collection<int, AccompanyingPeriodParticipation>
|
||||
*/
|
||||
#[Groups(['read', 'docgen:read'])]
|
||||
#[ORM\OneToMany(mappedBy: 'accompanyingPeriod', targetEntity: AccompanyingPeriodParticipation::class, cascade: ['persist', 'refresh', 'remove', 'merge', 'detach'], orphanRemoval: true)]
|
||||
#[ParticipationOverlap(groups: [AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED])]
|
||||
private Collection $participations;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity=Person::class,
|
||||
* inversedBy="periodLocatedOn"
|
||||
* )
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: Person::class, inversedBy: 'periodLocatedOn')]
|
||||
private ?Person $personLocation = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity=Comment::class,
|
||||
* cascade={"persist"},
|
||||
* )
|
||||
*
|
||||
* @Groups({"read"})
|
||||
*
|
||||
* @ORM\JoinColumn(onDelete="SET NULL")
|
||||
*/
|
||||
#[Groups(['read'])]
|
||||
#[ORM\ManyToOne(targetEntity: Comment::class, cascade: ['persist'])]
|
||||
#[ORM\JoinColumn(onDelete: 'SET NULL')]
|
||||
private ?Comment $pinnedComment = null;
|
||||
|
||||
private bool $preventUserIsChangedNotification = false;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text")
|
||||
*
|
||||
* @Groups({"read", "write"})
|
||||
*/
|
||||
#[Groups(['read', 'write'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)]
|
||||
private string $remark = '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", options={"default": false})
|
||||
*
|
||||
* @Groups({"read", "write", "docgen:read"})
|
||||
*/
|
||||
#[Groups(['read', 'write', 'docgen:read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, options: ['default' => false])]
|
||||
private bool $requestorAnonymous = false;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Person::class, inversedBy="accompanyingPeriodRequested")
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: Person::class, inversedBy: 'accompanyingPeriodRequested')]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
private ?Person $requestorPerson = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=ThirdParty::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: ThirdParty::class)]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
private ?ThirdParty $requestorThirdParty = null;
|
||||
|
||||
/**
|
||||
* @var Collection<resource>
|
||||
*
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\Resource",
|
||||
* mappedBy="accompanyingPeriod",
|
||||
* cascade={"persist", "remove"},
|
||||
* orphanRemoval=true
|
||||
* )
|
||||
*
|
||||
* @Groups({"read", "docgen:read"})
|
||||
*
|
||||
* @ResourceDuplicateCheck(groups={AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED, "Default", "default"})
|
||||
* @var Collection<int, AccompanyingPeriod\Resource>
|
||||
*/
|
||||
#[Groups(['read', 'docgen:read'])]
|
||||
#[ORM\OneToMany(targetEntity: AccompanyingPeriod\Resource::class, mappedBy: 'accompanyingPeriod', cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
#[ResourceDuplicateCheck(groups: [AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED, 'Default', 'default'])]
|
||||
private Collection $resources;
|
||||
|
||||
/**
|
||||
* @var Collection<Scope>
|
||||
*
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity=Scope::class,
|
||||
* cascade={}
|
||||
* )
|
||||
*
|
||||
* @ORM\JoinTable(
|
||||
* name="accompanying_periods_scopes",
|
||||
* joinColumns={@ORM\JoinColumn(name="accompanying_period_id", referencedColumnName="id")},
|
||||
* inverseJoinColumns={@ORM\JoinColumn(name="scope_id", referencedColumnName="id")}
|
||||
* )
|
||||
*
|
||||
* @Groups({"read", "docgen:read"})
|
||||
*
|
||||
* @Assert\Count(min=1, groups={AccompanyingPeriod::STEP_CONFIRMED}, minMessage="A course must be associated to at least one scope")
|
||||
* @var Collection<int, Scope>
|
||||
*/
|
||||
#[Groups(['read', 'docgen:read'])]
|
||||
#[Assert\Count(min: 1, groups: [AccompanyingPeriod::STEP_CONFIRMED], minMessage: 'A course must be associated to at least one scope')]
|
||||
#[ORM\ManyToMany(targetEntity: Scope::class, cascade: [])]
|
||||
#[ORM\JoinTable(name: 'accompanying_periods_scopes', joinColumns: [new ORM\JoinColumn(name: 'accompanying_period_id', referencedColumnName: 'id')], inverseJoinColumns: [new ORM\JoinColumn(name: 'scope_id', referencedColumnName: 'id')])]
|
||||
private Collection $scopes;
|
||||
|
||||
/**
|
||||
* @var Collection<SocialIssue>
|
||||
*
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity=SocialIssue::class
|
||||
* )
|
||||
*
|
||||
* @ORM\JoinTable(
|
||||
* name="chill_person_accompanying_period_social_issues"
|
||||
* )
|
||||
*
|
||||
* @Groups({"read", "docgen:read"})
|
||||
*
|
||||
* @Assert\Count(min=1, groups={AccompanyingPeriod::STEP_CONFIRMED}, minMessage="A course must contains at least one social issue")
|
||||
* @var Collection<int, SocialIssue>
|
||||
*/
|
||||
#[Groups(['read', 'docgen:read'])]
|
||||
#[Assert\Count(min: 1, groups: [AccompanyingPeriod::STEP_CONFIRMED], minMessage: 'A course must contains at least one social issue')]
|
||||
#[ORM\ManyToMany(targetEntity: SocialIssue::class)]
|
||||
#[ORM\JoinTable(name: 'chill_person_accompanying_period_social_issues')]
|
||||
private Collection $socialIssues;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=32, nullable=true)
|
||||
*
|
||||
* @Groups({"read"})
|
||||
*
|
||||
* @var AccompanyingPeriod::STEP_*
|
||||
*/
|
||||
#[Groups(['read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 32, nullable: true)]
|
||||
private ?string $step = self::STEP_DRAFT;
|
||||
|
||||
/**
|
||||
* @var Collection<AccompanyingPeriodStepHistory>
|
||||
*
|
||||
* @ORM\OneToMany(targetEntity=AccompanyingPeriodStepHistory::class,
|
||||
* mappedBy="period", cascade={"persist", "remove"}, orphanRemoval=true)
|
||||
* @var Collection<int, AccompanyingPeriodStepHistory>
|
||||
*/
|
||||
#[ORM\OneToMany(mappedBy: 'period', targetEntity: AccompanyingPeriodStepHistory::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
|
||||
private Collection $stepHistories;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true, options={"default": NULL})
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE, nullable: true, options: ['default' => null])]
|
||||
private ?\DateTimeInterface $updatedAt = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity=User::class
|
||||
* )
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: User::class)]
|
||||
private ?User $updatedBy = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*
|
||||
* @Groups({"read", "write", "docgen:read"})
|
||||
*/
|
||||
#[Groups(['read', 'write', 'docgen:read'])]
|
||||
#[ORM\ManyToOne(targetEntity: User::class)]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
private ?User $user = null;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity=UserHistory::class, mappedBy="accompanyingPeriod", orphanRemoval=true,
|
||||
* cascade={"persist", "remove"})
|
||||
*
|
||||
* @var Collection<UserHistory>
|
||||
* @var Collection<int, UserHistory>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: UserHistory::class, mappedBy: 'accompanyingPeriod', orphanRemoval: true, cascade: ['persist', 'remove'])]
|
||||
private Collection $userHistories;
|
||||
|
||||
private bool $userIsChanged = false;
|
||||
@@ -463,15 +311,10 @@ class AccompanyingPeriod implements
|
||||
private ?User $userPrevious = null;
|
||||
|
||||
/**
|
||||
* @var Collection<AccompanyingPeriodWork>
|
||||
*
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity=AccompanyingPeriodWork::class,
|
||||
* mappedBy="accompanyingPeriod"
|
||||
* )
|
||||
*
|
||||
* @Assert\Valid(traverse=true)
|
||||
* @var Collection<int, AccompanyingPeriodWork>
|
||||
*/
|
||||
#[Assert\Valid(traverse: true)]
|
||||
#[ORM\OneToMany(mappedBy: 'accompanyingPeriod', targetEntity: AccompanyingPeriodWork::class)]
|
||||
private Collection $works;
|
||||
|
||||
/**
|
||||
@@ -555,7 +398,7 @@ class AccompanyingPeriod implements
|
||||
|
||||
// ensure continuity of histories
|
||||
$criteria = new Criteria();
|
||||
$criteria->orderBy(['startDate' => \Doctrine\Common\Collections\Order::Ascending, 'id' => \Doctrine\Common\Collections\Order::Ascending]);
|
||||
$criteria->orderBy(['startDate' => Order::Ascending, 'id' => Order::Ascending]);
|
||||
|
||||
/** @var \Iterator $locations */
|
||||
$locations = $this->getLocationHistories()->matching($criteria)->getIterator();
|
||||
@@ -584,7 +427,7 @@ class AccompanyingPeriod implements
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addResource(Resource $resource): self
|
||||
public function addResource(AccompanyingPeriod\Resource $resource): self
|
||||
{
|
||||
$resource->setAccompanyingPeriod($this);
|
||||
$this->resources[] = $resource;
|
||||
@@ -749,10 +592,9 @@ class AccompanyingPeriod implements
|
||||
}
|
||||
|
||||
/**
|
||||
* @Groups({"read"})
|
||||
*
|
||||
* @return ReadableCollection<(int|string), Comment>
|
||||
* @return ReadableCollection<int, Comment>
|
||||
*/
|
||||
#[Groups(['read'])]
|
||||
public function getComments(): ReadableCollection
|
||||
{
|
||||
$pinnedComment = $this->pinnedComment;
|
||||
@@ -775,9 +617,7 @@ class AccompanyingPeriod implements
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Groups({"docgen:read"})
|
||||
*/
|
||||
#[Groups(['docgen:read'])]
|
||||
public function getCurrentParticipations(): ReadableCollection
|
||||
{
|
||||
return $this->getOpenParticipations();
|
||||
@@ -826,9 +666,8 @@ class AccompanyingPeriod implements
|
||||
|
||||
/**
|
||||
* Get the location, taking precedence into account.
|
||||
*
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
#[Groups(['read'])]
|
||||
public function getLocation(?\DateTimeImmutable $at = null): ?Address
|
||||
{
|
||||
if ($this->getPersonLocation() instanceof Person) {
|
||||
@@ -849,10 +688,9 @@ class AccompanyingPeriod implements
|
||||
/**
|
||||
* Get where the location is.
|
||||
*
|
||||
* @Groups({"read"})
|
||||
*
|
||||
* @return 'person'|'address'|'none'
|
||||
*/
|
||||
#[Groups(['read'])]
|
||||
public function getLocationStatus(): string
|
||||
{
|
||||
if ($this->getPersonLocation() instanceof Person) {
|
||||
@@ -954,9 +792,7 @@ class AccompanyingPeriod implements
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
#[Groups(['read'])]
|
||||
public function getPersonLocation(): ?Person
|
||||
{
|
||||
return $this->personLocation;
|
||||
@@ -965,7 +801,7 @@ class AccompanyingPeriod implements
|
||||
/**
|
||||
* Get a list of all persons which are participating to this course.
|
||||
*
|
||||
* @psalm-return Collection<(int|string), Person|null>
|
||||
* @psalm-return Collection<int, Person|null>
|
||||
*/
|
||||
public function getPersons(): Collection
|
||||
{
|
||||
@@ -976,9 +812,7 @@ class AccompanyingPeriod implements
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
#[Groups(['read'])]
|
||||
public function getPinnedComment(): ?Comment
|
||||
{
|
||||
return $this->pinnedComment;
|
||||
@@ -1031,9 +865,7 @@ class AccompanyingPeriod implements
|
||||
return $this->remark;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
#[Groups(['read'])]
|
||||
public function getRequestor(): Person|ThirdParty|null
|
||||
{
|
||||
return $this->requestorPerson ?? $this->requestorThirdParty;
|
||||
@@ -1065,6 +897,9 @@ class AccompanyingPeriod implements
|
||||
return $this->requestorThirdParty;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, AccompanyingPeriod\Resource>
|
||||
*/
|
||||
public function getResources(): Collection
|
||||
{
|
||||
return $this->resources;
|
||||
@@ -1259,9 +1094,7 @@ class AccompanyingPeriod implements
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Groups({"write"})
|
||||
*/
|
||||
#[Groups(['write'])]
|
||||
public function setAddressLocation(?Address $addressLocation = null): self
|
||||
{
|
||||
if ($this->addressLocation !== $addressLocation) {
|
||||
@@ -1374,9 +1207,7 @@ class AccompanyingPeriod implements
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Groups({"write"})
|
||||
*/
|
||||
#[Groups(['write'])]
|
||||
public function setPersonLocation(?Person $person = null): self
|
||||
{
|
||||
if ($this->personLocation !== $person) {
|
||||
@@ -1396,9 +1227,7 @@ class AccompanyingPeriod implements
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Groups({"write"})
|
||||
*/
|
||||
#[Groups(['write'])]
|
||||
public function setPinnedComment(?Comment $comment = null): self
|
||||
{
|
||||
if (null !== $this->pinnedComment) {
|
||||
@@ -1426,9 +1255,8 @@ class AccompanyingPeriod implements
|
||||
* @param $requestor Person|ThirdParty
|
||||
*
|
||||
* @throw UnexpectedValueException if the requestor is not a Person or ThirdParty
|
||||
*
|
||||
* @Groups({"write"})
|
||||
*/
|
||||
#[Groups(['write'])]
|
||||
public function setRequestor($requestor): self
|
||||
{
|
||||
if ($requestor instanceof Person) {
|
||||
@@ -1551,7 +1379,7 @@ class AccompanyingPeriod implements
|
||||
{
|
||||
// ensure continuity of histories
|
||||
$criteria = new Criteria();
|
||||
$criteria->orderBy(['startDate' => \Doctrine\Common\Collections\Order::Ascending, 'id' => \Doctrine\Common\Collections\Order::Ascending]);
|
||||
$criteria->orderBy(['startDate' => Order::Ascending, 'id' => Order::Ascending]);
|
||||
|
||||
/** @var \Iterator $steps */
|
||||
$steps = $this->getStepHistories()->matching($criteria)->getIterator();
|
||||
|
@@ -24,66 +24,54 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
* Usage:
|
||||
*
|
||||
* - get the user involved with an accompanying period
|
||||
*
|
||||
* @ORM\Entity()
|
||||
*
|
||||
* @ORM\Table(name="view_chill_person_accompanying_period_info")
|
||||
*/
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'view_chill_person_accompanying_period_info')]
|
||||
class AccompanyingPeriodInfo
|
||||
{
|
||||
public function __construct(
|
||||
/**
|
||||
* @var AccompanyingPeriod
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class)
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: AccompanyingPeriod::class)]
|
||||
public readonly AccompanyingPeriod $accompanyingPeriod,
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="text")
|
||||
*
|
||||
* @ORM\Id
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)]
|
||||
#[ORM\Id]
|
||||
public readonly string $relatedEntity,
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @ORM\Id
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
#[ORM\Id]
|
||||
public readonly int $relatedEntityId,
|
||||
|
||||
/**
|
||||
* @var User
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: User::class)]
|
||||
public readonly ?User $user,
|
||||
|
||||
/**
|
||||
* @var \DateTimeImmutable
|
||||
*
|
||||
* @ORM\Column(type="datetime_immutable")
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE)]
|
||||
public readonly \DateTimeImmutable $infoDate,
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*
|
||||
* @ORM\Column(type="json")
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)]
|
||||
public readonly array $metadata,
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="text")
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)]
|
||||
public readonly string $discriminator,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
}
|
||||
|
@@ -18,47 +18,30 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table("chill_person_accompanying_period_location_history")
|
||||
*/
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table('chill_person_accompanying_period_location_history')]
|
||||
class AccompanyingPeriodLocationHistory implements TrackCreationInterface
|
||||
{
|
||||
use TrackCreationTrait;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Address::class, cascade={"persist"})
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: Address::class, cascade: ['persist'])]
|
||||
private ?Address $addressLocation = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE, nullable: true, options: ['default' => null])]
|
||||
private ?\DateTimeImmutable $endDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class)
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: AccompanyingPeriod::class)]
|
||||
private AccompanyingPeriod $period;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Person::class)
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: Person::class)]
|
||||
private ?Person $personLocation = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable")
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE)]
|
||||
private ?\DateTimeImmutable $startDate = null;
|
||||
|
||||
public function getAddressLocation(): ?Address
|
||||
|
@@ -16,54 +16,35 @@ use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table("chill_person_accompanying_period_step_history")
|
||||
*/
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table('chill_person_accompanying_period_step_history')]
|
||||
class AccompanyingPeriodStepHistory implements TrackCreationInterface, TrackUpdateInterface
|
||||
{
|
||||
use TrackCreationTrait;
|
||||
|
||||
use TrackUpdateTrait;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE, nullable: true, options: ['default' => null])]
|
||||
private ?\DateTimeImmutable $endDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class)
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: AccompanyingPeriod::class)]
|
||||
private AccompanyingPeriod $period;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable")
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE)]
|
||||
private ?\DateTimeImmutable $startDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text", nullable=false)
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false)]
|
||||
private string $step;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=ClosingMotive::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: ClosingMotive::class)]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
private ?ClosingMotive $closingMotive = null;
|
||||
|
||||
public function getEndDate(): ?\DateTimeImmutable
|
||||
|
@@ -29,229 +29,125 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(name="chill_person_accompanying_period_work")
|
||||
*
|
||||
* @Serializer\DiscriminatorMap(
|
||||
* typeProperty="type",
|
||||
* mapping={
|
||||
* "accompanying_period_work": AccompanyingPeriodWork::class
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['accompanying_period_work' => AccompanyingPeriodWork::class])]
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'chill_person_accompanying_period_work')]
|
||||
class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterface, TrackCreationInterface, TrackUpdateInterface
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class)
|
||||
*
|
||||
* @Serializer\Groups({"read", "read:accompanyingPeriodWork:light"})
|
||||
*
|
||||
* @Serializer\Context(normalizationContext={"groups": {"read"}}, groups={"read:accompanyingPeriodWork:light"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'read:accompanyingPeriodWork:light'])]
|
||||
#[ORM\ManyToOne(targetEntity: AccompanyingPeriod::class)]
|
||||
#[Serializer\Context(normalizationContext: ['groups' => ['read']], groups: ['read:accompanyingPeriodWork:light'])]
|
||||
private ?AccompanyingPeriod $accompanyingPeriod = null;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity=AccompanyingPeriodWorkEvaluation::class,
|
||||
* mappedBy="accompanyingPeriodWork",
|
||||
* cascade={"remove", "persist"},
|
||||
* orphanRemoval=true
|
||||
* )
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
*
|
||||
* @ORM\OrderBy({"startDate": "DESC", "id": "DESC"})
|
||||
*
|
||||
* @var Collection<AccompanyingPeriodWorkEvaluation>
|
||||
* @var Collection<int, AccompanyingPeriodWorkEvaluation>
|
||||
*
|
||||
* @internal the serialization for write evaluations is handled in `accompanyingperiodworkdenormalizer`
|
||||
* @internal the serialization for context docgen:read is handled in `accompanyingperiodworknormalizer`
|
||||
*/
|
||||
#[Serializer\Groups(['read'])]
|
||||
#[ORM\OneToMany(mappedBy: 'accompanyingPeriodWork', targetEntity: AccompanyingPeriodWorkEvaluation::class, cascade: ['remove', 'persist'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['startDate' => \Doctrine\Common\Collections\Criteria::DESC, 'id' => 'DESC'])]
|
||||
private Collection $accompanyingPeriodWorkEvaluations;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read', 'read:accompanyingPeriodWork:light'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE)]
|
||||
private ?\DateTimeImmutable $createdAt = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read', 'read:accompanyingPeriodWork:light'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
|
||||
private bool $createdAutomatically = false;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read', 'read:accompanyingPeriodWork:light'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)]
|
||||
private string $createdAutomaticallyReason = '';
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read', 'read:accompanyingPeriodWork:light'])]
|
||||
#[ORM\ManyToOne(targetEntity: User::class)]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?User $createdBy = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
*
|
||||
* @Serializer\Groups({"accompanying_period_work:create"})
|
||||
* @Serializer\Groups({"accompanying_period_work:edit"})
|
||||
* @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"})
|
||||
*
|
||||
* @Assert\GreaterThanOrEqual(propertyPath="startDate",
|
||||
* message="accompanying_course_work.The endDate should be greater or equal than the start date"
|
||||
* )
|
||||
*/
|
||||
#[Serializer\Groups(['accompanying_period_work:create', 'accompanying_period_work:edit', 'read', 'docgen:read', 'read:accompanyingPeriodWork:light'])]
|
||||
#[Assert\GreaterThanOrEqual(propertyPath: 'startDate', message: 'accompanying_course_work.The endDate should be greater or equal than the start date')]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE, nullable: true, options: ['default' => null])]
|
||||
private ?\DateTimeImmutable $endDate = null;
|
||||
|
||||
/**
|
||||
* @var Collection<AccompanyingPeriodWorkGoal>
|
||||
*
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity=AccompanyingPeriodWorkGoal::class,
|
||||
* mappedBy="accompanyingPeriodWork",
|
||||
* cascade={"persist"},
|
||||
* orphanRemoval=true
|
||||
* )
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
* @Serializer\Groups({"accompanying_period_work:edit"})
|
||||
* @var Collection<int, AccompanyingPeriodWorkGoal>
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read', 'accompanying_period_work:edit'])]
|
||||
#[ORM\OneToMany(mappedBy: 'accompanyingPeriodWork', targetEntity: AccompanyingPeriodWorkGoal::class, cascade: ['persist'], orphanRemoval: true)]
|
||||
private Collection $goals;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=ThirdParty::class)
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
* @Serializer\Groups({"accompanying_period_work:edit"})
|
||||
*
|
||||
* In schema : traitant
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read', 'accompanying_period_work:edit'])]
|
||||
#[ORM\ManyToOne(targetEntity: ThirdParty::class)]
|
||||
private ?ThirdParty $handlingThierParty = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light", "read:evaluation:include-work"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read', 'read:accompanyingPeriodWork:light', 'read:evaluation:include-work'])]
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text")
|
||||
*
|
||||
* @Serializer\Groups({"read", "accompanying_period_work:edit", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'accompanying_period_work:edit', 'docgen:read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)]
|
||||
private string $note = '';
|
||||
|
||||
/**
|
||||
* @var Collection<Person>
|
||||
*
|
||||
* @ORM\ManyToMany(targetEntity=Person::class)
|
||||
*
|
||||
* @ORM\JoinTable(name="chill_person_accompanying_period_work_person")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"})
|
||||
* @Serializer\Groups({"accompanying_period_work:edit"})
|
||||
* @Serializer\Groups({"accompanying_period_work:create"})
|
||||
* @var Collection<int, Person>
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read', 'read:accompanyingPeriodWork:light', 'accompanying_period_work:edit', 'accompanying_period_work:create'])]
|
||||
#[ORM\ManyToMany(targetEntity: Person::class)]
|
||||
#[ORM\JoinTable(name: 'chill_person_accompanying_period_work_person')]
|
||||
private Collection $persons;
|
||||
|
||||
/**
|
||||
* @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\PrivateCommentEmbeddable", columnPrefix="privateComment_")
|
||||
*
|
||||
* @Serializer\Groups({"read", "accompanying_period_work:edit"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'accompanying_period_work:edit'])]
|
||||
#[ORM\Embedded(class: PrivateCommentEmbeddable::class, columnPrefix: 'privateComment_')]
|
||||
private PrivateCommentEmbeddable $privateComment;
|
||||
|
||||
/**
|
||||
* @var Collection<int, AccompanyingPeriodWorkReferrerHistory>
|
||||
*
|
||||
* @ORM\OneToMany(targetEntity=AccompanyingPeriodWorkReferrerHistory::class, cascade={"persist", "remove"}, mappedBy="accompanyingPeriodWork", orphanRemoval=true)
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: AccompanyingPeriodWorkReferrerHistory::class, cascade: ['persist', 'remove'], mappedBy: 'accompanyingPeriodWork', orphanRemoval: true)]
|
||||
private Collection $referrersHistory;
|
||||
|
||||
/**
|
||||
* @var Collection<Result>
|
||||
*
|
||||
* @ORM\ManyToMany(targetEntity=Result::class, inversedBy="accompanyingPeriodWorks")
|
||||
*
|
||||
* @ORM\JoinTable(name="chill_person_accompanying_period_work_result")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
* @Serializer\Groups({"accompanying_period_work:edit"})
|
||||
* @var Collection<int, \Chill\PersonBundle\Entity\SocialWork\Result>
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read', 'accompanying_period_work:edit'])]
|
||||
#[ORM\ManyToMany(targetEntity: Result::class, inversedBy: 'accompanyingPeriodWorks')]
|
||||
#[ORM\JoinTable(name: 'chill_person_accompanying_period_work_result')]
|
||||
private Collection $results;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=SocialAction::class)
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"})
|
||||
* @Serializer\Groups({"accompanying_period_work:create"})
|
||||
*
|
||||
* @Serializer\Context(normalizationContext={"groups": {"read"}}, groups={"read:accompanyingPeriodWork:light"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read', 'read:accompanyingPeriodWork:light', 'accompanying_period_work:create'])]
|
||||
#[ORM\ManyToOne(targetEntity: SocialAction::class)]
|
||||
#[Serializer\Context(normalizationContext: ['groups' => ['read']], groups: ['read:accompanyingPeriodWork:light'])]
|
||||
private ?SocialAction $socialAction = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable")
|
||||
*
|
||||
* @Serializer\Groups({"accompanying_period_work:create"})
|
||||
* @Serializer\Groups({"accompanying_period_work:edit"})
|
||||
* @Serializer\Groups({"read", "docgen:read", "read:accompanyingPeriodWork:light"})
|
||||
*/
|
||||
#[Serializer\Groups(['accompanying_period_work:create', 'accompanying_period_work:edit', 'read', 'docgen:read', 'read:accompanyingPeriodWork:light'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE)]
|
||||
private ?\DateTimeImmutable $startDate = null;
|
||||
|
||||
/**
|
||||
* @var Collection<ThirdParty>
|
||||
*
|
||||
* @ORM\ManyToMany(targetEntity=ThirdParty::class)
|
||||
*
|
||||
* @ORM\JoinTable(name="chill_person_accompanying_period_work_third_party")
|
||||
*
|
||||
* In schema : intervenants
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
* @Serializer\Groups({"accompanying_period_work:edit"})
|
||||
* @var Collection<int, ThirdParty>
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read', 'accompanying_period_work:edit'])]
|
||||
#[ORM\ManyToMany(targetEntity: ThirdParty::class)]
|
||||
#[ORM\JoinTable(name: 'chill_person_accompanying_period_work_third_party')] // In schema : intervenants
|
||||
private Collection $thirdParties;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE)]
|
||||
private ?\DateTimeImmutable $updatedAt = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\ManyToOne(targetEntity: User::class)]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?User $updatedBy = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="integer", nullable=false, options={"default": 1})
|
||||
*
|
||||
* @Serializer\Groups({"read", "accompanying_period_work:edit"})
|
||||
*
|
||||
* @ORM\Version
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'accompanying_period_work:edit'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER, nullable: false, options: ['default' => 1])]
|
||||
#[ORM\Version]
|
||||
private int $version = 1;
|
||||
|
||||
public function __construct()
|
||||
@@ -401,9 +297,8 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
|
||||
* and returns them as a new ReadableCollection.
|
||||
*
|
||||
* @return ReadableCollection<int, User> collection of active referrers
|
||||
*
|
||||
* @Serializer\Groups({"accompanying_period_work:edit"})
|
||||
*/
|
||||
#[Serializer\Groups(['accompanying_period_work:edit'])]
|
||||
public function getReferrers(): ReadableCollection
|
||||
{
|
||||
$users = $this->referrersHistory
|
||||
|
@@ -15,58 +15,31 @@ use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Entity\SocialWork\Evaluation;
|
||||
use DateInterval;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table("chill_person_accompanying_period_work_evaluation")
|
||||
*
|
||||
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "accompanying_period_work_evaluation": AccompanyingPeriodWorkEvaluation::class,
|
||||
* })
|
||||
*/
|
||||
#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['accompanying_period_work_evaluation' => AccompanyingPeriodWorkEvaluation::class])]
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table('chill_person_accompanying_period_work_evaluation')]
|
||||
class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackUpdateInterface
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity=AccompanyingPeriodWork::class,
|
||||
* inversedBy="accompanyingPeriodWorkEvaluations"
|
||||
* )
|
||||
*
|
||||
* @Serializer\Groups({"read:evaluation:include-work"})
|
||||
*
|
||||
* @Serializer\Context(normalizationContext={"groups": {"read:accompanyingPeriodWork:light"}}, groups={"read:evaluation:include-work"})
|
||||
*/
|
||||
#[Serializer\Groups(['read:evaluation:include-work'])]
|
||||
#[ORM\ManyToOne(targetEntity: AccompanyingPeriodWork::class, inversedBy: 'accompanyingPeriodWorkEvaluations')]
|
||||
#[Serializer\Context(normalizationContext: ['groups' => ['read:accompanyingPeriodWork:light']], groups: ['read:evaluation:include-work'])]
|
||||
private ?AccompanyingPeriodWork $accompanyingPeriodWork = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text", nullable=false, options={"default": ""})
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
* @Serializer\Groups({"write"})
|
||||
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read', 'write', 'accompanying_period_work_evaluation:create'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => ''])]
|
||||
private string $comment = '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE, nullable: true, options: ['default' => null])]
|
||||
private ?\DateTimeImmutable $createdAt = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity=User::class
|
||||
* )
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\ManyToOne(targetEntity: User::class)]
|
||||
private ?User $createdBy = null;
|
||||
|
||||
/**
|
||||
@@ -74,49 +47,25 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
|
||||
*
|
||||
* @see{Chill\PersonBundle\Serializer\Normalizer\AccompanyingPeriodWorkEvaluationDenormalizer}
|
||||
*
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity=AccompanyingPeriodWorkEvaluationDocument::class,
|
||||
* mappedBy="accompanyingPeriodWorkEvaluation",
|
||||
* cascade={"remove", "persist"},
|
||||
* orphanRemoval=true
|
||||
* )
|
||||
*
|
||||
* @ORM\OrderBy({"createdAt": "DESC", "id": "DESC"})
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
*
|
||||
* @var Collection<AccompanyingPeriodWorkEvaluationDocument>
|
||||
* @var Collection<int, AccompanyingPeriodWorkEvaluationDocument>
|
||||
*/
|
||||
#[Serializer\Groups(['read'])]
|
||||
#[ORM\OneToMany(mappedBy: 'accompanyingPeriodWorkEvaluation', targetEntity: AccompanyingPeriodWorkEvaluationDocument::class, cascade: ['remove', 'persist'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['createdAt' => \Doctrine\Common\Collections\Criteria::DESC, 'id' => 'DESC'])]
|
||||
private Collection $documents;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
* @Serializer\Groups({"write"})
|
||||
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read', 'write', 'accompanying_period_work_evaluation:create'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE, nullable: true, options: ['default' => null])]
|
||||
private ?\DateTimeImmutable $endDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity=Evaluation::class
|
||||
* )
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read', 'accompanying_period_work_evaluation:create'])]
|
||||
#[ORM\ManyToOne(targetEntity: Evaluation::class)]
|
||||
private ?Evaluation $evaluation = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
@@ -125,63 +74,32 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
|
||||
*
|
||||
* This data is not persisted into database, but will appears on the data
|
||||
* normalized during the same request (like PUT/PATCH request)
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"write"})
|
||||
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'write', 'accompanying_period_work_evaluation:create'])]
|
||||
private $key;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
* @Serializer\Groups({"write"})
|
||||
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read', 'write', 'accompanying_period_work_evaluation:create'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE, nullable: true, options: ['default' => null])]
|
||||
private ?\DateTimeImmutable $maxDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
* @Serializer\Groups({"write"})
|
||||
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read', 'write', 'accompanying_period_work_evaluation:create'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE, nullable: true, options: ['default' => null])]
|
||||
private ?\DateTimeImmutable $startDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE, nullable: true, options: ['default' => null])]
|
||||
private ?\DateTimeImmutable $updatedAt = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity=User::class
|
||||
* )
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\ManyToOne(targetEntity: User::class)]
|
||||
private ?User $updatedBy = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="dateinterval", nullable=true, options={"default": null})
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"write"})
|
||||
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'write', 'accompanying_period_work_evaluation:create'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATEINTERVAL, nullable: true, options: ['default' => null])]
|
||||
private ?\DateInterval $warningInterval = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="integer", nullable=true)
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
* @Serializer\Groups({"write"})
|
||||
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read', 'write', 'accompanying_period_work_evaluation:create'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER, nullable: true)]
|
||||
private ?int $timeSpent = null;
|
||||
|
||||
public function __construct()
|
||||
@@ -270,9 +188,7 @@ class AccompanyingPeriodWorkEvaluation implements TrackCreationInterface, TrackU
|
||||
return $this->updatedBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Serializer\Groups({"docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['docgen:read'])]
|
||||
public function getWarningDate(): ?\DateTimeImmutable
|
||||
{
|
||||
if (null === $this->getEndDate() || null === $this->getWarningInterval()) {
|
||||
|
@@ -19,43 +19,26 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table("chill_person_accompanying_period_work_evaluation_document")
|
||||
*
|
||||
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "accompanying_period_work_evaluation_document": AccompanyingPeriodWorkEvaluationDocument::class
|
||||
* })
|
||||
*/
|
||||
#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['accompanying_period_work_evaluation_document' => AccompanyingPeriodWorkEvaluationDocument::class])]
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table('chill_person_accompanying_period_work_evaluation_document')]
|
||||
class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doctrine\Model\TrackCreationInterface, \Chill\MainBundle\Doctrine\Model\TrackUpdateInterface
|
||||
{
|
||||
use TrackCreationTrait;
|
||||
|
||||
use TrackUpdateTrait;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity=AccompanyingPeriodWorkEvaluation::class,
|
||||
* inversedBy="documents"
|
||||
* )
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: AccompanyingPeriodWorkEvaluation::class, inversedBy: 'documents')]
|
||||
private ?AccompanyingPeriodWorkEvaluation $accompanyingPeriodWorkEvaluation = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @internal the default name exceeds 64 characters, we must set manually:
|
||||
*
|
||||
* @ORM\SequenceGenerator(sequenceName="chill_person_social_work_eval_doc_id_seq", allocationSize=1, initialValue=1000)
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'accompanying_period_work_evaluation:create'])]
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
#[ORM\SequenceGenerator(sequenceName: 'chill_person_social_work_eval_doc_id_seq', allocationSize: 1, initialValue: 1000)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
@@ -64,43 +47,21 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
|
||||
*
|
||||
* This data is not persisted into database, but will appears on the data
|
||||
* normalized during the same request (like PUT/PATCH request)
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"write"})
|
||||
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'write', 'accompanying_period_work_evaluation:create'])]
|
||||
private $key;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity=StoredObject::class,
|
||||
* )
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"write"})
|
||||
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
||||
*
|
||||
* @Assert\Valid
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'write', 'accompanying_period_work_evaluation:create'])]
|
||||
#[Assert\Valid]
|
||||
#[ORM\ManyToOne(targetEntity: StoredObject::class)]
|
||||
private ?StoredObject $storedObject = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity=DocGeneratorTemplate::class
|
||||
* )
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'accompanying_period_work_evaluation:create'])]
|
||||
#[ORM\ManyToOne(targetEntity: DocGeneratorTemplate::class)]
|
||||
private ?DocGeneratorTemplate $template = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text", nullable=false, options={"default": ""})
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"write"})
|
||||
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'write', 'accompanying_period_work_evaluation:create'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => ''])]
|
||||
private ?string $title = '';
|
||||
|
||||
public function getAccompanyingPeriodWorkEvaluation(): ?AccompanyingPeriodWorkEvaluation
|
||||
|
@@ -18,62 +18,34 @@ use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(name="chill_person_accompanying_period_work_goal")
|
||||
*
|
||||
* @Serializer\DiscriminatorMap(
|
||||
* typeProperty="type",
|
||||
* mapping={
|
||||
* "accompanying_period_work_goal": AccompanyingPeriodWorkGoal::class
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['accompanying_period_work_goal' => AccompanyingPeriodWorkGoal::class])]
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'chill_person_accompanying_period_work_goal')]
|
||||
class AccompanyingPeriodWorkGoal
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=AccompanyingPeriodWork::class, inversedBy="goals")
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: AccompanyingPeriodWork::class, inversedBy: 'goals')]
|
||||
private ?AccompanyingPeriodWork $accompanyingPeriodWork = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Goal::class)
|
||||
*
|
||||
* @Serializer\Groups({"accompanying_period_work:edit"})
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['accompanying_period_work:edit', 'read', 'docgen:read'])]
|
||||
#[ORM\ManyToOne(targetEntity: Goal::class)]
|
||||
private ?Goal $goal = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text")
|
||||
*
|
||||
* @Serializer\Groups({"accompanying_period_work:edit"})
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
#[Serializer\Groups(['accompanying_period_work:edit', 'read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)]
|
||||
private string $note = '';
|
||||
|
||||
/**
|
||||
* @var Collection<Result>
|
||||
*
|
||||
* @ORM\ManyToMany(targetEntity=Result::class, inversedBy="accompanyingPeriodWorkGoals")
|
||||
*
|
||||
* @ORM\JoinTable(name="chill_person_accompanying_period_work_goal_result")
|
||||
*
|
||||
* @Serializer\Groups({"accompanying_period_work:edit"})
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
* @var Collection<int, Result>
|
||||
*/
|
||||
#[Serializer\Groups(['accompanying_period_work:edit', 'read', 'docgen:read'])]
|
||||
#[ORM\ManyToMany(targetEntity: Result::class, inversedBy: 'accompanyingPeriodWorkGoals')]
|
||||
#[ORM\JoinTable(name: 'chill_person_accompanying_period_work_goal_result')]
|
||||
private Collection $results;
|
||||
|
||||
public function __construct()
|
||||
|
@@ -18,49 +18,35 @@ use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(name="chill_person_accompanying_period_work_referrer")
|
||||
*/
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'chill_person_accompanying_period_work_referrer')]
|
||||
class AccompanyingPeriodWorkReferrerHistory implements TrackCreationInterface, TrackUpdateInterface
|
||||
{
|
||||
use TrackCreationTrait;
|
||||
use TrackUpdateTrait;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE, nullable: true, options: ['default' => null])]
|
||||
private ?\DateTimeImmutable $endDate = null;
|
||||
|
||||
public function __construct(
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=AccompanyingPeriodWork::class, inversedBy="referrersHistory")
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: AccompanyingPeriodWork::class, inversedBy: 'referrersHistory')]
|
||||
private ?AccompanyingPeriodWork $accompanyingPeriodWork,
|
||||
/**
|
||||
* @var User
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: User::class)]
|
||||
private User $user,
|
||||
/**
|
||||
* @var \DateTimeImmutable
|
||||
*
|
||||
* @ORM\Column(type="date_immutable", nullable=false)
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE, nullable: false)]
|
||||
private \DateTimeImmutable $startDate,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
|
@@ -18,64 +18,40 @@ use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
|
||||
/**
|
||||
* ClosingMotive give an explanation why we closed the Accompanying period.
|
||||
*
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(name="chill_person_accompanying_period_closingmotive")
|
||||
*/
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'chill_person_accompanying_period_closingmotive')]
|
||||
class ClosingMotive
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
|
||||
private bool $active = true;
|
||||
|
||||
/**
|
||||
* Child Accompanying periods.
|
||||
*
|
||||
* @var Collection<ClosingMotive>
|
||||
*
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive",
|
||||
* mappedBy="parent")
|
||||
* @var Collection<int, ClosingMotive>
|
||||
*/
|
||||
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: ClosingMotive::class)]
|
||||
private Collection $children;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
*
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*
|
||||
* @Serializer\Groups({"docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['docgen:read'])]
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
#[ORM\GeneratedValue(strategy: 'AUTO')]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json")
|
||||
*
|
||||
* @Serializer\Groups({"docgen:read"})
|
||||
*
|
||||
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['docgen:read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)]
|
||||
#[Serializer\Context(['is-translatable' => true], groups: ['docgen:read'])]
|
||||
private array $name = [];
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="float")
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT)]
|
||||
private float $ordering = 0.0;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive",
|
||||
* inversedBy="children")
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: ClosingMotive::class, inversedBy: 'children')]
|
||||
private ?ClosingMotive $parent = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", nullable=false, options={"default": false})
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, nullable: false, options: ['default' => false])]
|
||||
private bool $isCanceledAccompanyingPeriod = false;
|
||||
|
||||
/**
|
||||
@@ -206,11 +182,9 @@ class ClosingMotive
|
||||
/**
|
||||
* Set name.
|
||||
*
|
||||
* @param array $name
|
||||
*
|
||||
* @return ClosingMotive
|
||||
*/
|
||||
public function setName($name)
|
||||
public function setName(array $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
|
@@ -20,78 +20,43 @@ use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(name="chill_person_accompanying_period_comment")
|
||||
*
|
||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "accompanying_period_comment": Comment::class
|
||||
* })
|
||||
*/
|
||||
#[DiscriminatorMap(typeProperty: 'type', mapping: ['accompanying_period_comment' => Comment::class])]
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'chill_person_accompanying_period_comment')]
|
||||
class Comment implements TrackCreationInterface, TrackUpdateInterface
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod",
|
||||
* inversedBy="comments")
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: AccompanyingPeriod::class, inversedBy: 'comments')]
|
||||
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
|
||||
private ?AccompanyingPeriod $accompanyingPeriod = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text", nullable=false, options={"default":""})
|
||||
*
|
||||
* @Groups({"read", "write", "docgen:read"})
|
||||
*
|
||||
* @Assert\NotBlank
|
||||
*
|
||||
* @Assert\NotNull
|
||||
*/
|
||||
#[Groups(['read', 'write', 'docgen:read'])]
|
||||
#[Assert\NotBlank]
|
||||
#[Assert\NotNull]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => ''])]
|
||||
private string $content = '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime")
|
||||
*
|
||||
* @Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE)]
|
||||
private ?\DateTimeInterface $createdAt = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*
|
||||
* @Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Groups(['read', 'docgen:read'])]
|
||||
#[ORM\ManyToOne(targetEntity: User::class)]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?User $creator = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime")
|
||||
*
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
#[Groups(['read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE)]
|
||||
private ?\DateTimeInterface $updatedAt = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
#[Groups(['read'])]
|
||||
#[ORM\ManyToOne(targetEntity: User::class)]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?User $updatedBy = null;
|
||||
|
||||
public function getAccompanyingPeriod(): ?AccompanyingPeriod
|
||||
|
@@ -14,44 +14,24 @@ namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(name="chill_person_accompanying_period_origin")
|
||||
*
|
||||
* @Serializer\DiscriminatorMap(
|
||||
* typeProperty="type",
|
||||
* mapping={
|
||||
* "origin": Origin::class
|
||||
* })
|
||||
*/
|
||||
#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['origin' => Origin::class])]
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'chill_person_accompanying_period_origin')]
|
||||
class Origin
|
||||
{
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*
|
||||
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)]
|
||||
#[Serializer\Context(['is-translatable' => true], groups: ['docgen:read'])]
|
||||
private array $label = [];
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true)
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE, nullable: true)]
|
||||
private ?\DateTimeImmutable $noActiveAfter = null;
|
||||
|
||||
public function getId(): ?int
|
||||
|
@@ -20,68 +20,38 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
/**
|
||||
* **About denormalization**: this operation is operated by @see{AccompanyingPeriodResourdeNormalizer}.
|
||||
*
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(
|
||||
* name="chill_person_accompanying_period_resource",
|
||||
* uniqueConstraints={
|
||||
*
|
||||
* @ORM\UniqueConstraint(name="person_unique", columns={"person_id", "accompanyingperiod_id"}),
|
||||
* @ORM\UniqueConstraint(name="thirdparty_unique", columns={"thirdparty_id", "accompanyingperiod_id"})
|
||||
* }
|
||||
* )
|
||||
*
|
||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "accompanying_period_resource": Resource::class
|
||||
* })
|
||||
*/
|
||||
#[DiscriminatorMap(typeProperty: 'type', mapping: ['accompanying_period_resource' => Resource::class])]
|
||||
#[ORM\Entity]
|
||||
#[ORM\UniqueConstraint(name: 'person_unique', columns: ['person_id', 'accompanyingperiod_id'])] // ,
|
||||
#[ORM\UniqueConstraint(name: 'thirdparty_unique', columns: ['thirdparty_id', 'accompanyingperiod_id'])]
|
||||
#[ORM\Table(name: 'chill_person_accompanying_period_resource')]
|
||||
#[ORM\UniqueConstraint(name: 'person_unique', columns: ['person_id', 'accompanyingperiod_id'])]
|
||||
#[ORM\UniqueConstraint(name: 'thirdparty_unique', columns: ['thirdparty_id', 'accompanyingperiod_id'])]
|
||||
class Resource
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod",
|
||||
* inversedBy="resources"
|
||||
* )
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: AccompanyingPeriod::class, inversedBy: 'resources')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?AccompanyingPeriod $accompanyingPeriod = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text", nullable=true)
|
||||
*
|
||||
* @Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: true)]
|
||||
private ?string $comment = '';
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Person::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*
|
||||
* @Groups({"docgen:read"})
|
||||
*/
|
||||
#[Groups(['docgen:read'])]
|
||||
#[ORM\ManyToOne(targetEntity: Person::class)]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
private ?Person $person = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=ThirdParty::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*
|
||||
* @Groups({"docgen:read"})
|
||||
*/
|
||||
#[Groups(['docgen:read'])]
|
||||
#[ORM\ManyToOne(targetEntity: ThirdParty::class)]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
private ?ThirdParty $thirdParty = null;
|
||||
|
||||
public function getAccompanyingPeriod(): ?AccompanyingPeriod
|
||||
@@ -104,9 +74,7 @@ class Resource
|
||||
return $this->person;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
#[Groups(['read'])]
|
||||
public function getResource(): Person|ThirdParty|null
|
||||
{
|
||||
return $this->person ?? $this->thirdParty;
|
||||
|
@@ -17,49 +17,30 @@ use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table("chill_person_accompanying_period_user_history")
|
||||
*/
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table('chill_person_accompanying_period_user_history')]
|
||||
class UserHistory implements TrackCreationInterface
|
||||
{
|
||||
use TrackCreationTrait;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable", nullable=true, options={"default": null})
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true, options: ['default' => null])]
|
||||
private ?\DateTimeImmutable $endDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
*
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
#[ORM\GeneratedValue(strategy: 'AUTO')]
|
||||
private ?int $id = null;
|
||||
|
||||
public function __construct(
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class, inversedBy="userHistories")
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: AccompanyingPeriod::class, inversedBy: 'userHistories')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?AccompanyingPeriod $accompanyingPeriod,
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: User::class)]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private User $user,
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable", nullable=false, options={"default": "now()"})
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: false, options: ['default' => 'now()'])]
|
||||
private \DateTimeImmutable $startDate = new \DateTimeImmutable('now'),
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function getAccompanyingPeriod(): AccompanyingPeriod
|
||||
{
|
||||
|
@@ -17,54 +17,31 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
/**
|
||||
* AccompanyingPeriodParticipation Class.
|
||||
*
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(name="chill_person_accompanying_period_participation")
|
||||
*
|
||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "accompanying_period_participation": AccompanyingPeriodParticipation::class
|
||||
* })
|
||||
*/
|
||||
#[DiscriminatorMap(typeProperty: 'type', mapping: ['accompanying_period_participation' => AccompanyingPeriodParticipation::class])]
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'chill_person_accompanying_period_participation')]
|
||||
class AccompanyingPeriodParticipation
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(type="date", nullable=true)
|
||||
*
|
||||
* @Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_MUTABLE, nullable: true)]
|
||||
private ?\DateTime $endDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date", nullable=false)
|
||||
*
|
||||
* @Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_MUTABLE, nullable: false)]
|
||||
private ?\DateTime $startDate = null;
|
||||
|
||||
public function __construct(/**
|
||||
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class, inversedBy="participations", cascade={"persist"})
|
||||
*
|
||||
* @ORM\JoinColumn(name="accompanyingperiod_id", referencedColumnName="id", nullable=false)
|
||||
*/
|
||||
private ?AccompanyingPeriod $accompanyingPeriod, /**
|
||||
* @ORM\ManyToOne(targetEntity=Person::class, inversedBy="accompanyingPeriodParticipations")
|
||||
*
|
||||
* @ORM\JoinColumn(name="person_id", referencedColumnName="id", nullable=false)
|
||||
*
|
||||
* @Groups({"read", "docgen:read"})
|
||||
*/
|
||||
public function __construct(
|
||||
#[ORM\ManyToOne(targetEntity: AccompanyingPeriod::class, inversedBy: 'participations', cascade: ['persist'])]
|
||||
#[ORM\JoinColumn(name: 'accompanyingperiod_id', referencedColumnName: 'id', nullable: false)]
|
||||
private ?AccompanyingPeriod $accompanyingPeriod,
|
||||
#[Groups(['read', 'docgen:read'])] #[ORM\ManyToOne(targetEntity: Person::class, inversedBy: 'accompanyingPeriodParticipations')] #[ORM\JoinColumn(name: 'person_id', referencedColumnName: 'id', nullable: false)]
|
||||
private ?Person $person,
|
||||
) {
|
||||
$this->startDate = new \DateTime('now');
|
||||
|
@@ -13,6 +13,7 @@ namespace Chill\PersonBundle\Entity\Household;
|
||||
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
||||
use Chill\MainBundle\Entity\HasCentersInterface;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Validator\Constraints\Household\MaxHolder;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
@@ -20,99 +21,61 @@ use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
use Doctrine\Common\Collections\ReadableCollection;
|
||||
use Doctrine\Common\Collections\Selectable;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(
|
||||
* name="chill_person_household"
|
||||
* )
|
||||
*
|
||||
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "household": Household::class
|
||||
* })
|
||||
*
|
||||
* @MaxHolder(groups={"household_memberships"})
|
||||
*/
|
||||
class Household
|
||||
#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['household' => Household::class])]
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'chill_person_household')]
|
||||
#[MaxHolder(groups: ['household_memberships'])]
|
||||
class Household implements HasCentersInterface
|
||||
{
|
||||
/**
|
||||
* Addresses.
|
||||
*
|
||||
* @var Collection<Address>
|
||||
*
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity="Chill\MainBundle\Entity\Address",
|
||||
* cascade={"persist", "remove", "merge", "detach"})
|
||||
*
|
||||
* @ORM\JoinTable(name="chill_person_household_to_addresses")
|
||||
*
|
||||
* @ORM\OrderBy({"validFrom": "DESC", "id": "DESC"})
|
||||
*
|
||||
* @Serializer\Groups({"write"})
|
||||
* @var Collection<int, \Chill\MainBundle\Entity\Address>
|
||||
*/
|
||||
#[Serializer\Groups(['write'])]
|
||||
#[ORM\ManyToMany(targetEntity: Address::class, cascade: ['persist', 'remove', 'merge', 'detach'])]
|
||||
#[ORM\JoinTable(name: 'chill_person_household_to_addresses')]
|
||||
#[ORM\OrderBy(['validFrom' => Criteria::DESC, 'id' => 'DESC'])]
|
||||
private Collection $addresses;
|
||||
|
||||
/**
|
||||
* @ORM\Embedded(class=CommentEmbeddable::class, columnPrefix="comment_members_")
|
||||
*/
|
||||
#[ORM\Embedded(class: CommentEmbeddable::class, columnPrefix: 'comment_members_')]
|
||||
private CommentEmbeddable $commentMembers;
|
||||
|
||||
/**
|
||||
* @var Collection&Selectable<int, HouseholdComposition>
|
||||
*
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity=HouseholdComposition::class,
|
||||
* mappedBy="household",
|
||||
* orphanRemoval=true,
|
||||
* cascade={"persist"}
|
||||
* )
|
||||
*
|
||||
* @ORM\OrderBy({"startDate": "DESC"})
|
||||
*
|
||||
* @Assert\Valid(traverse=true, groups={"household_composition"})
|
||||
* @var \Doctrine\Common\Collections\Collection<int, \Chill\PersonBundle\Entity\Household\HouseholdComposition>&Selectable
|
||||
*/
|
||||
#[Assert\Valid(groups: ['household_composition'], traverse: true)]
|
||||
#[ORM\OneToMany(mappedBy: 'household', targetEntity: HouseholdComposition::class, cascade: ['persist'], orphanRemoval: true)]
|
||||
#[ORM\OrderBy(['startDate' => Criteria::DESC])]
|
||||
private Collection&Selectable $compositions;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @var Collection<HouseholdMember>
|
||||
*
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity=HouseholdMember::class,
|
||||
* mappedBy="household"
|
||||
* )
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
* @var Collection<int, HouseholdMember>
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\OneToMany(mappedBy: 'household', targetEntity: HouseholdMember::class)]
|
||||
private Collection $members;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", name="waiting_for_birth", options={"default": false})
|
||||
*
|
||||
* @Serializer\Groups({"docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['docgen:read'])]
|
||||
#[ORM\Column(name: 'waiting_for_birth', type: Types::BOOLEAN, options: ['default' => false])]
|
||||
#[Assert\Type('boolean', groups: ['household_metadata'])]
|
||||
private bool $waitingForBirth = false;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", name="waiting_for_birth_date", nullable=true, options={"default": null})
|
||||
*
|
||||
* @Serializer\Groups({"docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['docgen:read'])]
|
||||
#[ORM\Column(type: Types::DATE_IMMUTABLE, name: 'waiting_for_birth_date', nullable: true, options: ['default' => null])]
|
||||
#[Assert\Expression('this.getWaitingForBirth() == false or value != null', message: 'The waiting for birth date must be set', groups: ['household_metadata'])]
|
||||
private ?\DateTimeImmutable $waitingForBirthDate = null;
|
||||
|
||||
public function __construct()
|
||||
@@ -159,8 +122,6 @@ class Household
|
||||
* By default, the addresses are ordered by date, descending (the most
|
||||
* recent first).
|
||||
*
|
||||
* @Assert\Callback(methods={"validate"})
|
||||
*
|
||||
* @return Collection<Address>
|
||||
*/
|
||||
public function getAddresses(): Collection
|
||||
@@ -196,6 +157,19 @@ class Household
|
||||
return $addresses;
|
||||
}
|
||||
|
||||
public function getCenters(): ?iterable
|
||||
{
|
||||
$centers = [];
|
||||
|
||||
foreach ($this->getCurrentPersons() as $person) {
|
||||
if (null !== $center = $person->getCenter()) {
|
||||
$centers[$center->getId() ?? spl_object_hash($center)] = $center;
|
||||
}
|
||||
}
|
||||
|
||||
return array_values($centers);
|
||||
}
|
||||
|
||||
public function getCommentMembers(): CommentEmbeddable
|
||||
{
|
||||
return $this->commentMembers;
|
||||
@@ -209,11 +183,8 @@ class Household
|
||||
return $this->compositions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*
|
||||
* @Serializer\SerializedName("current_address")
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[Serializer\SerializedName('current_address')]
|
||||
public function getCurrentAddress(?\DateTime $at = null): ?Address
|
||||
{
|
||||
$at ??= new \DateTime('today');
|
||||
@@ -229,11 +200,8 @@ class Household
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Serializer\Groups({"docgen:read"})
|
||||
*
|
||||
* @Serializer\SerializedName("current_composition")
|
||||
*/
|
||||
#[Serializer\Groups(['docgen:read'])]
|
||||
#[Serializer\SerializedName('current_composition')]
|
||||
public function getCurrentComposition(?\DateTimeImmutable $at = null): ?HouseholdComposition
|
||||
{
|
||||
$at ??= new \DateTimeImmutable('today');
|
||||
@@ -259,9 +227,7 @@ class Household
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Serializer\Groups({"docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['docgen:read'])]
|
||||
public function getCurrentMembers(?\DateTimeImmutable $now = null): Collection
|
||||
{
|
||||
return $this->getMembers()->matching($this->buildCriteriaCurrentMembers($now));
|
||||
@@ -281,11 +247,9 @@ class Household
|
||||
* get current members ids.
|
||||
*
|
||||
* Used in serialization
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
*
|
||||
* @Serializer\SerializedName("current_members_id")
|
||||
*/
|
||||
#[Serializer\Groups(['read'])]
|
||||
#[Serializer\SerializedName('current_members_id')]
|
||||
public function getCurrentMembersIds(?\DateTimeImmutable $now = null): ReadableCollection
|
||||
{
|
||||
return $this->getCurrentMembers($now)->map(
|
||||
@@ -606,9 +570,8 @@ class Household
|
||||
* This will force the startDate's address on today.
|
||||
*
|
||||
* Used on household creation.
|
||||
*
|
||||
* @Serializer\Groups({"create"})
|
||||
*/
|
||||
#[Serializer\Groups(['create'])]
|
||||
public function setForceAddress(Address $address)
|
||||
{
|
||||
$address->setValidFrom(new \DateTime('today'));
|
||||
@@ -629,14 +592,16 @@ class Household
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function validate(ExecutionContextInterface $context, $payload)
|
||||
#[Assert\Callback]
|
||||
public function validate(ExecutionContextInterface $context, $payload): void
|
||||
{
|
||||
$addresses = $this->getAddresses();
|
||||
$cond = true;
|
||||
$addresses = $this->getAddressesOrdered();
|
||||
|
||||
for ($i = 0; \count($addresses) - 1 > $i; ++$i) {
|
||||
if ($addresses[$i]->getValidFrom() !== $addresses[$i + 1]->getValidTo()) {
|
||||
$cond = false;
|
||||
if (0 === $i) {
|
||||
continue;
|
||||
}
|
||||
if ($addresses[$i - 1]->getValidTo() !== $addresses[$i]->getValidFrom()) {
|
||||
$context->buildViolation('The address are not sequentials. The validFrom date of one address should be equal to the validTo date of the previous address.')
|
||||
->atPath('addresses')
|
||||
->addViolation();
|
||||
|
@@ -20,82 +20,47 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(
|
||||
* name="chill_person_household_composition"
|
||||
* )
|
||||
*
|
||||
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "household_composition_type": HouseholdCompositionType::class
|
||||
* })
|
||||
*/
|
||||
#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['household_composition_type' => HouseholdCompositionType::class])]
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'chill_person_household_composition')]
|
||||
class HouseholdComposition implements TrackCreationInterface, TrackUpdateInterface
|
||||
{
|
||||
use TrackCreationTrait;
|
||||
|
||||
use TrackUpdateTrait;
|
||||
|
||||
/**
|
||||
* @ORM\Embedded(class=CommentEmbeddable::class, columnPrefix="comment_")
|
||||
*/
|
||||
#[ORM\Embedded(class: CommentEmbeddable::class, columnPrefix: 'comment_')]
|
||||
private CommentEmbeddable $comment;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
*
|
||||
* @Assert\GreaterThanOrEqual(propertyPath="startDate", groups={"Default", "household_composition"})
|
||||
*
|
||||
* @Serializer\Groups({"docgen:read"})
|
||||
*/
|
||||
#[Assert\GreaterThanOrEqual(propertyPath: 'startDate', groups: ['Default', 'household_composition'])]
|
||||
#[Serializer\Groups(['docgen:read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE, nullable: true, options: ['default' => null])]
|
||||
private ?\DateTimeImmutable $endDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Household::class, inversedBy="compositions")
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: Household::class, inversedBy: 'compositions')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?Household $household = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=HouseholdCompositionType::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*
|
||||
* @Serializer\Groups({"docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['docgen:read'])]
|
||||
#[ORM\ManyToOne(targetEntity: HouseholdCompositionType::class)]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?HouseholdCompositionType $householdCompositionType = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="integer", nullable=true, options={"default": null})
|
||||
*
|
||||
* @Assert\NotNull
|
||||
*
|
||||
* @Assert\GreaterThanOrEqual(0, groups={"Default", "household_composition"})
|
||||
*
|
||||
* @Serializer\Groups({"docgen:read"})
|
||||
*/
|
||||
#[Assert\NotNull]
|
||||
#[Assert\GreaterThanOrEqual(0, groups: ['Default', 'household_composition'])]
|
||||
#[Serializer\Groups(['docgen:read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER, nullable: true, options: ['default' => null])]
|
||||
private ?int $numberOfChildren = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=false)
|
||||
*
|
||||
* @Assert\NotNull(groups={"Default", "household_composition"})
|
||||
*
|
||||
* @Serializer\Groups({"docgen:read"})
|
||||
*/
|
||||
#[Assert\NotNull(groups: ['Default', 'household_composition'])]
|
||||
#[Serializer\Groups(['docgen:read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE, nullable: false)]
|
||||
private ?\DateTimeImmutable $startDate = null;
|
||||
|
||||
public function __construct()
|
||||
|
@@ -14,42 +14,23 @@ namespace Chill\PersonBundle\Entity\Household;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(
|
||||
* name="chill_person_household_composition_type"
|
||||
* )
|
||||
*
|
||||
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "household_composition_type": HouseholdCompositionType::class
|
||||
* })
|
||||
*/
|
||||
#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['household_composition_type' => HouseholdCompositionType::class])]
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'chill_person_household_composition_type')]
|
||||
class HouseholdCompositionType
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
|
||||
private bool $active = true;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*
|
||||
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)]
|
||||
#[Serializer\Context(['is-translatable' => true], groups: ['docgen:read'])]
|
||||
private array $label = [];
|
||||
|
||||
public function getId(): ?int
|
||||
|
@@ -16,98 +16,51 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(
|
||||
* name="chill_person_household_members"
|
||||
* )
|
||||
*/
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'chill_person_household_members')]
|
||||
class HouseholdMember
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255, nullable: true)]
|
||||
private ?string $comment = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*
|
||||
* @Assert\GreaterThanOrEqual(
|
||||
* propertyPath="startDate",
|
||||
* message="household_membership.The end date must be after start date",
|
||||
* groups={"household_memberships"}
|
||||
* )
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[Assert\GreaterThanOrEqual(propertyPath: 'startDate', message: 'household_membership.The end date must be after start date', groups: ['household_memberships'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE, nullable: true, options: ['default' => null])]
|
||||
private ?\DateTimeImmutable $endDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", options={"default": false})
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, options: ['default' => false])]
|
||||
private bool $holder = false;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="\Chill\PersonBundle\Entity\Household\Household"
|
||||
* )
|
||||
*
|
||||
* @Assert\Valid(groups={"household_memberships"})
|
||||
*
|
||||
* @Assert\NotNull(groups={"household_memberships"})
|
||||
*/
|
||||
#[Assert\Valid(groups: ['household_memberships'])]
|
||||
#[Assert\NotNull(groups: ['household_memberships'])]
|
||||
#[ORM\ManyToOne(targetEntity: Household::class)]
|
||||
private ?Household $household = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="\Chill\PersonBundle\Entity\Person"
|
||||
* )
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*
|
||||
* @Serializer\Context({"docgen:person:with-household": false})
|
||||
*
|
||||
* @Assert\Valid(groups={"household_memberships"})
|
||||
*
|
||||
* @Assert\NotNull(groups={"household_memberships"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[Assert\Valid(groups: ['household_memberships'])]
|
||||
#[Assert\NotNull(groups: ['household_memberships'])]
|
||||
#[ORM\ManyToOne(targetEntity: Person::class)]
|
||||
#[Serializer\Context(['docgen:person:with-household' => false])]
|
||||
private ?Person $person = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Position::class)
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\ManyToOne(targetEntity: Position::class)]
|
||||
private ?Position $position = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", name="sharedhousehold")
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, name: 'sharedhousehold')]
|
||||
private bool $shareHousehold = true;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*
|
||||
* @Assert\NotNull(groups={"household_memberships"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[Assert\NotNull(groups: ['household_memberships'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE, nullable: true, options: ['default' => null])]
|
||||
private ?\DateTimeImmutable $startDate = null;
|
||||
|
||||
public function getComment(): ?string
|
||||
@@ -140,9 +93,7 @@ class HouseholdMember
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read'])]
|
||||
public function getShareHousehold(): ?bool
|
||||
{
|
||||
return $this->shareHousehold;
|
||||
|
@@ -38,48 +38,30 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
* 1. 1st entity: from 2021-01-01 to 2021-06-01, household W, address Q;
|
||||
* 2. 2st entity: from 2021-06-01 to 2021-12-01, household W, address R;
|
||||
* 3. 3st entity: from 2021-12-01 to NULL, household V, address T;
|
||||
*
|
||||
* @ORM\Entity(readOnly=true)
|
||||
*
|
||||
* @ORM\Table(name="view_chill_person_household_address")
|
||||
*/
|
||||
#[ORM\Entity(readOnly: true)]
|
||||
#[ORM\Table(name: 'view_chill_person_household_address')]
|
||||
class PersonHouseholdAddress
|
||||
{
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity=Address::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
#[ORM\Id]
|
||||
#[ORM\ManyToOne(targetEntity: Address::class)]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?Address $address = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity=Household::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
#[ORM\Id]
|
||||
#[ORM\ManyToOne(targetEntity: Household::class)]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?Household $household = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity=Person::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
#[ORM\Id]
|
||||
#[ORM\ManyToOne(targetEntity: Person::class)]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?Person $person = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable")
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE)]
|
||||
private $validFrom;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true)
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE, nullable: true)]
|
||||
private $validTo;
|
||||
|
||||
public function getAddress(): ?Address
|
||||
|
@@ -14,56 +14,32 @@ namespace Chill\PersonBundle\Entity\Household;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(name="chill_person_household_position")
|
||||
*
|
||||
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "household_position": Position::class
|
||||
* })
|
||||
*/
|
||||
#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['household_position' => Position::class])]
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'chill_person_household_position')]
|
||||
class Position
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*
|
||||
* @Serializer\Groups({ "read" })
|
||||
*/
|
||||
#[Serializer\Groups(['read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
|
||||
private bool $allowHolder = false;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*
|
||||
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)]
|
||||
#[Serializer\Context(['is-translatable' => true], groups: ['docgen:read'])]
|
||||
private array $label = [];
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="float")
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT)]
|
||||
private float $ordering = 0.00;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
|
||||
private bool $shareHouseHold = true;
|
||||
|
||||
public function getAllowHolder(): bool
|
||||
|
@@ -15,25 +15,17 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* MaritalStatus.
|
||||
*
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(name="chill_person_marital_status")
|
||||
*
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*/
|
||||
#[ORM\Entity]
|
||||
#[ORM\HasLifecycleCallbacks]
|
||||
#[ORM\Table(name: 'chill_person_marital_status')]
|
||||
class MaritalStatus
|
||||
{
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\Column(type="string", length=7)
|
||||
*/
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 7)]
|
||||
private ?string $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json")
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)]
|
||||
private array $name;
|
||||
|
||||
public function __construct()
|
||||
|
@@ -39,6 +39,7 @@ use DateTime;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
use Doctrine\Common\Collections\Selectable;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use libphonenumber\PhoneNumber;
|
||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
@@ -47,34 +48,15 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
/**
|
||||
* Person Class.
|
||||
*
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(name="chill_person_person",
|
||||
* indexes={
|
||||
*
|
||||
* @ORM\Index(
|
||||
* name="person_names",
|
||||
* columns={"firstName", "lastName"}
|
||||
* ),
|
||||
* @ORM\Index(
|
||||
* name="person_birthdate",
|
||||
* columns={"birthdate"}
|
||||
* )
|
||||
* })
|
||||
*
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*
|
||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "person": Person::class
|
||||
* })
|
||||
*
|
||||
* @PersonHasCenter
|
||||
*
|
||||
* @HouseholdMembershipSequential(
|
||||
* groups={"household_memberships"}
|
||||
* )
|
||||
*/
|
||||
#[DiscriminatorMap(typeProperty: 'type', mapping: ['person' => Person::class])]
|
||||
#[ORM\Entity]
|
||||
#[ORM\Index(name: 'person_names', columns: ['firstName', 'lastName'])] // ,
|
||||
#[ORM\Index(name: 'person_birthdate', columns: ['birthdate'])] // @ORM\HasLifecycleCallbacks
|
||||
#[ORM\Table(name: 'chill_person_person')]
|
||||
#[ORM\HasLifecycleCallbacks]
|
||||
#[PersonHasCenter]
|
||||
#[HouseholdMembershipSequential(groups: ['household_memberships'])]
|
||||
class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateInterface, \Stringable
|
||||
{
|
||||
final public const BOTH_GENDER = 'both';
|
||||
@@ -92,171 +74,122 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
|
||||
/**
|
||||
* Accept receiving email.
|
||||
*
|
||||
* @ORM\Column(type="boolean", options={"default": false})
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, options: ['default' => false])]
|
||||
private ?bool $acceptEmail = false;
|
||||
|
||||
/**
|
||||
* Accept short text message (aka SMS).
|
||||
*
|
||||
* @ORM\Column(type="boolean", options={"default": false})
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, options: ['default' => false])]
|
||||
private ?bool $acceptSMS = false;
|
||||
|
||||
/**
|
||||
* The person's accompanying periods (when the person was accompanied by the center).
|
||||
*
|
||||
* @var Collection<AccompanyingPeriodParticipation>
|
||||
*
|
||||
* @ORM\OneToMany(targetEntity=AccompanyingPeriodParticipation::class,
|
||||
* mappedBy="person",
|
||||
* cascade={"persist", "remove", "merge", "detach"})
|
||||
*
|
||||
* @ORM\OrderBy({"startDate": "DESC"})
|
||||
* @var Collection<int, \Chill\PersonBundle\Entity\AccompanyingPeriodParticipation>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: AccompanyingPeriodParticipation::class, mappedBy: 'person', cascade: ['persist', 'remove', 'merge', 'detach'])]
|
||||
#[ORM\OrderBy(['startDate' => Criteria::DESC])]
|
||||
private Collection $accompanyingPeriodParticipations;
|
||||
|
||||
/**
|
||||
* The accompanying period requested by the Person.
|
||||
*
|
||||
* @ORM\OneToMany(targetEntity=AccompanyingPeriod::class,
|
||||
* mappedBy="requestorPerson")
|
||||
*
|
||||
* @var Collection<AccompanyingPeriod>
|
||||
* @var Collection<int, \Chill\PersonBundle\Entity\AccompanyingPeriod>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: AccompanyingPeriod::class, mappedBy: 'requestorPerson')]
|
||||
private Collection $accompanyingPeriodRequested;
|
||||
|
||||
/**
|
||||
* Addresses.
|
||||
*
|
||||
* @var Collection<Address>
|
||||
*
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity="Chill\MainBundle\Entity\Address",
|
||||
* cascade={"persist", "remove", "merge", "detach"})
|
||||
*
|
||||
* @ORM\JoinTable(name="chill_person_persons_to_addresses")
|
||||
*
|
||||
* @ORM\OrderBy({"validFrom": "DESC"})
|
||||
* @var Collection<int, \Chill\MainBundle\Entity\Address>
|
||||
*/
|
||||
#[ORM\ManyToMany(targetEntity: Address::class, cascade: ['persist', 'remove', 'merge', 'detach'])]
|
||||
#[ORM\JoinTable(name: 'chill_person_persons_to_addresses')]
|
||||
#[ORM\OrderBy(['validFrom' => Criteria::DESC])]
|
||||
private Collection $addresses;
|
||||
|
||||
/**
|
||||
* @var Collection<PersonAltName>
|
||||
*
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity="Chill\PersonBundle\Entity\PersonAltName",
|
||||
* mappedBy="person",
|
||||
* cascade={"persist", "remove", "merge", "detach"},
|
||||
* orphanRemoval=true)
|
||||
* @var Collection<int, \Chill\PersonBundle\Entity\PersonAltName>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: PersonAltName::class, mappedBy: 'person', cascade: ['persist', 'remove', 'merge', 'detach'], orphanRemoval: true)]
|
||||
private Collection $altNames;
|
||||
|
||||
/**
|
||||
* The person's birthdate.
|
||||
*
|
||||
* @ORM\Column(type="date", nullable=true)
|
||||
*
|
||||
* @Birthdate
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_MUTABLE, nullable: true)]
|
||||
#[Birthdate]
|
||||
private ?\DateTime $birthdate = null;
|
||||
|
||||
/**
|
||||
* @var Collection<Charge>
|
||||
*
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity=Charge::class,
|
||||
* mappedBy="person"
|
||||
* )
|
||||
* @var Collection<int, \Chill\BudgetBundle\Entity\Charge>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: Charge::class, mappedBy: 'person')]
|
||||
private Collection $budgetCharges;
|
||||
|
||||
/**
|
||||
* @var Collection<resource>
|
||||
*
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity=Resource::class,
|
||||
* mappedBy="person"
|
||||
* )
|
||||
* @var Collection<int, \Chill\BudgetBundle\Entity\Resource>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: Resource::class, mappedBy: 'person')]
|
||||
private Collection $budgetResources;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Calendar>
|
||||
*
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity="Chill\CalendarBundle\Entity\Calendar",
|
||||
* mappedBy="persons"
|
||||
* )
|
||||
*/
|
||||
#[ORM\ManyToMany(targetEntity: Calendar::class, mappedBy: 'persons')]
|
||||
private Collection $calendars;
|
||||
|
||||
/**
|
||||
* The person's center.
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Center")
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: Center::class)]
|
||||
private ?Center $center = null;
|
||||
|
||||
/**
|
||||
* @ORM\OneToOne(targetEntity=PersonCenterCurrent::class, mappedBy="person")
|
||||
*/
|
||||
#[ORM\OneToOne(mappedBy: 'person', targetEntity: PersonCenterCurrent::class)]
|
||||
private ?PersonCenterCurrent $centerCurrent = null;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity=PersonCenterHistory::class, mappedBy="person", cascade={"persist", "remove"})
|
||||
*
|
||||
* @var Collection<PersonCenterHistory>
|
||||
* @var \Doctrine\Common\Collections\Collection<int, \Chill\PersonBundle\Entity\Person\PersonCenterHistory>&Selectable
|
||||
*/
|
||||
private Collection $centerHistory;
|
||||
#[ORM\OneToMany(mappedBy: 'person', targetEntity: PersonCenterHistory::class, cascade: ['persist', 'remove'])]
|
||||
private Collection&Selectable $centerHistory;
|
||||
|
||||
/**
|
||||
* Array where customfield's data are stored.
|
||||
*
|
||||
* @ORM\Column(type="json")
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)]
|
||||
private ?array $cFData = null;
|
||||
|
||||
/**
|
||||
* The marital status of the person.
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Civility")
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: Civility::class)]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
private ?Civility $civility = null;
|
||||
|
||||
/**
|
||||
* Contact information for contacting the person.
|
||||
*
|
||||
* @ORM\Column(type="text", nullable=true)
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: true)]
|
||||
private ?string $contactInfo = '';
|
||||
|
||||
/**
|
||||
* The person's country of birth.
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Country")
|
||||
*
|
||||
* sf4 check: option inversedBy="birthsIn" return error mapping !!
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: Country::class)] // sf4 check: option inversedBy="birthsIn" return error mapping !!
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
private ?Country $countryOfBirth = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true, options={"default": NULL})
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE, nullable: true, options: ['default' => null])]
|
||||
private ?\DateTimeInterface $createdAt = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: User::class)]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
private ?User $createdBy = null;
|
||||
|
||||
/**
|
||||
@@ -273,258 +206,180 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* The current person address.
|
||||
*
|
||||
* This is computed through database and is optimized on database side.
|
||||
*
|
||||
* @ORM\OneToOne(targetEntity=PersonCurrentAddress::class, mappedBy="person")
|
||||
*/
|
||||
#[ORM\OneToOne(targetEntity: PersonCurrentAddress::class, mappedBy: 'person')]
|
||||
private ?PersonCurrentAddress $currentPersonAddress = null;
|
||||
|
||||
/**
|
||||
* The person's deathdate.
|
||||
*
|
||||
* @ORM\Column(type="date_immutable", nullable=true)
|
||||
*
|
||||
* @Assert\Date
|
||||
*
|
||||
* @Assert\GreaterThanOrEqual(propertyPath="birthdate")
|
||||
*
|
||||
* @Assert\LessThanOrEqual("today")
|
||||
*/
|
||||
#[Assert\Date]
|
||||
#[Assert\GreaterThanOrEqual(propertyPath: 'birthdate')]
|
||||
#[Assert\LessThanOrEqual('today')]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE, nullable: true)]
|
||||
private ?\DateTimeImmutable $deathdate = null;
|
||||
|
||||
/**
|
||||
* The person's email.
|
||||
*
|
||||
* @ORM\Column(type="text", nullable=true)
|
||||
*
|
||||
* @Assert\Email()
|
||||
*/
|
||||
#[Assert\Email]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: true)]
|
||||
private ?string $email = '';
|
||||
|
||||
/**
|
||||
* The person's first name.
|
||||
*
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*
|
||||
* @Assert\NotBlank(message="The firstname cannot be empty")
|
||||
*
|
||||
* @Assert\Length(
|
||||
* max=255,
|
||||
* )
|
||||
*/
|
||||
#[Assert\NotBlank(message: 'The firstname cannot be empty')]
|
||||
#[Assert\Length(max: 255)]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255)]
|
||||
private string $firstName = '';
|
||||
|
||||
/**
|
||||
* fullname canonical. Read-only field, which is calculated by
|
||||
* the database.
|
||||
*
|
||||
* @ORM\Column(type="text", nullable=true)
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: true)]
|
||||
private ?string $fullnameCanonical = '';
|
||||
|
||||
/**
|
||||
* The person's gender.
|
||||
*
|
||||
* @ORM\Column(type="string", length=9, nullable=true)
|
||||
*
|
||||
* @Assert\NotNull(message="The gender must be set")
|
||||
*/
|
||||
#[Assert\NotNull(message: 'The gender must be set')]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 9, nullable: true)]
|
||||
private ?string $gender = null;
|
||||
|
||||
/**
|
||||
* Comment on gender.
|
||||
*
|
||||
* @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="genderComment_")
|
||||
*/
|
||||
#[ORM\Embedded(class: CommentEmbeddable::class, columnPrefix: 'genderComment_')]
|
||||
private CommentEmbeddable $genderComment;
|
||||
|
||||
/**
|
||||
* Read-only field, computed by the database.
|
||||
*
|
||||
* @var Collection<PersonHouseholdAddress>
|
||||
*
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity=PersonHouseholdAddress::class,
|
||||
* mappedBy="person"
|
||||
* )
|
||||
* @var Collection<int, \Chill\PersonBundle\Entity\Household\PersonHouseholdAddress>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: PersonHouseholdAddress::class, mappedBy: 'person')]
|
||||
private Collection $householdAddresses;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity=HouseholdMember::class,
|
||||
* mappedBy="person"
|
||||
* )
|
||||
*
|
||||
* @var Collection<HouseholdMember>
|
||||
* @var Collection<int, \Chill\PersonBundle\Entity\Household\HouseholdMember>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: HouseholdMember::class, mappedBy: 'person')]
|
||||
private Collection $householdParticipations;
|
||||
|
||||
/**
|
||||
* The person's id.
|
||||
*
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
*
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
#[ORM\GeneratedValue(strategy: 'AUTO')]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* The person's last name.
|
||||
*
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*
|
||||
* @Assert\NotBlank(message="The lastname cannot be empty")
|
||||
*
|
||||
* @Assert\Length(
|
||||
* max=255,
|
||||
* )
|
||||
*/
|
||||
#[Assert\NotBlank(message: 'The lastname cannot be empty')]
|
||||
#[Assert\Length(max: 255)]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255)]
|
||||
private string $lastName = '';
|
||||
|
||||
/**
|
||||
* The marital status of the person.
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\MaritalStatus")
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: MaritalStatus::class)]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
private ?MaritalStatus $maritalStatus = null;
|
||||
|
||||
/**
|
||||
* Comment on marital status.
|
||||
*
|
||||
* @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="maritalStatusComment_")
|
||||
*/
|
||||
#[ORM\Embedded(class: CommentEmbeddable::class, columnPrefix: 'maritalStatusComment_')]
|
||||
private CommentEmbeddable $maritalStatusComment;
|
||||
|
||||
/**
|
||||
* The date of the last marital status change of the person.
|
||||
*
|
||||
* @ORM\Column(type="date", nullable=true)
|
||||
*
|
||||
* @Assert\Date
|
||||
*/
|
||||
#[Assert\Date]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_MUTABLE, nullable: true)]
|
||||
private ?\DateTime $maritalStatusDate = null;
|
||||
|
||||
/**
|
||||
* A remark over the person.
|
||||
*
|
||||
* @ORM\Column(type="text")
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)]
|
||||
private string $memo = '';
|
||||
|
||||
/**
|
||||
* The person's mobile phone number.
|
||||
*
|
||||
* @PhonenumberConstraint(type="mobile")
|
||||
*
|
||||
* @ORM\Column(type="phone_number", nullable=true)
|
||||
*/
|
||||
#[ORM\Column(type: 'phone_number', nullable: true)]
|
||||
#[PhonenumberConstraint(type: 'mobile')]
|
||||
private ?PhoneNumber $mobilenumber = null;
|
||||
|
||||
/**
|
||||
* The person's nationality.
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Country")
|
||||
*
|
||||
* sf4 check: option inversedBy="nationals" return error mapping !!
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: Country::class)] // sf4 check: option inversedBy="nationals" return error mapping !!
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
private ?Country $nationality = null;
|
||||
|
||||
/**
|
||||
* Number of children.
|
||||
*
|
||||
* @ORM\Column(type="integer", nullable=true)
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER, nullable: true)]
|
||||
private ?int $numberOfChildren = null;
|
||||
|
||||
/**
|
||||
* @var Collection<PersonPhone>
|
||||
*
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity="Chill\PersonBundle\Entity\PersonPhone",
|
||||
* mappedBy="person",
|
||||
* cascade={"persist", "remove", "merge", "detach"},
|
||||
* orphanRemoval=true
|
||||
* )
|
||||
*
|
||||
* @Assert\Valid(
|
||||
* traverse=true,
|
||||
* )
|
||||
* @var Collection<int, \Chill\PersonBundle\Entity\PersonPhone>
|
||||
*/
|
||||
#[Assert\Valid(traverse: true)]
|
||||
#[ORM\OneToMany(targetEntity: PersonPhone::class, mappedBy: 'person', cascade: ['persist', 'remove', 'merge', 'detach'], orphanRemoval: true)]
|
||||
private Collection $otherPhoneNumbers;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(
|
||||
* targetEntity=AccompanyingPeriod::class,
|
||||
* mappedBy="personLocation"
|
||||
* )
|
||||
*
|
||||
* @var Collection<AccompanyingPeriod>
|
||||
* @var Collection<int, \Chill\PersonBundle\Entity\AccompanyingPeriod>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: AccompanyingPeriod::class, mappedBy: 'personLocation')]
|
||||
private Collection $periodLocatedOn;
|
||||
|
||||
/**
|
||||
* The person's phonenumber.
|
||||
*
|
||||
* @ORM\Column(type="phone_number", nullable=true)
|
||||
*
|
||||
* @PhonenumberConstraint(
|
||||
* type="landline",
|
||||
* )
|
||||
*/
|
||||
#[ORM\Column(type: 'phone_number', nullable: true)]
|
||||
#[PhonenumberConstraint(type: 'landline')]
|
||||
private ?PhoneNumber $phonenumber = null;
|
||||
|
||||
/**
|
||||
* The person's place of birth.
|
||||
*
|
||||
* @ORM\Column(type="string", length=255, name="place_of_birth")
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255, name: 'place_of_birth')]
|
||||
private string $placeOfBirth = '';
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
|
||||
private bool $proxyAccompanyingPeriodOpenState = false; // TO-DELETE ?
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity=PersonResource::class, mappedBy="personOwner")
|
||||
*
|
||||
* @var Collection<PersonResource>
|
||||
* @var Collection<int, \Chill\PersonBundle\Entity\Person\PersonResource>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: PersonResource::class, mappedBy: 'personOwner')]
|
||||
private Collection $resources;
|
||||
|
||||
/**
|
||||
* The person's spoken languages.
|
||||
*
|
||||
* @var Collection<Language>
|
||||
*
|
||||
* @ORM\ManyToMany(targetEntity="Chill\MainBundle\Entity\Language")
|
||||
*
|
||||
* @ORM\JoinTable(
|
||||
* name="persons_spoken_languages",
|
||||
* joinColumns={@ORM\JoinColumn(name="person_id", referencedColumnName="id")},
|
||||
* inverseJoinColumns={@ORM\JoinColumn(name="language_id", referencedColumnName="id")}
|
||||
* )
|
||||
* @var Collection<int, Language>
|
||||
*/
|
||||
#[ORM\ManyToMany(targetEntity: Language::class)]
|
||||
#[ORM\JoinTable(name: 'persons_spoken_languages', joinColumns: [new ORM\JoinColumn(name: 'person_id', referencedColumnName: 'id')], inverseJoinColumns: [new ORM\JoinColumn(name: 'language_id', referencedColumnName: 'id')])]
|
||||
private Collection $spokenLanguages;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true, options={"default": NULL})
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE, nullable: true, options: ['default' => null])]
|
||||
private ?\DateTimeInterface $updatedAt = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity=User::class
|
||||
* )
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: User::class)]
|
||||
private ?User $updatedBy = null;
|
||||
|
||||
/**
|
||||
@@ -1410,11 +1265,8 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* Validation callback that checks if the accompanying periods are valid.
|
||||
*
|
||||
* This method add violation errors.
|
||||
*
|
||||
* @Assert\Callback(
|
||||
* groups={"accompanying_period_consistent"}
|
||||
* )
|
||||
*/
|
||||
#[Assert\Callback(groups: ['accompanying_period_consistent'])]
|
||||
public function isAccompanyingPeriodValid(ExecutionContextInterface $context)
|
||||
{
|
||||
$r = $this->checkAccompanyingPeriodsAreNotCollapsing();
|
||||
@@ -1439,11 +1291,8 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
* two addresses with the same validFrom date).
|
||||
*
|
||||
* This method add violation errors.
|
||||
*
|
||||
* @Assert\Callback(
|
||||
* groups={"addresses_consistent"}
|
||||
* )
|
||||
*/
|
||||
#[Assert\Callback(groups: ['addresses_consistent'])]
|
||||
public function isAddressesValid(ExecutionContextInterface $context)
|
||||
{
|
||||
if ($this->hasTwoAdressWithSameValidFromDate()) {
|
||||
@@ -1561,10 +1410,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $birthdate
|
||||
*/
|
||||
public function setBirthdate($birthdate): self
|
||||
public function setBirthdate(?\DateTime $birthdate): self
|
||||
{
|
||||
$this->birthdate = $birthdate;
|
||||
|
||||
@@ -1595,7 +1441,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCenterHistory(Collection $centerHistory): Person
|
||||
public function setCenterHistory(Collection&Selectable $centerHistory): Person
|
||||
{
|
||||
$this->centerHistory = $centerHistory;
|
||||
|
||||
@@ -1679,7 +1525,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setFullnameCanonical($fullnameCanonical): self
|
||||
public function setFullnameCanonical(?string $fullnameCanonical): self
|
||||
{
|
||||
$this->fullnameCanonical = $fullnameCanonical;
|
||||
|
||||
@@ -1787,7 +1633,10 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setSpokenLanguages(mixed $spokenLanguages): self
|
||||
/**
|
||||
* @param (Collection<int, Language>) $spokenLanguages
|
||||
*/
|
||||
public function setSpokenLanguages(Collection $spokenLanguages): self
|
||||
{
|
||||
$this->spokenLanguages = $spokenLanguages;
|
||||
|
||||
|
@@ -0,0 +1,198 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Entity\Person;
|
||||
|
||||
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
|
||||
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
#[ORM\MappedSuperclass]
|
||||
class AbstractPersonResource implements TrackCreationInterface, TrackUpdateInterface
|
||||
{
|
||||
use TrackCreationTrait;
|
||||
|
||||
use TrackUpdateTrait;
|
||||
|
||||
#[ORM\Embedded(class: CommentEmbeddable::class, columnPrefix: 'comment_')]
|
||||
#[Groups(['read', 'docgen:read'])]
|
||||
private CommentEmbeddable $comment;
|
||||
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: true)]
|
||||
#[Groups(['read', 'docgen:read'])]
|
||||
private ?string $freeText = null;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: PersonResourceKind::class, inversedBy: 'personResources')]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
#[Groups(['read', 'docgen:read'])]
|
||||
private ?PersonResourceKind $kind = null;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: Person::class)]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
#[Groups(['read', 'docgen:read'])]
|
||||
private ?Person $person = null;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: Person::class, inversedBy: 'resources')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[Groups(['read'])]
|
||||
private ?Person $personOwner = null;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: ThirdParty::class, inversedBy: 'personResources')]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
#[Groups(['read', 'docgen:read'])]
|
||||
private ?ThirdParty $thirdParty = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->comment = new CommentEmbeddable();
|
||||
}
|
||||
|
||||
public function getComment(): CommentEmbeddable
|
||||
{
|
||||
return $this->comment;
|
||||
}
|
||||
|
||||
public function getFreeText(): ?string
|
||||
{
|
||||
return $this->freeText;
|
||||
}
|
||||
|
||||
public function getKind(): ?PersonResourceKind
|
||||
{
|
||||
return $this->kind;
|
||||
}
|
||||
|
||||
public function getPerson(): ?Person
|
||||
{
|
||||
return $this->person;
|
||||
}
|
||||
|
||||
public function getPersonOwner(): ?Person
|
||||
{
|
||||
return $this->personOwner;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Groups({"read", "docgen:read"})
|
||||
*/
|
||||
public function getResourceKind(): string
|
||||
{
|
||||
if ($this->getPerson() instanceof Person) {
|
||||
return 'person';
|
||||
}
|
||||
|
||||
if ($this->getThirdParty() instanceof ThirdParty) {
|
||||
return 'thirdparty';
|
||||
}
|
||||
|
||||
if (null !== $this->getFreeText()) {
|
||||
return 'freetext';
|
||||
}
|
||||
|
||||
return 'none';
|
||||
}
|
||||
|
||||
public function getThirdParty(): ?ThirdParty
|
||||
{
|
||||
return $this->thirdParty;
|
||||
}
|
||||
|
||||
public function setComment(?CommentEmbeddable $comment): self
|
||||
{
|
||||
if (null === $comment) {
|
||||
$this->comment->setComment('');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->comment = $comment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setFreeText(?string $freeText): self
|
||||
{
|
||||
$this->freeText = $freeText;
|
||||
|
||||
if ('' !== $freeText && null !== $freeText) {
|
||||
$this->setPerson(null);
|
||||
$this->setThirdParty(null);
|
||||
}
|
||||
|
||||
if ('' === $freeText) {
|
||||
$this->freeText = null;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setKind(?PersonResourceKind $kind): self
|
||||
{
|
||||
$this->kind = $kind;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPerson(?Person $person): self
|
||||
{
|
||||
$this->person = $person;
|
||||
|
||||
if (null !== $person) {
|
||||
$this->setFreeText('');
|
||||
$this->setThirdParty(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPersonOwner(?Person $personOwner): self
|
||||
{
|
||||
$this->personOwner = $personOwner;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setThirdParty(?ThirdParty $thirdParty): self
|
||||
{
|
||||
$this->thirdParty = $thirdParty;
|
||||
|
||||
if (null !== $thirdParty) {
|
||||
$this->setFreeText('');
|
||||
$this->setPerson(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Assert\Callback
|
||||
*/
|
||||
public function validate(ExecutionContextInterface $context, mixed $payload): void
|
||||
{
|
||||
if (null === $this->person && null === $this->thirdParty && (null === $this->freeText || '' === $this->freeText)) {
|
||||
$context->buildViolation('You must associate at least one entity')
|
||||
->addViolation();
|
||||
}
|
||||
|
||||
if (null !== $this->person && $this->person === $this->personOwner) {
|
||||
$context->buildViolation('You cannot associate a resource with the same person')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
}
|
@@ -21,39 +21,26 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
* The process of selecting the current center is done on database side,
|
||||
* using a SQL view.
|
||||
*
|
||||
* @ORM\Entity(readOnly=true)
|
||||
*
|
||||
* @ORM\Table(name="view_chill_person_person_center_history_current")
|
||||
*
|
||||
* @psalm-internal Chill\PersonBundle\Entity
|
||||
*/
|
||||
#[ORM\Entity(readOnly: true)]
|
||||
#[ORM\Table(name: 'view_chill_person_person_center_history_current')]
|
||||
class PersonCenterCurrent
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Center::class)
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: Center::class)]
|
||||
private Center $center;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE, nullable: true, options: ['default' => null])]
|
||||
private ?\DateTimeImmutable $endDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\OneToOne(targetEntity=Person::class, inversedBy="centerCurrent")
|
||||
*/
|
||||
#[ORM\OneToOne(targetEntity: Person::class, inversedBy: 'centerCurrent')]
|
||||
private Person $person;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=false)
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE, nullable: false)]
|
||||
private \DateTimeImmutable $startDate;
|
||||
|
||||
/**
|
||||
|
@@ -21,46 +21,31 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* Associate a Person with a Center. The association may change on date intervals.
|
||||
*
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(name="chill_person_person_center_history")
|
||||
*/
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'chill_person_person_center_history')]
|
||||
class PersonCenterHistory implements TrackCreationInterface, TrackUpdateInterface
|
||||
{
|
||||
use TrackCreationTrait;
|
||||
|
||||
use TrackUpdateTrait;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE, nullable: true, options: ['default' => null])]
|
||||
private ?\DateTimeImmutable $endDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
public function __construct(
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Person::class, inversedBy="centerHistory")
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: Person::class, inversedBy: 'centerHistory')]
|
||||
private ?Person $person = null,
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Center::class)
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: Center::class)]
|
||||
private ?Center $center = null,
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=false)
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE, nullable: false)]
|
||||
private ?\DateTimeImmutable $startDate = null,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function getCenter(): ?Center
|
||||
{
|
||||
|
@@ -23,35 +23,23 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
*
|
||||
* The validFrom and validTo properties are the intersection of
|
||||
* household membership and address validity. See @see{PersonHouseholdAddress}
|
||||
*
|
||||
* @ORM\Entity(readOnly=true)
|
||||
*
|
||||
* @ORM\Table("view_chill_person_current_address")
|
||||
*/
|
||||
#[ORM\Entity(readOnly: true)]
|
||||
#[ORM\Table('view_chill_person_current_address')]
|
||||
class PersonCurrentAddress
|
||||
{
|
||||
/**
|
||||
* @ORM\OneToOne(targetEntity=Address::class)
|
||||
*/
|
||||
#[ORM\OneToOne(targetEntity: Address::class)]
|
||||
protected Address $address;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\OneToOne(targetEntity=Person::class, inversedBy="currentPersonAddress")
|
||||
*
|
||||
* @ORM\JoinColumn(name="person_id", referencedColumnName="id")
|
||||
*/
|
||||
#[ORM\Id]
|
||||
#[ORM\OneToOne(targetEntity: Person::class, inversedBy: 'currentPersonAddress')]
|
||||
#[ORM\JoinColumn(name: 'person_id', referencedColumnName: 'id')]
|
||||
protected Person $person;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="valid_from", type="date_immutable")
|
||||
*/
|
||||
#[ORM\Column(name: 'valid_from', type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE)]
|
||||
protected \DateTimeImmutable $validFrom;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="valid_to", type="date_immutable")
|
||||
*/
|
||||
#[ORM\Column(name: 'valid_to', type: \Doctrine\DBAL\Types\Types::DATE_IMMUTABLE)]
|
||||
protected ?\DateTimeImmutable $validTo = null;
|
||||
|
||||
public function getAddress(): Address
|
||||
|
@@ -12,241 +12,24 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Entity\Person;
|
||||
|
||||
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
|
||||
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(name="chill_person_resource")
|
||||
*
|
||||
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "personResource": personResource::class
|
||||
* })
|
||||
*/
|
||||
class PersonResource implements TrackCreationInterface, TrackUpdateInterface
|
||||
#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['personResource' => PersonResource::class])]
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'chill_person_resource')]
|
||||
class PersonResource extends AbstractPersonResource implements TrackCreationInterface, TrackUpdateInterface
|
||||
{
|
||||
use TrackCreationTrait;
|
||||
|
||||
use TrackUpdateTrait;
|
||||
|
||||
/**
|
||||
* @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="comment_")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
private CommentEmbeddable $comment;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text", nullable=true)
|
||||
*
|
||||
* @Groups({"read", "docgen:read"})
|
||||
*/
|
||||
private ?string $freeText = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=PersonResourceKind::class, inversedBy="personResources")
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*
|
||||
* @Groups({"read", "docgen:read"})
|
||||
*/
|
||||
private ?PersonResourceKind $kind = null;
|
||||
|
||||
/**
|
||||
* The person which host the owner of this resource.
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity=Person::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*
|
||||
* @Groups({"read", "docgen:read"})
|
||||
*/
|
||||
private ?Person $person = null;
|
||||
|
||||
/**
|
||||
* The person linked with this resource.
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity=Person::class, inversedBy="resources")
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
private ?Person $personOwner = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=ThirdParty::class, inversedBy="personResources")
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*
|
||||
* @Groups({"read", "docgen:read"})
|
||||
*/
|
||||
private ?ThirdParty $thirdParty = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->comment = new CommentEmbeddable();
|
||||
}
|
||||
|
||||
public function getComment(): CommentEmbeddable
|
||||
{
|
||||
return $this->comment;
|
||||
}
|
||||
|
||||
public function getFreeText(): ?string
|
||||
{
|
||||
return $this->freeText;
|
||||
}
|
||||
|
||||
/**
|
||||
* GETTERS.
|
||||
*/
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getKind(): ?PersonResourceKind
|
||||
{
|
||||
return $this->kind;
|
||||
}
|
||||
|
||||
public function getPerson(): ?Person
|
||||
{
|
||||
return $this->person;
|
||||
}
|
||||
|
||||
public function getPersonOwner(): ?Person
|
||||
{
|
||||
return $this->personOwner;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Groups({"read", "docgen:read"})
|
||||
*/
|
||||
public function getResourceKind(): string
|
||||
{
|
||||
if ($this->getPerson() instanceof Person) {
|
||||
return 'person';
|
||||
}
|
||||
|
||||
if ($this->getThirdParty() instanceof ThirdParty) {
|
||||
return 'thirdparty';
|
||||
}
|
||||
|
||||
if (null !== $this->getFreeText()) {
|
||||
return 'freetext';
|
||||
}
|
||||
|
||||
return 'none';
|
||||
}
|
||||
|
||||
public function getThirdParty(): ?ThirdParty
|
||||
{
|
||||
return $this->thirdParty;
|
||||
}
|
||||
|
||||
public function setComment(?CommentEmbeddable $comment): self
|
||||
{
|
||||
if (null === $comment) {
|
||||
$this->comment->setComment('');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->comment = $comment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setFreeText(?string $freeText): self
|
||||
{
|
||||
$this->freeText = $freeText;
|
||||
|
||||
if ('' !== $freeText && null !== $freeText) {
|
||||
$this->setPerson(null);
|
||||
$this->setThirdParty(null);
|
||||
}
|
||||
|
||||
if ('' === $freeText) {
|
||||
$this->freeText = null;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setKind(?PersonResourceKind $kind): self
|
||||
{
|
||||
$this->kind = $kind;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPerson(?Person $person): self
|
||||
{
|
||||
$this->person = $person;
|
||||
|
||||
if (null !== $person) {
|
||||
$this->setFreeText('');
|
||||
$this->setThirdParty(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPersonOwner(?Person $personOwner): self
|
||||
{
|
||||
$this->personOwner = $personOwner;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setThirdParty(?ThirdParty $thirdParty): self
|
||||
{
|
||||
$this->thirdParty = $thirdParty;
|
||||
|
||||
if (null !== $thirdParty) {
|
||||
$this->setFreeText('');
|
||||
$this->setPerson(null);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Assert\Callback
|
||||
*/
|
||||
public function validate(ExecutionContextInterface $context, mixed $payload)
|
||||
{
|
||||
if (null === $this->person && null === $this->thirdParty && (null === $this->freeText || '' === $this->freeText)) {
|
||||
$context->buildViolation('You must associate at least one entity')
|
||||
->addViolation();
|
||||
}
|
||||
|
||||
if (null !== $this->person && $this->person === $this->personOwner) {
|
||||
$context->buildViolation('You cannot associate a resource with the same person')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -14,36 +14,22 @@ namespace Chill\PersonBundle\Entity\Person;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(name="chill_person_resource_kind")
|
||||
*/
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'chill_person_resource_kind')]
|
||||
class PersonResourceKind
|
||||
{
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @Serializer\Groups({"docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['docgen:read'])]
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
|
||||
private bool $isActive = true;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json", length=255)
|
||||
*
|
||||
* @Serializer\Groups({"docgen:read"})
|
||||
*
|
||||
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['docgen:read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, length: 255)]
|
||||
#[Serializer\Context(['is-translatable' => true], groups: ['docgen:read'])]
|
||||
private array $title;
|
||||
|
||||
public function getId(): ?int
|
||||
|
@@ -20,75 +20,44 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation\Context;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass=ResidentialAddressRepository::class)
|
||||
*
|
||||
* @ORM\Table(name="chill_person_residential_address")
|
||||
*/
|
||||
#[ORM\Entity(repositoryClass: ResidentialAddressRepository::class)]
|
||||
#[ORM\Table(name: 'chill_person_residential_address')]
|
||||
class ResidentialAddress
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Address::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
#[Groups(['read'])]
|
||||
#[ORM\ManyToOne(targetEntity: Address::class)]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
private ?Address $address = null;
|
||||
|
||||
/**
|
||||
* @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="residentialAddressComment_")
|
||||
*/
|
||||
#[ORM\Embedded(class: CommentEmbeddable::class, columnPrefix: 'residentialAddressComment_')]
|
||||
private CommentEmbeddable $comment;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable", nullable=true)
|
||||
*
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
#[Groups(['read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true)]
|
||||
private ?\DateTimeImmutable $endDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Person::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*
|
||||
* @Groups({"read"})
|
||||
*
|
||||
* @Context(normalizationContext={"groups": {"minimal"}})
|
||||
*/
|
||||
#[Groups(['read'])]
|
||||
#[ORM\ManyToOne(targetEntity: Person::class)]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
#[Context(normalizationContext: ['groups' => ['minimal']])]
|
||||
private ?Person $hostPerson = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=ThirdParty::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
#[Groups(['read'])]
|
||||
#[ORM\ManyToOne(targetEntity: ThirdParty::class)]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
private ?ThirdParty $hostThirdParty = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Person::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: Person::class)]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private Person $person;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable")
|
||||
*
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
#[Groups(['read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE)]
|
||||
private ?\DateTimeImmutable $startDate = null;
|
||||
|
||||
public function __construct()
|
||||
|
@@ -16,42 +16,25 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
/**
|
||||
* PersonAltName.
|
||||
*
|
||||
* @ORM\Table(name="chill_person_alt_name")
|
||||
*
|
||||
* @ORM\Entity
|
||||
*/
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'chill_person_alt_name')]
|
||||
class PersonAltName
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
*
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
#[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue(strategy: 'AUTO')]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="key", type="string", length=255)
|
||||
*
|
||||
* @Groups({"write"})
|
||||
*/
|
||||
#[Groups(['write'])]
|
||||
#[ORM\Column(name: 'key', type: \Doctrine\DBAL\Types\Types::STRING, length: 255)]
|
||||
private string $key = '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="label", type="text")
|
||||
*
|
||||
* @Groups({"write"})
|
||||
*/
|
||||
#[Groups(['write'])]
|
||||
#[ORM\Column(name: 'label', type: \Doctrine\DBAL\Types\Types::TEXT)]
|
||||
private string $label = '';
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="Chill\PersonBundle\Entity\Person",
|
||||
* inversedBy="altNames"
|
||||
* )
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: Person::class, inversedBy: 'altNames')]
|
||||
private ?Person $person = null;
|
||||
|
||||
/**
|
||||
|
@@ -12,47 +12,33 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Entity;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* PersonNotDuplicate.
|
||||
*
|
||||
* @ORM\Table(name="chill_person_not_duplicate")
|
||||
*
|
||||
* @ORM\Entity
|
||||
*/
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'chill_person_not_duplicate')]
|
||||
class PersonNotDuplicate
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(type="datetime")
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE)]
|
||||
private \DateTime $date;
|
||||
|
||||
/**
|
||||
* The person's id.
|
||||
*
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
*
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
#[ORM\GeneratedValue(strategy: 'AUTO')]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\Person")
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: Person::class)]
|
||||
private ?Person $person1 = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\Person")
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: Person::class)]
|
||||
private ?Person $person2 = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: User::class)]
|
||||
private ?User $user = null;
|
||||
|
||||
public function __construct()
|
||||
@@ -90,7 +76,7 @@ class PersonNotDuplicate
|
||||
$this->date = $date;
|
||||
}
|
||||
|
||||
public function setId($id)
|
||||
public function setId(?int $id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
@@ -11,58 +11,36 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Entity;
|
||||
|
||||
use DateTime;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use libphonenumber\PhoneNumber;
|
||||
|
||||
/**
|
||||
* Person Phones.
|
||||
*
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(name="chill_person_phone",
|
||||
* indexes={
|
||||
*
|
||||
* @ORM\Index(name="phonenumber", columns={"phonenumber"})
|
||||
* })
|
||||
*/
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'chill_person_phone')]
|
||||
#[ORM\Index(name: 'phonenumber', columns: ['phonenumber'])]
|
||||
#[ORM\Index(name: 'phonenumber', columns: ['phonenumber'])]
|
||||
class PersonPhone
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=false)
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE, nullable: false)]
|
||||
private \DateTime $date;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text", nullable=true)
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: true)]
|
||||
private ?string $description = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
*
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(name: 'id', type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
#[ORM\GeneratedValue(strategy: 'AUTO')]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(
|
||||
* targetEntity="Chill\PersonBundle\Entity\Person",
|
||||
* inversedBy="otherPhoneNumbers"
|
||||
* )
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: Person::class, inversedBy: 'otherPhoneNumbers')]
|
||||
private Person $person;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="phone_number", nullable=false)
|
||||
*/
|
||||
#[ORM\Column(type: 'phone_number', nullable: false)]
|
||||
private ?PhoneNumber $phonenumber = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text", length=40, nullable=true)
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, length: 40, nullable: true)]
|
||||
private ?string $type = null;
|
||||
|
||||
public function __construct()
|
||||
|
@@ -15,51 +15,29 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(name="chill_person_relations")
|
||||
*
|
||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "relation": Relation::class
|
||||
* })
|
||||
*/
|
||||
#[DiscriminatorMap(typeProperty: 'type', mapping: ['relation' => Relation::class])]
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'chill_person_relations')]
|
||||
class Relation
|
||||
{
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", nullable=true)
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, nullable: true)]
|
||||
private bool $isActive = true;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json", nullable=true)
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
*
|
||||
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, nullable: true)]
|
||||
#[Serializer\Context(['is-translatable' => true], groups: ['docgen:read'])]
|
||||
private array $reverseTitle = [];
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json", nullable=true)
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
*
|
||||
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, nullable: true)]
|
||||
#[Serializer\Context(['is-translatable' => true], groups: ['docgen:read'])]
|
||||
private array $title = [];
|
||||
|
||||
public function getId(): ?int
|
||||
|
@@ -12,8 +12,9 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Entity\Relationships;
|
||||
|
||||
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Validator\Constraints\Relationship\RelationshipNoDuplicate;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
@@ -23,109 +24,45 @@ use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(name="chill_person_relationships")
|
||||
*
|
||||
* @DiscriminatorColumn(name="relation_id", type="integer")
|
||||
*
|
||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "relationship": Relationship::class
|
||||
* })
|
||||
*
|
||||
* @RelationshipNoDuplicate
|
||||
*/
|
||||
#[DiscriminatorMap(typeProperty: 'type', mapping: ['relationship' => Relationship::class])]
|
||||
#[ORM\Entity]
|
||||
#[DiscriminatorColumn(name: 'relation_id', type: 'integer')]
|
||||
#[ORM\Table(name: 'chill_person_relationships')]
|
||||
#[RelationshipNoDuplicate]
|
||||
class Relationship implements TrackCreationInterface, TrackUpdateInterface
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable")
|
||||
*/
|
||||
private ?\DateTimeImmutable $createdAt = null;
|
||||
use TrackCreationTrait;
|
||||
use TrackUpdateTrait;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private ?User $createdBy = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Person::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*
|
||||
* @Assert\NotNull
|
||||
*
|
||||
* @Serializer\Groups({"read", "write"})
|
||||
*/
|
||||
#[Assert\NotNull]
|
||||
#[Serializer\Groups(['read', 'write'])]
|
||||
#[ORM\ManyToOne(targetEntity: Person::class)]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?Person $fromPerson = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read'])]
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Relation::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false, name="relation_id", referencedColumnName="id")
|
||||
*
|
||||
* @Assert\NotNull
|
||||
*
|
||||
* @Serializer\Groups({"read", "write"})
|
||||
*/
|
||||
#[Assert\NotNull]
|
||||
#[Serializer\Groups(['read', 'write'])]
|
||||
#[ORM\ManyToOne(targetEntity: Relation::class)]
|
||||
#[ORM\JoinColumn(nullable: false, name: 'relation_id', referencedColumnName: 'id')]
|
||||
private ?Relation $relation = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*
|
||||
* @Assert\Type(
|
||||
* type="bool",
|
||||
* message="This must be of type boolean"
|
||||
* )
|
||||
*
|
||||
* @Serializer\Groups({"read", "write"})
|
||||
*/
|
||||
#[Assert\Type(type: 'bool', message: 'This must be of type boolean')]
|
||||
#[Serializer\Groups(['read', 'write'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
|
||||
private bool $reverse;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Person::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*
|
||||
* @Assert\NotNull
|
||||
*
|
||||
* @Serializer\Groups({"read", "write"})
|
||||
*/
|
||||
#[Assert\NotNull]
|
||||
#[Serializer\Groups(['read', 'write'])]
|
||||
#[ORM\ManyToOne(targetEntity: Person::class)]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?Person $toPerson = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable", nullable=true)
|
||||
*/
|
||||
private ?\DateTimeImmutable $updatedAt = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
*/
|
||||
private ?User $updatedBy = null;
|
||||
|
||||
public function getCreatedAt(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
public function getCreatedBy(): ?User
|
||||
{
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
||||
public function getFromPerson(): ?Person
|
||||
{
|
||||
return $this->fromPerson;
|
||||
@@ -178,30 +115,6 @@ class Relationship implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this->toPerson;
|
||||
}
|
||||
|
||||
public function getUpdatedAt(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
public function getUpdatedBy(): ?User
|
||||
{
|
||||
return $this->updatedBy;
|
||||
}
|
||||
|
||||
public function setCreatedAt(\DateTimeInterface $createdAt): self
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCreatedBy(?User $user): self
|
||||
{
|
||||
$this->createdBy = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setFromPerson(?Person $fromPerson): self
|
||||
{
|
||||
$this->fromPerson = $fromPerson;
|
||||
@@ -229,18 +142,4 @@ class Relationship implements TrackCreationInterface, TrackUpdateInterface
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
|
||||
{
|
||||
$this->updatedAt = $updatedAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setUpdatedBy(?User $updatedBy): self
|
||||
{
|
||||
$this->updatedBy = $updatedBy;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@@ -11,77 +11,46 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Entity\SocialWork;
|
||||
|
||||
use DateInterval;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(name="chill_person_social_work_evaluation")
|
||||
*
|
||||
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "social_work_evaluation": Evaluation::class
|
||||
* })
|
||||
*/
|
||||
#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['social_work_evaluation' => Evaluation::class])]
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'chill_person_social_work_evaluation')]
|
||||
class Evaluation
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(type="boolean", nullable=false, options={"default": true})
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, nullable: false, options: ['default' => true])]
|
||||
private bool $active = true;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="dateinterval", nullable=true, options={"default": null})
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATEINTERVAL, nullable: true, options: ['default' => null])]
|
||||
private ?\DateInterval $delay = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="dateinterval", nullable=true, options={"default": null})
|
||||
*
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATEINTERVAL, nullable: true, options: ['default' => null])]
|
||||
private ?\DateInterval $notificationDelay = null;
|
||||
|
||||
/**
|
||||
* @var Collection<SocialAction>
|
||||
*
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity=SocialAction::class,
|
||||
* mappedBy="evaluations"
|
||||
* )
|
||||
* @var \Doctrine\Common\Collections\Collection<int, \Chill\PersonBundle\Entity\SocialWork\SocialAction>
|
||||
*/
|
||||
#[ORM\ManyToMany(targetEntity: SocialAction::class, mappedBy: 'evaluations')]
|
||||
private Collection $socialActions;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*
|
||||
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)]
|
||||
#[Serializer\Context(['is-translatable' => true], groups: ['docgen:read'])]
|
||||
private array $title = [];
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text", nullable=true)
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: true)]
|
||||
private ?string $url = null;
|
||||
|
||||
public function __construct()
|
||||
|
@@ -16,59 +16,36 @@ use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(name="chill_person_social_work_goal")
|
||||
*
|
||||
* @Serializer\DiscriminatorMap(
|
||||
* typeProperty="type",
|
||||
* mapping={
|
||||
* "social_work_goal": Goal::class
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['social_work_goal' => Goal::class])]
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'chill_person_social_work_goal')]
|
||||
class Goal
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true)
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE, nullable: true)]
|
||||
private ?\DateTimeInterface $desactivationDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @var Collection<Result>
|
||||
*
|
||||
* @ORM\ManyToMany(targetEntity=Result::class, inversedBy="goals")
|
||||
*
|
||||
* @ORM\JoinTable(name="chill_person_social_work_goal_result")
|
||||
* @var Collection<int, Result>
|
||||
*/
|
||||
#[ORM\ManyToMany(targetEntity: Result::class, inversedBy: 'goals')]
|
||||
#[ORM\JoinTable(name: 'chill_person_social_work_goal_result')]
|
||||
private Collection $results;
|
||||
|
||||
/**
|
||||
* @var Collection<SocialAction>
|
||||
*
|
||||
* @ORM\ManyToMany(targetEntity=SocialAction::class, mappedBy="goals")
|
||||
* @var Collection<int, SocialAction>
|
||||
*/
|
||||
#[ORM\ManyToMany(targetEntity: SocialAction::class, mappedBy: 'goals')]
|
||||
private Collection $socialActions;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*
|
||||
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)]
|
||||
#[Serializer\Context(['is-translatable' => true], groups: ['docgen:read'])]
|
||||
private array $title = [];
|
||||
|
||||
public function __construct()
|
||||
|
@@ -13,77 +13,52 @@ namespace Chill\PersonBundle\Entity\SocialWork;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkGoal;
|
||||
use DateTime;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(name="chill_person_social_work_result")
|
||||
*
|
||||
* @Serializer\DiscriminatorMap(
|
||||
* typeProperty="type",
|
||||
* mapping={
|
||||
* "social_work_result": Result::class
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['social_work_result' => Result::class])]
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'chill_person_social_work_result')]
|
||||
class Result
|
||||
{
|
||||
/**
|
||||
* @var Collection<AccompanyingPeriodWorkGoal>
|
||||
*
|
||||
* @ORM\ManyToMany(targetEntity=AccompanyingPeriodWorkGoal::class, mappedBy="results")
|
||||
* @var Collection<int, AccompanyingPeriodWorkGoal>
|
||||
*/
|
||||
#[ORM\ManyToMany(targetEntity: AccompanyingPeriodWorkGoal::class, mappedBy: 'results')]
|
||||
private Collection $accompanyingPeriodWorkGoals;
|
||||
|
||||
/**
|
||||
* @var Collection<AccompanyingPeriodWork>
|
||||
*
|
||||
* @ORM\ManyToMany(targetEntity=AccompanyingPeriodWork::class, mappedBy="results")
|
||||
* @var Collection<int, AccompanyingPeriodWork>
|
||||
*/
|
||||
#[ORM\ManyToMany(targetEntity: AccompanyingPeriodWork::class, mappedBy: 'results')]
|
||||
private Collection $accompanyingPeriodWorks;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true)
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE, nullable: true)]
|
||||
private ?\DateTime $desactivationDate = null;
|
||||
|
||||
/**
|
||||
* @var Collection<Goal>
|
||||
*
|
||||
* @ORM\ManyToMany(targetEntity=Goal::class, mappedBy="results")
|
||||
* @var Collection<int, Goal>
|
||||
*/
|
||||
#[ORM\ManyToMany(targetEntity: Goal::class, mappedBy: 'results')]
|
||||
private Collection $goals;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @var Collection<SocialAction>
|
||||
*
|
||||
* @ORM\ManyToMany(targetEntity=SocialAction::class, mappedBy="results")
|
||||
* @var Collection<int, SocialAction>
|
||||
*/
|
||||
#[ORM\ManyToMany(targetEntity: SocialAction::class, mappedBy: 'results')]
|
||||
private Collection $socialActions;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*
|
||||
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
|
||||
*/
|
||||
#[Serializer\Groups(['read', 'docgen:read'])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)]
|
||||
#[Serializer\Context(['is-translatable' => true], groups: ['docgen:read'])]
|
||||
private array $title = [];
|
||||
|
||||
public function __construct()
|
||||
|
@@ -11,98 +11,65 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Entity\SocialWork;
|
||||
|
||||
use DateInterval;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\ReadableCollection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(name="chill_person_social_action")
|
||||
*
|
||||
* @Serializer\DiscriminatorMap(
|
||||
* typeProperty="type",
|
||||
* mapping={
|
||||
* "social_work_social_action": SocialAction::class
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['social_work_social_action' => SocialAction::class])]
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'chill_person_social_action')]
|
||||
class SocialAction
|
||||
{
|
||||
/**
|
||||
* @var Collection<SocialAction>
|
||||
*
|
||||
* @ORM\OneToMany(targetEntity=SocialAction::class, mappedBy="parent")
|
||||
* @var Collection<int, SocialAction>
|
||||
*/
|
||||
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: SocialAction::class)]
|
||||
private Collection $children;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="dateinterval", nullable=true)
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATEINTERVAL, nullable: true)]
|
||||
private ?\DateInterval $defaultNotificationDelay = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true)
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE, nullable: true)]
|
||||
private ?\DateTimeInterface $desactivationDate = null;
|
||||
|
||||
/**
|
||||
* @var Collection<Evaluation>
|
||||
*
|
||||
* @ORM\ManyToMany(targetEntity=Evaluation::class, inversedBy="socialActions")
|
||||
*
|
||||
* @ORM\JoinTable(name="chill_person_social_work_evaluation_action")
|
||||
* @var Collection<int, Evaluation>
|
||||
*/
|
||||
#[ORM\ManyToMany(targetEntity: Evaluation::class, inversedBy: 'socialActions')]
|
||||
#[ORM\JoinTable(name: 'chill_person_social_work_evaluation_action')]
|
||||
private Collection $evaluations;
|
||||
|
||||
/**
|
||||
* @var Collection<Goal>
|
||||
*
|
||||
* @ORM\ManyToMany(targetEntity=Goal::class, inversedBy="socialActions")
|
||||
*
|
||||
* @ORM\JoinTable(name="chill_person_social_action_goal")
|
||||
* @var Collection<int, Goal>
|
||||
*/
|
||||
#[ORM\ManyToMany(targetEntity: Goal::class, inversedBy: 'socialActions')]
|
||||
#[ORM\JoinTable(name: 'chill_person_social_action_goal')]
|
||||
private Collection $goals;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=SocialIssue::class, inversedBy="socialActions")
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: SocialIssue::class, inversedBy: 'socialActions')]
|
||||
private ?SocialIssue $issue = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="float", name="ordering", options={"default": 0.0})
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT, name: 'ordering', options: ['default' => '0.0'])]
|
||||
private float $ordering = 0.0;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=SocialAction::class, inversedBy="children")
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: SocialAction::class, inversedBy: 'children')]
|
||||
private ?SocialAction $parent = null;
|
||||
|
||||
/**
|
||||
* @var Collection<Result>
|
||||
*
|
||||
* @ORM\ManyToMany(targetEntity=Result::class, inversedBy="socialActions")
|
||||
*
|
||||
* @ORM\JoinTable(name="chill_person_social_action_result")
|
||||
* @var Collection<int, Result>
|
||||
*/
|
||||
#[ORM\ManyToMany(targetEntity: Result::class, inversedBy: 'socialActions')]
|
||||
#[ORM\JoinTable(name: 'chill_person_social_action_result')]
|
||||
private Collection $results;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json")
|
||||
*/
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)]
|
||||
private array $title = [];
|
||||
|
||||
public function __construct()
|
||||
|
@@ -13,64 +13,44 @@ namespace Chill\PersonBundle\Entity\SocialWork;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(name="chill_person_social_issue")
|
||||
*
|
||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "social_issue": SocialIssue::class
|
||||
* })
|
||||
*/
|
||||
#[DiscriminatorMap(typeProperty: 'type', mapping: ['social_issue' => SocialIssue::class])]
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'chill_person_social_issue')]
|
||||
class SocialIssue
|
||||
{
|
||||
/**
|
||||
* @var Collection<SocialIssue>
|
||||
*
|
||||
* @ORM\OneToMany(targetEntity=SocialIssue::class, mappedBy="parent")
|
||||
* @var Collection<int, SocialIssue>
|
||||
*/
|
||||
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: SocialIssue::class)]
|
||||
private Collection $children;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true)
|
||||
*/
|
||||
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
|
||||
private ?\DateTimeInterface $desactivationDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: Types::INTEGER)]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="float", name="ordering", options={"default": 0.0})
|
||||
*/
|
||||
#[ORM\Column(name: 'ordering', type: Types::FLOAT, options: ['default' => '0.0'])]
|
||||
private float $ordering = 0.0;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=SocialIssue::class, inversedBy="children")
|
||||
*/
|
||||
#[ORM\ManyToOne(targetEntity: SocialIssue::class, inversedBy: 'children')]
|
||||
private ?SocialIssue $parent = null;
|
||||
|
||||
/**
|
||||
* @var Collection<SocialAction>
|
||||
*
|
||||
* @ORM\OneToMany(targetEntity=SocialAction::class, mappedBy="issue")
|
||||
* @var Collection<int, SocialAction>
|
||||
*/
|
||||
#[ORM\OneToMany(mappedBy: 'issue', targetEntity: SocialAction::class)]
|
||||
private Collection $socialActions;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json")
|
||||
*
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
#[Groups(['read'])]
|
||||
#[ORM\Column(type: Types::JSON)]
|
||||
private array $title = [];
|
||||
|
||||
public function __construct()
|
||||
|
@@ -29,9 +29,7 @@ class PersonAddressMoveEvent extends Event
|
||||
|
||||
private ?HouseholdMember $previousMembership = null;
|
||||
|
||||
public function __construct(private readonly Person $person)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly Person $person) {}
|
||||
|
||||
/**
|
||||
* Get the date of the move.
|
||||
|
@@ -17,9 +17,7 @@ use Symfony\Component\Security\Core\Security;
|
||||
|
||||
class AccompanyingPeriodWorkEventListener
|
||||
{
|
||||
public function __construct(private readonly Security $security)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly Security $security) {}
|
||||
|
||||
public function prePersistAccompanyingPeriodWork(AccompanyingPeriodWork $work): void
|
||||
{
|
||||
|
@@ -20,9 +20,7 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class AdministrativeLocationAggregator implements AggregatorInterface
|
||||
{
|
||||
public function __construct(private readonly LocationRepository $locationRepository, private readonly TranslatableStringHelper $translatableStringHelper)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly LocationRepository $locationRepository, private readonly TranslatableStringHelper $translatableStringHelper) {}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
|
@@ -20,9 +20,7 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class ClosingMotiveAggregator implements AggregatorInterface
|
||||
{
|
||||
public function __construct(private readonly ClosingMotiveRepositoryInterface $motiveRepository, private readonly TranslatableStringHelper $translatableStringHelper)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly ClosingMotiveRepositoryInterface $motiveRepository, private readonly TranslatableStringHelper $translatableStringHelper) {}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
|
@@ -19,9 +19,7 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class ConfidentialAggregator implements AggregatorInterface
|
||||
{
|
||||
public function __construct(private readonly TranslatorInterface $translator)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly TranslatorInterface $translator) {}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
|
@@ -27,8 +27,7 @@ class CreatorJobAggregator implements AggregatorInterface
|
||||
public function __construct(
|
||||
private readonly UserJobRepository $jobRepository,
|
||||
private readonly TranslatableStringHelper $translatableStringHelper,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
@@ -79,9 +78,7 @@ class CreatorJobAggregator implements AggregatorInterface
|
||||
return Declarations::ACP_TYPE;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
}
|
||||
public function buildForm(FormBuilderInterface $builder) {}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
|
@@ -26,9 +26,7 @@ final readonly class DurationAggregator implements AggregatorInterface
|
||||
'day',
|
||||
];
|
||||
|
||||
public function __construct(private TranslatorInterface $translator)
|
||||
{
|
||||
}
|
||||
public function __construct(private TranslatorInterface $translator) {}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
|
@@ -19,9 +19,7 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class EmergencyAggregator implements AggregatorInterface
|
||||
{
|
||||
public function __construct(private readonly TranslatorInterface $translator)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly TranslatorInterface $translator) {}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user