mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-02-28 02:59:40 +00:00
# Conflicts: # docs/source/_static/code/exports/BirthdateFilter.php # rector.php # src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/ByActivityTypeAggregator.php # src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialActionAggregator.php # src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/BySocialIssueAggregator.php # src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityLocationAggregator.php # src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityPresenceAggregator.php # src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityReasonAggregator.php # src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php # src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUserAggregator.php # src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersAggregator.php # src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersJobAggregator.php # src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityUsersScopeAggregator.php # src/Bundle/ChillActivityBundle/Export/Aggregator/ByCreatorAggregator.php # src/Bundle/ChillActivityBundle/Export/Aggregator/ByThirdpartyAggregator.php # src/Bundle/ChillActivityBundle/Export/Aggregator/CreatorJobAggregator.php # src/Bundle/ChillActivityBundle/Export/Aggregator/CreatorScopeAggregator.php # src/Bundle/ChillActivityBundle/Export/Aggregator/DateAggregator.php # src/Bundle/ChillActivityBundle/Export/Aggregator/LocationTypeAggregator.php # src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/HouseholdAggregator.php # src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/PersonAggregator.php # src/Bundle/ChillActivityBundle/Export/Aggregator/PersonsAggregator.php # src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php # src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php # src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php # src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialActionFilter.php # src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/BySocialIssueFilter.php # src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/HasNoActivityFilter.php # src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/PeriodHavingActivityBetweenDatesFilter.php # src/Bundle/ChillActivityBundle/Export/Filter/ActivityDateFilter.php # src/Bundle/ChillActivityBundle/Export/Filter/ActivityPresenceFilter.php # src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php # src/Bundle/ChillActivityBundle/Export/Filter/ActivityUsersFilter.php # src/Bundle/ChillActivityBundle/Export/Filter/ByCreatorFilter.php # src/Bundle/ChillActivityBundle/Export/Filter/CreatorJobFilter.php # src/Bundle/ChillActivityBundle/Export/Filter/CreatorScopeFilter.php # src/Bundle/ChillActivityBundle/Export/Filter/EmergencyFilter.php # src/Bundle/ChillActivityBundle/Export/Filter/LocationFilter.php # src/Bundle/ChillActivityBundle/Export/Filter/LocationTypeFilter.php # src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/ActivityReasonFilter.php # src/Bundle/ChillActivityBundle/Export/Filter/PersonsFilter.php # src/Bundle/ChillActivityBundle/Export/Filter/SentReceivedFilter.php # src/Bundle/ChillActivityBundle/Export/Filter/UserFilter.php # src/Bundle/ChillActivityBundle/Export/Filter/UsersJobFilter.php # src/Bundle/ChillActivityBundle/Export/Filter/UsersScopeFilter.php # src/Bundle/ChillActivityBundle/Validator/Constraints/ActivityValidity.php # src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByActivityTypeAggregator.php # src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserJobAggregator.php # src/Bundle/ChillAsideActivityBundle/src/Export/Aggregator/ByUserScopeAggregator.php # src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByActivityTypeFilter.php # src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByDateFilter.php # src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserFilter.php # src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserJobFilter.php # src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserScopeFilter.php # src/Bundle/ChillCalendarBundle/Export/Aggregator/AgentAggregator.php # src/Bundle/ChillCalendarBundle/Export/Aggregator/CancelReasonAggregator.php # src/Bundle/ChillCalendarBundle/Export/Aggregator/JobAggregator.php # src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationAggregator.php # src/Bundle/ChillCalendarBundle/Export/Aggregator/LocationTypeAggregator.php # src/Bundle/ChillCalendarBundle/Export/Aggregator/MonthYearAggregator.php # src/Bundle/ChillCalendarBundle/Export/Aggregator/ScopeAggregator.php # src/Bundle/ChillCalendarBundle/Export/Aggregator/UrgencyAggregator.php # src/Bundle/ChillCalendarBundle/Export/Filter/AgentFilter.php # src/Bundle/ChillCalendarBundle/Export/Filter/BetweenDatesFilter.php # src/Bundle/ChillCalendarBundle/Export/Filter/CalendarRangeFilter.php # src/Bundle/ChillCalendarBundle/Export/Filter/JobFilter.php # src/Bundle/ChillCalendarBundle/Export/Filter/ScopeFilter.php # src/Bundle/ChillEventBundle/Export/Aggregator/EventDateAggregator.php # src/Bundle/ChillEventBundle/Export/Aggregator/EventTypeAggregator.php # src/Bundle/ChillEventBundle/Export/Aggregator/RoleAggregator.php # src/Bundle/ChillEventBundle/Export/Filter/EventDateFilter.php # src/Bundle/ChillEventBundle/Export/Filter/EventTypeFilter.php # src/Bundle/ChillEventBundle/Export/Filter/RoleFilter.php # src/Bundle/ChillMainBundle/Controller/ExportController.php # src/Bundle/ChillMainBundle/Controller/SavedExportController.php # src/Bundle/ChillMainBundle/DependencyInjection/CompilerPass/ExportsCompilerPass.php # src/Bundle/ChillMainBundle/Entity/Notification.php # src/Bundle/ChillMainBundle/Export/ExportManager.php # src/Bundle/ChillMainBundle/Export/Formatter/CSVFormatter.php # src/Bundle/ChillMainBundle/Export/Formatter/CSVListFormatter.php # src/Bundle/ChillMainBundle/Export/Formatter/CSVPivotedListFormatter.php # src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php # src/Bundle/ChillMainBundle/Export/Formatter/SpreadsheetListFormatter.php # src/Bundle/ChillMainBundle/Form/SavedExportType.php # src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php # src/Bundle/ChillMainBundle/Tests/Export/ExportManagerTest.php # src/Bundle/ChillMainBundle/Tests/Export/SortExportElementTest.php # src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingDateAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/CreatorJobAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/JobWorkingOnCourseAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OpeningDateAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/PersonParticipatingAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerScopeAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeWorkingOnCourseAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserWorkingOnCourseAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingPeriodStepHistoryAggregators/ByClosingMotiveAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingPeriodStepHistoryAggregators/ByDateAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingPeriodStepHistoryAggregators/ByStepAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByEndDateAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByMaxDateAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/ByStartDateAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/HavingEndDateAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/HouseholdAggregators/CompositionAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AdministrativeStatusAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/AgeAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/ByHouseholdCompositionAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/CenterAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/EmploymentStatusAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/GenderAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/HouseholdPositionAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/NationalityAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/PostalCodeAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorJobAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorScopeAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalResultAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/HandlingThirdPartyAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php # src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php # src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOnDateFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/AdministrativeLocationFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ClosingMotiveFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ConfidentialFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/CreatorJobFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EmergencyFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/EvaluationFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/GeographicalUnitStatFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HandlingThirdPartyFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasNoReferrerFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/HasTemporaryLocationFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/IntensityFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/NotAssociatedWithAReferenceAddressFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OriginFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ReferrerFilterBetweenDates.php # src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialActionFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/SocialIssueFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilterBetweenDates.php # src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/StepFilterOnDate.php # src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserJobFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingPeriodStepHistoryFilters/ByDateFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingPeriodStepHistoryFilters/ByStepFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/EvaluationTypeFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/MaxDateFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AddressRefStatusFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AgeFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/BirthdateFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ByHouseholdCompositionFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeadOrAliveFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/DeathdateFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GenderFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/GeographicalUnitFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/MaritalStatusFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/NationalityFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/ResidentialAddressAtUserFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/WithParticipationBetweenDatesFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/WithoutHouseholdComposition.php # src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/WithoutParticipationBetweenDatesFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorJobFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorScopeFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/JobFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ReferrerFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/ScopeFilter.php # src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/SocialWorkTypeFilter.php # src/Bundle/ChillPersonBundle/Export/Helper/FilterListAccompanyingPeriodHelper.php # src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php # src/Bundle/ChillPersonBundle/Tests/Export/Export/ListAccompanyingPeriodTest.php # src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidity.php # src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/ConfidentialCourseMustHaveReferrer.php # src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/LocationValidity.php # src/Bundle/ChillPersonBundle/Validator/Constraints/Household/MaxHolder.php # src/Bundle/ChillReportBundle/Export/Export/ReportList.php # src/Bundle/ChillReportBundle/Export/Filter/ReportDateFilter.php
386 lines
15 KiB
PHP
386 lines
15 KiB
PHP
<?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;
|
|
use Chill\MainBundle\Entity\Scope;
|
|
use Chill\MainBundle\Entity\User;
|
|
use Chill\MainBundle\Serializer\Model\Collection;
|
|
use Chill\MainBundle\Serializer\Model\Counter;
|
|
use Chill\MainBundle\Serializer\Normalizer\DiscriminatedObjectDenormalizer;
|
|
use Chill\PersonBundle\AccompanyingPeriod\Suggestion\ReferralsSuggestionInterface;
|
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
|
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
|
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\Resource;
|
|
use Chill\PersonBundle\Entity\Person;
|
|
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
|
use Chill\PersonBundle\Privacy\AccompanyingPeriodPrivacyEvent;
|
|
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
|
|
use Chill\PersonBundle\Repository\AccompanyingPeriodRepository;
|
|
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
|
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
|
use Doctrine\Persistence\ManagerRegistry;
|
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
|
use Symfony\Component\Routing\Annotation\Route;
|
|
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
|
use Symfony\Component\Serializer\Exception\RuntimeException;
|
|
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
|
use Symfony\Component\Serializer\SerializerInterface;
|
|
use Symfony\Component\Validator\ConstraintViolationList;
|
|
use Symfony\Component\Validator\ConstraintViolationListInterface;
|
|
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
|
use Symfony\Component\Workflow\Registry;
|
|
|
|
final class AccompanyingCourseApiController extends ApiController
|
|
{
|
|
public function __construct(
|
|
private readonly AccompanyingPeriodRepository $accompanyingPeriodRepository,
|
|
private readonly EventDispatcherInterface $eventDispatcher,
|
|
private readonly ReferralsSuggestionInterface $referralAvailable,
|
|
private readonly Registry $registry,
|
|
private readonly ValidatorInterface $validator,
|
|
private readonly AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository,
|
|
) {
|
|
}
|
|
|
|
public function commentApi($id, Request $request, string $_format): Response
|
|
{
|
|
return $this->addRemoveSomething('comment', $id, $request, $_format, 'comment', Comment::class);
|
|
}
|
|
|
|
public function confirmApi($id, Request $request, $_format): Response
|
|
{
|
|
/** @var AccompanyingPeriod $accompanyingPeriod */
|
|
$accompanyingPeriod = $this->getEntity('participation', $id, $request);
|
|
|
|
$this->checkACL('confirm', $request, $_format, $accompanyingPeriod);
|
|
$workflow = $this->registry->get($accompanyingPeriod);
|
|
|
|
if (false === $workflow->can($accompanyingPeriod, 'confirm')) {
|
|
// throw new BadRequestException('It is not possible to confirm this period');
|
|
$errors = $this->validator->validate($accompanyingPeriod, null, [$accompanyingPeriod::STEP_CONFIRMED]);
|
|
|
|
if (\count($errors) > 0) {
|
|
return $this->json($errors, 422);
|
|
}
|
|
}
|
|
|
|
$workflow->apply($accompanyingPeriod, 'confirm');
|
|
|
|
$this->managerRegistry->getManager()->flush();
|
|
|
|
return $this->json($accompanyingPeriod, Response::HTTP_OK, [], [
|
|
'groups' => ['read'],
|
|
]);
|
|
}
|
|
|
|
#[\Symfony\Component\Routing\Attribute\Route(path: '/api/1.0/person/accompanying-course/list/by-recent-attributions')]
|
|
public function findMyRecentCourseAttribution(Request $request): JsonResponse
|
|
{
|
|
$this->denyAccessUnlessGranted('ROLE_USER');
|
|
$user = $this->getUser();
|
|
|
|
if (!$user instanceof User) {
|
|
throw new AccessDeniedException();
|
|
}
|
|
|
|
$since = (new \DateTimeImmutable('now'))->sub(new \DateInterval('P15D'));
|
|
|
|
$total = $this->accompanyingPeriodRepository->countByRecentUserHistory($user, $since);
|
|
|
|
if ($request->query->getBoolean('countOnly', false)) {
|
|
return new JsonResponse(
|
|
$this->serializer->serialize(new Counter($total), 'json'),
|
|
JsonResponse::HTTP_OK,
|
|
[],
|
|
true
|
|
);
|
|
}
|
|
|
|
$paginator = $this->getPaginatorFactory()->create($total);
|
|
|
|
if (0 === $total) {
|
|
return new JsonResponse(
|
|
$this->serializer->serialize(new Collection([], $paginator), 'json'),
|
|
JsonResponse::HTTP_OK,
|
|
[],
|
|
true
|
|
);
|
|
}
|
|
|
|
$courses = $this->accompanyingPeriodRepository->findByRecentUserHistory(
|
|
$user,
|
|
$since,
|
|
$paginator->getItemsPerPage(),
|
|
$paginator->getCurrentPageFirstItemNumber()
|
|
);
|
|
|
|
return new JsonResponse(
|
|
$this->serializer->serialize(new Collection($courses, $paginator), 'json', ['groups' => ['read']]),
|
|
JsonResponse::HTTP_OK,
|
|
[],
|
|
true
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @ParamConverter("person", options={"id": "person_id"})
|
|
*/
|
|
public function getAccompanyingPeriodsByPerson(Person $person): \Symfony\Component\HttpFoundation\JsonResponse
|
|
{
|
|
$accompanyingPeriods = $person->getCurrentAccompanyingPeriods();
|
|
$accompanyingPeriodsChecked = array_filter(
|
|
$accompanyingPeriods,
|
|
fn (AccompanyingPeriod $period) => $this->isGranted(AccompanyingPeriodVoter::SEE, $period)
|
|
);
|
|
|
|
return $this->json(\array_values($accompanyingPeriodsChecked), Response::HTTP_OK, [], ['groups' => ['read']]);
|
|
}
|
|
|
|
public function participationApi($id, Request $request, $_format): \Symfony\Component\HttpFoundation\JsonResponse
|
|
{
|
|
/** @var AccompanyingPeriod $accompanyingPeriod */
|
|
$accompanyingPeriod = $this->getEntity('participation', $id, $request);
|
|
$person = $this->serializer
|
|
->deserialize($request->getContent(), Person::class, $_format, []);
|
|
|
|
if (null === $person) {
|
|
throw new BadRequestHttpException('person id not found');
|
|
}
|
|
|
|
// TODO add acl
|
|
//
|
|
$this->onPostCheckACL('participation', $request, $_format, $accompanyingPeriod);
|
|
|
|
$participation = match ($request->getMethod()) {
|
|
Request::METHOD_POST => $accompanyingPeriod->createParticipationFor($person),
|
|
Request::METHOD_DELETE => $accompanyingPeriod->closeParticipationFor($person),
|
|
default => throw new BadRequestHttpException('This method is not supported'),
|
|
};
|
|
|
|
$errors = $this->validator->validate($accompanyingPeriod);
|
|
|
|
if ($errors->count() > 0) {
|
|
// only format accepted
|
|
return $this->json($errors, 422);
|
|
}
|
|
|
|
$this->managerRegistry->getManager()->flush();
|
|
|
|
return $this->json($participation, 200, [], ['groups' => ['read']]);
|
|
}
|
|
|
|
public function requestorApi($id, Request $request, string $_format): Response
|
|
{
|
|
/** @var AccompanyingPeriod $accompanyingPeriod */
|
|
$action = 'requestor';
|
|
$accompanyingPeriod = $this->getEntity($action, $id, $request);
|
|
// a requestor may be a person or a thirdParty
|
|
|
|
$this->checkACL($action, $request, $_format, $accompanyingPeriod);
|
|
$this->onPostCheckACL($action, $request, $_format, $accompanyingPeriod);
|
|
|
|
if (Request::METHOD_DELETE === $request->getMethod()) {
|
|
$accompanyingPeriod->setRequestor(null);
|
|
} elseif (Request::METHOD_POST === $request->getMethod()) {
|
|
$requestor = null;
|
|
$exceptions = [];
|
|
|
|
try {
|
|
$requestor = $this->serializer->deserialize(
|
|
$request->getContent(),
|
|
'@multi',
|
|
$_format,
|
|
[DiscriminatedObjectDenormalizer::ALLOWED_TYPES => [Person::class, ThirdParty::class]]
|
|
);
|
|
} catch (RuntimeException $e) {
|
|
$exceptions[] = $e;
|
|
}
|
|
|
|
if (null === $requestor) {
|
|
throw new BadRequestHttpException('Could not find any person or thirdparty');
|
|
}
|
|
|
|
$accompanyingPeriod->setRequestor($requestor);
|
|
} else {
|
|
throw new BadRequestHttpException('method not supported');
|
|
}
|
|
|
|
$errors = $this->validator->validate($accompanyingPeriod);
|
|
|
|
if ($errors->count() > 0) {
|
|
// only format accepted
|
|
return $this->json($errors, 422);
|
|
}
|
|
|
|
$this->managerRegistry->getManager()->flush();
|
|
|
|
return $this->json($accompanyingPeriod->getRequestor(), 200, [], ['groups' => ['read']]);
|
|
}
|
|
|
|
public function resourceApi($id, Request $request, string $_format): Response
|
|
{
|
|
$accompanyingPeriod = $this->getEntity('resource', $id, $request);
|
|
$errors = $this->validator->validate($accompanyingPeriod);
|
|
|
|
if ($errors->count() > 0) {
|
|
return $this->json($errors, 422);
|
|
}
|
|
|
|
return $this->addRemoveSomething('resource', $id, $request, $_format, 'resource', Resource::class);
|
|
}
|
|
|
|
public function scopeApi($id, Request $request, string $_format): Response
|
|
{
|
|
return $this->addRemoveSomething('scope', $id, $request, $_format, 'scope', Scope::class, ['groups' => ['read']]);
|
|
}
|
|
|
|
public function socialIssueApi($id, Request $request, string $_format): Response
|
|
{
|
|
return $this->addRemoveSomething('socialissue', $id, $request, $_format, 'socialIssue', SocialIssue::class, ['groups' => ['read']]);
|
|
}
|
|
|
|
#[\Symfony\Component\Routing\Attribute\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);
|
|
|
|
$total = $this->referralAvailable->countReferralSuggested($period);
|
|
$paginator = $this->getPaginatorFactory()->create($total);
|
|
|
|
if (0 < $total) {
|
|
$users = $this->referralAvailable->findReferralSuggested(
|
|
$period,
|
|
$paginator->getItemsPerPage(),
|
|
$paginator->getCurrentPageFirstItemNumber()
|
|
);
|
|
} else {
|
|
$users = [];
|
|
}
|
|
|
|
return $this->json(
|
|
new Collection($users, $paginator),
|
|
Response::HTTP_OK,
|
|
[],
|
|
[AbstractNormalizer::GROUPS => ['read']]
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @ParamConverter("accompanyingCourse", options={"id": "id"})
|
|
*/
|
|
#[\Symfony\Component\Routing\Attribute\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): \Symfony\Component\HttpFoundation\JsonResponse
|
|
{
|
|
if ('POST' === $request->getMethod()) {
|
|
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::TOGGLE_CONFIDENTIAL, $accompanyingCourse);
|
|
|
|
$accompanyingCourse->setConfidential(!$accompanyingCourse->isConfidential());
|
|
|
|
$this->managerRegistry->getManager()->flush();
|
|
}
|
|
|
|
return $this->json($accompanyingCourse->isConfidential(), Response::HTTP_OK, [], ['groups' => ['read']]);
|
|
}
|
|
|
|
/**
|
|
* @ParamConverter("accompanyingCourse", options={"id": "id"})
|
|
*/
|
|
#[\Symfony\Component\Routing\Attribute\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): \Symfony\Component\HttpFoundation\JsonResponse
|
|
{
|
|
if ('POST' === $request->getMethod()) {
|
|
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::TOGGLE_INTENSITY, $accompanyingCourse);
|
|
|
|
$status = 'regular' === $accompanyingCourse->getIntensity() ? 'occasional' : 'regular';
|
|
$accompanyingCourse->setIntensity($status);
|
|
$this->managerRegistry->getManager()->flush();
|
|
}
|
|
|
|
return $this->json($accompanyingCourse->getIntensity(), Response::HTTP_OK, [], ['groups' => ['read']]);
|
|
}
|
|
|
|
/**
|
|
* @ParamConverter("accompanyingPeriod", options={"id": "id"})
|
|
*/
|
|
#[\Symfony\Component\Routing\Attribute\Route(path: '/api/1.0/person/accompanying-course/{id}/works.json', name: 'chill_api_person_accompanying_period_works')]
|
|
public function worksByAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): JsonResponse
|
|
{
|
|
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::SEE, $accompanyingPeriod);
|
|
|
|
$total = $this->accompanyingPeriodWorkRepository->countByAccompanyingPeriod($accompanyingPeriod);
|
|
$paginator = $this->getPaginatorFactory()->create($total);
|
|
|
|
$works = $this->accompanyingPeriodWorkRepository->findByAccompanyingPeriodOpenFirst(
|
|
$accompanyingPeriod,
|
|
[
|
|
'types' => [],
|
|
'before' => null,
|
|
'after' => null,
|
|
'user' => [],
|
|
],
|
|
$paginator->getItemsPerPage(),
|
|
$paginator->getCurrentPageFirstItemNumber()
|
|
);
|
|
|
|
$collection = new Collection($works, $paginator);
|
|
|
|
return $this->json($collection, Response::HTTP_OK, [], ['groups' => ['read']]);
|
|
}
|
|
|
|
public function workApi($id, Request $request, string $_format): Response
|
|
{
|
|
return $this->addRemoveSomething(
|
|
'work',
|
|
$id,
|
|
$request,
|
|
$_format,
|
|
'work',
|
|
AccompanyingPeriodWork::class,
|
|
['groups' => ['accompanying_period_work:create']],
|
|
true // force persist
|
|
);
|
|
}
|
|
|
|
protected function onPostCheckACL(string $action, Request $request, string $_format, $entity): ?Response
|
|
{
|
|
$this->eventDispatcher->dispatch(
|
|
new AccompanyingPeriodPrivacyEvent($entity, [
|
|
'action' => $action,
|
|
'request' => $request->getMethod(),
|
|
]),
|
|
AccompanyingPeriodPrivacyEvent::ACCOMPANYING_PERIOD_PRIVACY_EVENT
|
|
);
|
|
|
|
return null;
|
|
}
|
|
|
|
protected function validate(string $action, Request $request, string $_format, $entity, array $more = []): ConstraintViolationListInterface
|
|
{
|
|
if ('work' !== $action) {
|
|
return parent::validate($action, $request, $_format, $entity, $more);
|
|
}
|
|
|
|
if (Request::METHOD_POST === $request->getMethod()) {
|
|
return $this->getValidator()->validate($more[0], null);
|
|
}
|
|
|
|
return new ConstraintViolationList([]);
|
|
}
|
|
}
|