mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 18:43:49 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -66,8 +66,8 @@ class AzureGrantAdminConsentAndAcquireToken extends Command
|
||||
|
||||
$output->writeln('Token information:');
|
||||
$output->writeln($token->getToken());
|
||||
$output->writeln('Expires at: ' . $token->getExpires());
|
||||
$output->writeln('To inspect the token content, go to https://jwt.ms/#access_token=' . urlencode($token->getToken()));
|
||||
$output->writeln('Expires at: '.$token->getExpires());
|
||||
$output->writeln('To inspect the token content, go to https://jwt.ms/#access_token='.urlencode($token->getToken()));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -21,11 +21,8 @@ namespace Chill\CalendarBundle\Command;
|
||||
use Chill\CalendarBundle\Exception\UserAbsenceSyncException;
|
||||
use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\EventsOnUserSubscriptionCreator;
|
||||
use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\MapCalendarToUser;
|
||||
use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\MSGraphUserRepository;
|
||||
use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\MSUserAbsenceSync;
|
||||
use Chill\MainBundle\Repository\UserRepositoryInterface;
|
||||
use DateInterval;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
@@ -48,19 +45,19 @@ final class MapAndSubscribeUserCalendarCommand extends Command
|
||||
|
||||
public function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$this->logger->info(self::class . ' execute command');
|
||||
$this->logger->info(self::class.' execute command');
|
||||
|
||||
$limit = 50;
|
||||
$offset = 0;
|
||||
/** @var DateInterval $interval the interval before the end of the expiration */
|
||||
$interval = new DateInterval('P1D');
|
||||
$expiration = (new DateTimeImmutable('now'))->add(new DateInterval($input->getOption('subscription-duration')));
|
||||
/** @var \DateInterval $interval the interval before the end of the expiration */
|
||||
$interval = new \DateInterval('P1D');
|
||||
$expiration = (new \DateTimeImmutable('now'))->add(new \DateInterval($input->getOption('subscription-duration')));
|
||||
$users = $this->userRepository->findAllAsArray('fr');
|
||||
$created = 0;
|
||||
$renewed = 0;
|
||||
|
||||
$this->logger->info(self::class . ' start user to get - renew', [
|
||||
'expiration' => $expiration->format(DateTimeImmutable::ATOM),
|
||||
$this->logger->info(self::class.' start user to get - renew', [
|
||||
'expiration' => $expiration->format(\DateTimeImmutable::ATOM),
|
||||
]);
|
||||
|
||||
foreach ($users as $u) {
|
||||
@@ -73,8 +70,8 @@ final class MapAndSubscribeUserCalendarCommand extends Command
|
||||
$user = $this->userRepository->find($u['id']);
|
||||
|
||||
if (null === $user) {
|
||||
$this->logger->error("could not find user by id", ['uid' => $u['id']]);
|
||||
$output->writeln("could not find user by id : " . $u['id']);
|
||||
$this->logger->error('could not find user by id', ['uid' => $u['id']]);
|
||||
$output->writeln('could not find user by id : '.$u['id']);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -83,8 +80,8 @@ final class MapAndSubscribeUserCalendarCommand extends Command
|
||||
|
||||
// if user still does not have userid, continue
|
||||
if (!$this->mapCalendarToUser->hasUserId($user)) {
|
||||
$this->logger->warning("user does not have a counterpart on ms api", ['userId' => $user->getId(), 'email' => $user->getEmail()]);
|
||||
$output->writeln(sprintf("giving up for user with email %s and id %s", $user->getEmail(), $user->getId()));
|
||||
$this->logger->warning('user does not have a counterpart on ms api', ['userId' => $user->getId(), 'email' => $user->getEmail()]);
|
||||
$output->writeln(sprintf('giving up for user with email %s and id %s', $user->getEmail(), $user->getId()));
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -94,15 +91,15 @@ final class MapAndSubscribeUserCalendarCommand extends Command
|
||||
try {
|
||||
$this->userAbsenceSync->syncUserAbsence($user);
|
||||
} catch (UserAbsenceSyncException $e) {
|
||||
$this->logger->error("could not sync user absence", ['userId' => $user->getId(), 'email' => $user->getEmail(), 'exception' => $e->getTraceAsString(), "message" => $e->getMessage()]);
|
||||
$output->writeln(sprintf("Could not sync user absence: id: %s and email: %s", $user->getId(), $user->getEmail()));
|
||||
$this->logger->error('could not sync user absence', ['userId' => $user->getId(), 'email' => $user->getEmail(), 'exception' => $e->getTraceAsString(), 'message' => $e->getMessage()]);
|
||||
$output->writeln(sprintf('Could not sync user absence: id: %s and email: %s', $user->getId(), $user->getEmail()));
|
||||
throw $e;
|
||||
}
|
||||
|
||||
// we first try to renew an existing subscription, if any.
|
||||
// if not, or if it fails, we try to create a new one
|
||||
if ($this->mapCalendarToUser->hasActiveSubscription($user)) {
|
||||
$this->logger->debug(self::class . ' renew a subscription for', [
|
||||
$this->logger->debug(self::class.' renew a subscription for', [
|
||||
'userId' => $user->getId(),
|
||||
'username' => $user->getUsernameCanonical(),
|
||||
]);
|
||||
@@ -114,7 +111,7 @@ final class MapAndSubscribeUserCalendarCommand extends Command
|
||||
if (0 !== $expirationTs) {
|
||||
++$renewed;
|
||||
} else {
|
||||
$this->logger->warning(self::class . ' could not renew subscription for a user', [
|
||||
$this->logger->warning(self::class.' could not renew subscription for a user', [
|
||||
'userId' => $user->getId(),
|
||||
'username' => $user->getUsernameCanonical(),
|
||||
]);
|
||||
@@ -122,7 +119,7 @@ final class MapAndSubscribeUserCalendarCommand extends Command
|
||||
}
|
||||
|
||||
if (!$this->mapCalendarToUser->hasActiveSubscription($user)) {
|
||||
$this->logger->debug(self::class . ' create a subscription for', [
|
||||
$this->logger->debug(self::class.' create a subscription for', [
|
||||
'userId' => $user->getId(),
|
||||
'username' => $user->getUsernameCanonical(),
|
||||
]);
|
||||
@@ -134,14 +131,13 @@ final class MapAndSubscribeUserCalendarCommand extends Command
|
||||
if (0 !== $expirationTs) {
|
||||
++$created;
|
||||
} else {
|
||||
$this->logger->warning(self::class . ' could not create subscription for a user', [
|
||||
$this->logger->warning(self::class.' could not create subscription for a user', [
|
||||
'userId' => $user->getId(),
|
||||
'username' => $user->getUsernameCanonical(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (0 === $offset % $limit) {
|
||||
$this->em->flush();
|
||||
$this->em->clear();
|
||||
@@ -151,12 +147,12 @@ final class MapAndSubscribeUserCalendarCommand extends Command
|
||||
$this->em->flush();
|
||||
$this->em->clear();
|
||||
|
||||
$this->logger->warning(self::class . ' process executed', [
|
||||
$this->logger->warning(self::class.' process executed', [
|
||||
'created' => $created,
|
||||
'renewed' => $renewed,
|
||||
]);
|
||||
|
||||
$output->writeln("users synchronized");
|
||||
$output->writeln('users synchronized');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -26,8 +26,6 @@ use Chill\MainBundle\Repository\UserRepositoryInterface;
|
||||
use Chill\MainBundle\Service\ShortMessage\ShortMessageTransporterInterface;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Repository\PersonRepository;
|
||||
use DateInterval;
|
||||
use DateTimeImmutable;
|
||||
use libphonenumber\PhoneNumber;
|
||||
use libphonenumber\PhoneNumberFormat;
|
||||
use libphonenumber\PhoneNumberType;
|
||||
@@ -38,8 +36,6 @@ use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
||||
use Symfony\Component\Console\Question\Question;
|
||||
use UnexpectedValueException;
|
||||
use function count;
|
||||
|
||||
class SendTestShortMessageOnCalendarCommand extends Command
|
||||
{
|
||||
@@ -74,20 +70,20 @@ class SendTestShortMessageOnCalendarCommand extends Command
|
||||
|
||||
// start date
|
||||
$question = new Question('When will start the appointment ? (default: "1 hour") ', '1 hour');
|
||||
$startDate = new DateTimeImmutable($helper->ask($input, $output, $question));
|
||||
$startDate = new \DateTimeImmutable($helper->ask($input, $output, $question));
|
||||
|
||||
if (false === $startDate) {
|
||||
throw new UnexpectedValueException('could not create a date with this date and time');
|
||||
throw new \UnexpectedValueException('could not create a date with this date and time');
|
||||
}
|
||||
|
||||
$calendar->setStartDate($startDate);
|
||||
|
||||
// end date
|
||||
$question = new Question('How long will last the appointment ? (default: "PT30M") ', 'PT30M');
|
||||
$interval = new DateInterval($helper->ask($input, $output, $question));
|
||||
$interval = new \DateInterval($helper->ask($input, $output, $question));
|
||||
|
||||
if (false === $interval) {
|
||||
throw new UnexpectedValueException('could not create the interval');
|
||||
throw new \UnexpectedValueException('could not create the interval');
|
||||
}
|
||||
|
||||
$calendar->setEndDate($calendar->getStartDate()->add($interval));
|
||||
@@ -97,17 +93,17 @@ class SendTestShortMessageOnCalendarCommand extends Command
|
||||
$question
|
||||
->setValidator(function ($answer): Person {
|
||||
if (!is_numeric($answer)) {
|
||||
throw new UnexpectedValueException('the answer must be numeric');
|
||||
throw new \UnexpectedValueException('the answer must be numeric');
|
||||
}
|
||||
|
||||
if (0 >= (int) $answer) {
|
||||
throw new UnexpectedValueException('the answer must be greater than zero');
|
||||
throw new \UnexpectedValueException('the answer must be greater than zero');
|
||||
}
|
||||
|
||||
$person = $this->personRepository->find((int) $answer);
|
||||
|
||||
if (null === $person) {
|
||||
throw new UnexpectedValueException('The person is not found');
|
||||
throw new \UnexpectedValueException('The person is not found');
|
||||
}
|
||||
|
||||
return $person;
|
||||
@@ -121,17 +117,17 @@ class SendTestShortMessageOnCalendarCommand extends Command
|
||||
$question
|
||||
->setValidator(function ($answer): User {
|
||||
if (!is_numeric($answer)) {
|
||||
throw new UnexpectedValueException('the answer must be numeric');
|
||||
throw new \UnexpectedValueException('the answer must be numeric');
|
||||
}
|
||||
|
||||
if (0 >= (int) $answer) {
|
||||
throw new UnexpectedValueException('the answer must be greater than zero');
|
||||
throw new \UnexpectedValueException('the answer must be greater than zero');
|
||||
}
|
||||
|
||||
$user = $this->userRepository->find((int) $answer);
|
||||
|
||||
if (null === $user) {
|
||||
throw new UnexpectedValueException('The user is not found');
|
||||
throw new \UnexpectedValueException('The user is not found');
|
||||
}
|
||||
|
||||
return $user;
|
||||
@@ -150,13 +146,13 @@ class SendTestShortMessageOnCalendarCommand extends Command
|
||||
|
||||
$question->setNormalizer(function ($answer): PhoneNumber {
|
||||
if (null === $answer) {
|
||||
throw new UnexpectedValueException('The person is not found');
|
||||
throw new \UnexpectedValueException('The person is not found');
|
||||
}
|
||||
|
||||
$phone = $this->phoneNumberUtil->parse($answer, 'BE');
|
||||
|
||||
if (!$this->phoneNumberUtil->isPossibleNumberForType($phone, PhoneNumberType::MOBILE)) {
|
||||
throw new UnexpectedValueException('Phone number si not a mobile');
|
||||
throw new \UnexpectedValueException('Phone number si not a mobile');
|
||||
}
|
||||
|
||||
return $phone;
|
||||
@@ -169,7 +165,7 @@ class SendTestShortMessageOnCalendarCommand extends Command
|
||||
|
||||
$messages = $this->messageForCalendarBuilder->buildMessageForCalendar($calendar);
|
||||
|
||||
if (0 === count($messages)) {
|
||||
if (0 === \count($messages)) {
|
||||
$output->writeln('no message to send to this user');
|
||||
}
|
||||
|
||||
|
@@ -15,7 +15,6 @@ use Chill\CalendarBundle\Repository\CalendarRepository;
|
||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Serializer\Model\Collection;
|
||||
use DateTimeImmutable;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
@@ -40,8 +39,8 @@ class CalendarAPIController extends ApiController
|
||||
throw new BadRequestHttpException('You must provide a dateFrom parameter');
|
||||
}
|
||||
|
||||
if (false === $dateFrom = DateTimeImmutable::createFromFormat(
|
||||
DateTimeImmutable::ATOM,
|
||||
if (false === $dateFrom = \DateTimeImmutable::createFromFormat(
|
||||
\DateTimeImmutable::ATOM,
|
||||
$request->query->get('dateFrom')
|
||||
)) {
|
||||
throw new BadRequestHttpException('dateFrom not parsable');
|
||||
@@ -51,8 +50,8 @@ class CalendarAPIController extends ApiController
|
||||
throw new BadRequestHttpException('You must provide a dateTo parameter');
|
||||
}
|
||||
|
||||
if (false === $dateTo = DateTimeImmutable::createFromFormat(
|
||||
DateTimeImmutable::ATOM,
|
||||
if (false === $dateTo = \DateTimeImmutable::createFromFormat(
|
||||
\DateTimeImmutable::ATOM,
|
||||
$request->query->get('dateTo')
|
||||
)) {
|
||||
throw new BadRequestHttpException('dateTo not parsable');
|
||||
|
@@ -30,11 +30,8 @@ use Chill\PersonBundle\Repository\PersonRepository;
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use DateTimeImmutable;
|
||||
use Exception;
|
||||
use http\Exception\UnexpectedValueException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use RuntimeException;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Form;
|
||||
@@ -82,12 +79,12 @@ class CalendarController extends AbstractController
|
||||
$view = '@ChillCalendar/Calendar/confirm_deleteByPerson.html.twig';
|
||||
$redirectRoute = $this->generateUrl('chill_calendar_calendar_list_by_person', ['id' => $person->getId()]);
|
||||
} else {
|
||||
throw new RuntimeException('nor person or accompanying period');
|
||||
throw new \RuntimeException('nor person or accompanying period');
|
||||
}
|
||||
|
||||
$form = $this->createDeleteForm($entity);
|
||||
|
||||
if ($request->getMethod() === Request::METHOD_DELETE) {
|
||||
if (Request::METHOD_DELETE === $request->getMethod()) {
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isValid()) {
|
||||
@@ -138,7 +135,7 @@ class CalendarController extends AbstractController
|
||||
$view = '@ChillCalendar/Calendar/editByPerson.html.twig';
|
||||
$redirectRoute = $this->generateUrl('chill_calendar_calendar_list_by_person', ['id' => $person->getId()]);
|
||||
} else {
|
||||
throw new RuntimeException('no person nor accompanying period');
|
||||
throw new \RuntimeException('no person nor accompanying period');
|
||||
}
|
||||
|
||||
$form = $this->createForm(CalendarType::class, $entity)
|
||||
@@ -148,7 +145,7 @@ class CalendarController extends AbstractController
|
||||
$templates = $this->docGeneratorTemplateRepository->findByEntity(Calendar::class);
|
||||
|
||||
foreach ($templates as $template) {
|
||||
$form->add('save_and_generate_doc_' . $template->getId(), SubmitType::class, [
|
||||
$form->add('save_and_generate_doc_'.$template->getId(), SubmitType::class, [
|
||||
'label' => $this->translatableStringHelper->localize($template->getName()),
|
||||
]);
|
||||
}
|
||||
@@ -165,7 +162,7 @@ class CalendarController extends AbstractController
|
||||
}
|
||||
|
||||
foreach ($templates as $template) {
|
||||
if ($form->get('save_and_generate_doc_' . $template->getId())->isClicked()) {
|
||||
if ($form->get('save_and_generate_doc_'.$template->getId())->isClicked()) {
|
||||
return $this->redirectToRoute('chill_docgenerator_generate_from_template', [
|
||||
'entityClassName' => Calendar::class,
|
||||
'entityId' => $entity->getId(),
|
||||
@@ -327,7 +324,7 @@ class CalendarController extends AbstractController
|
||||
$form->add('save_and_upload_doc', SubmitType::class);
|
||||
|
||||
foreach ($templates as $template) {
|
||||
$form->add('save_and_generate_doc_' . $template->getId(), SubmitType::class, [
|
||||
$form->add('save_and_generate_doc_'.$template->getId(), SubmitType::class, [
|
||||
'label' => $this->translatableStringHelper->localize($template->getName()),
|
||||
]);
|
||||
}
|
||||
@@ -342,12 +339,12 @@ class CalendarController extends AbstractController
|
||||
|
||||
if ($form->get('save_and_upload_doc')->isClicked()) {
|
||||
return $this->redirectToRoute('chill_calendar_calendardoc_new', [
|
||||
'id' => $entity->getId()
|
||||
'id' => $entity->getId(),
|
||||
]);
|
||||
}
|
||||
|
||||
foreach ($templates as $template) {
|
||||
if ($form->get('save_and_generate_doc_' . $template->getId())->isClicked()) {
|
||||
if ($form->get('save_and_generate_doc_'.$template->getId())->isClicked()) {
|
||||
return $this->redirectToRoute('chill_docgenerator_generate_from_template', [
|
||||
'entityClassName' => Calendar::class,
|
||||
'entityId' => $entity->getId(),
|
||||
@@ -392,7 +389,7 @@ class CalendarController extends AbstractController
|
||||
*/
|
||||
public function showAction(Request $request, int $id): Response
|
||||
{
|
||||
throw new Exception('not implemented');
|
||||
throw new \Exception('not implemented');
|
||||
$view = null;
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
@@ -453,7 +450,7 @@ class CalendarController extends AbstractController
|
||||
'entity' => $entity,
|
||||
'user' => $user,
|
||||
'activityData' => $activityData,
|
||||
//'delete_form' => $deleteForm->createView(),
|
||||
// 'delete_form' => $deleteForm->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -498,12 +495,12 @@ class CalendarController extends AbstractController
|
||||
'returnPath' => $request->query->get('returnPath', null),
|
||||
];
|
||||
|
||||
if ($calendar->getContext() === 'accompanying_period') {
|
||||
if ('accompanying_period' === $calendar->getContext()) {
|
||||
$routeParams['accompanying_period_id'] = $calendar->getAccompanyingPeriod()->getId();
|
||||
} elseif ($calendar->getContext() === 'person') {
|
||||
} elseif ('person' === $calendar->getContext()) {
|
||||
$routeParams['person_id'] = $calendar->getPerson()->getId();
|
||||
} else {
|
||||
throw new RuntimeException('context not found for this calendar');
|
||||
throw new \RuntimeException('context not found for this calendar');
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('chill_activity_activity_new', $routeParams);
|
||||
@@ -512,7 +509,7 @@ class CalendarController extends AbstractController
|
||||
private function buildListFilterOrder(): FilterOrderHelper
|
||||
{
|
||||
$filterOrder = $this->filterOrderHelperFactory->create(self::class);
|
||||
$filterOrder->addDateRange('startDate', null, new DateTimeImmutable('3 days ago'), null);
|
||||
$filterOrder->addDateRange('startDate', null, new \DateTimeImmutable('3 days ago'), null);
|
||||
|
||||
return $filterOrder->build();
|
||||
}
|
||||
|
@@ -16,7 +16,6 @@ use Chill\CalendarBundle\Entity\CalendarDoc;
|
||||
use Chill\CalendarBundle\Form\CalendarDocCreateType;
|
||||
use Chill\CalendarBundle\Form\CalendarDocEditType;
|
||||
use Chill\CalendarBundle\Security\Voter\CalendarDocVoter;
|
||||
use Chill\DocGeneratorBundle\Repository\DocGeneratorTemplateRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\FormFactoryInterface;
|
||||
@@ -27,9 +26,6 @@ use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
use UnexpectedValueException;
|
||||
|
||||
final readonly class CalendarDocController
|
||||
{
|
||||
@@ -69,7 +65,7 @@ final readonly class CalendarDocController
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new UnexpectedValueException('Unsupported context');
|
||||
throw new \UnexpectedValueException('Unsupported context');
|
||||
}
|
||||
|
||||
$calendarDocDTO = new CalendarDoc\CalendarDocCreateDTO();
|
||||
@@ -186,7 +182,7 @@ final readonly class CalendarDocController
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new UnexpectedValueException('Unsupported context');
|
||||
throw new \UnexpectedValueException('Unsupported context');
|
||||
}
|
||||
|
||||
$calendarDocEditDTO = new CalendarDoc\CalendarDocEditDTO($calendarDoc);
|
||||
|
@@ -15,12 +15,10 @@ use Chill\CalendarBundle\Repository\CalendarRangeRepository;
|
||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Serializer\Model\Collection;
|
||||
use DateTimeImmutable;
|
||||
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;
|
||||
|
||||
class CalendarRangeAPIController extends ApiController
|
||||
@@ -35,15 +33,15 @@ class CalendarRangeAPIController extends ApiController
|
||||
*/
|
||||
public function availableRanges(User $user, Request $request, string $_format): JsonResponse
|
||||
{
|
||||
//return new JsonResponse(['ok' => true], 200, [], false);
|
||||
// return new JsonResponse(['ok' => true], 200, [], false);
|
||||
$this->denyAccessUnlessGranted('ROLE_USER');
|
||||
|
||||
if (!$request->query->has('dateFrom')) {
|
||||
throw new BadRequestHttpException('You must provide a dateFrom parameter');
|
||||
}
|
||||
|
||||
if (false === $dateFrom = DateTimeImmutable::createFromFormat(
|
||||
DateTimeImmutable::ATOM,
|
||||
if (false === $dateFrom = \DateTimeImmutable::createFromFormat(
|
||||
\DateTimeImmutable::ATOM,
|
||||
$request->query->get('dateFrom')
|
||||
)) {
|
||||
throw new BadRequestHttpException('dateFrom not parsable');
|
||||
@@ -53,8 +51,8 @@ class CalendarRangeAPIController extends ApiController
|
||||
throw new BadRequestHttpException('You must provide a dateTo parameter');
|
||||
}
|
||||
|
||||
if (false === $dateTo = DateTimeImmutable::createFromFormat(
|
||||
DateTimeImmutable::ATOM,
|
||||
if (false === $dateTo = \DateTimeImmutable::createFromFormat(
|
||||
\DateTimeImmutable::ATOM,
|
||||
$request->query->get('dateTo')
|
||||
)) {
|
||||
throw new BadRequestHttpException('dateTo not parsable');
|
||||
|
@@ -31,7 +31,6 @@ use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Messenger\MessageBusInterface;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use function in_array;
|
||||
|
||||
class InviteApiController
|
||||
{
|
||||
@@ -58,7 +57,7 @@ class InviteApiController
|
||||
throw new AccessDeniedHttpException('not allowed to answer on this invitation');
|
||||
}
|
||||
|
||||
if (!in_array($answer, Invite::STATUSES, true)) {
|
||||
if (!\in_array($answer, Invite::STATUSES, true)) {
|
||||
throw new BadRequestHttpException('answer not valid');
|
||||
}
|
||||
|
||||
|
@@ -19,13 +19,11 @@ declare(strict_types=1);
|
||||
namespace Chill\CalendarBundle\Controller;
|
||||
|
||||
use Chill\CalendarBundle\Messenger\Message\MSGraphChangeNotificationMessage;
|
||||
use JsonException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Messenger\MessageBusInterface;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use const JSON_THROW_ON_ERROR;
|
||||
|
||||
class RemoteCalendarMSGraphSyncController
|
||||
{
|
||||
@@ -44,8 +42,8 @@ class RemoteCalendarMSGraphSyncController
|
||||
}
|
||||
|
||||
try {
|
||||
$body = json_decode($request->getContent(), true, 512, JSON_THROW_ON_ERROR);
|
||||
} catch (JsonException $e) {
|
||||
$body = json_decode($request->getContent(), true, 512, \JSON_THROW_ON_ERROR);
|
||||
} catch (\JsonException $e) {
|
||||
throw new BadRequestHttpException('could not decode json', $e);
|
||||
}
|
||||
|
||||
|
@@ -22,14 +22,12 @@ use Chill\CalendarBundle\RemoteCalendar\Connector\RemoteCalendarConnectorInterfa
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||
use Chill\MainBundle\Serializer\Model\Collection;
|
||||
use DateTimeImmutable;
|
||||
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\Serializer\SerializerInterface;
|
||||
use function count;
|
||||
|
||||
/**
|
||||
* Contains method to get events (Calendar) from remote calendar.
|
||||
@@ -47,8 +45,8 @@ class RemoteCalendarProxyController
|
||||
throw new BadRequestHttpException('You must provide a dateFrom parameter');
|
||||
}
|
||||
|
||||
if (false === $dateFrom = DateTimeImmutable::createFromFormat(
|
||||
DateTimeImmutable::ATOM,
|
||||
if (false === $dateFrom = \DateTimeImmutable::createFromFormat(
|
||||
\DateTimeImmutable::ATOM,
|
||||
$request->query->get('dateFrom')
|
||||
)) {
|
||||
throw new BadRequestHttpException('dateFrom not parsable');
|
||||
@@ -58,8 +56,8 @@ class RemoteCalendarProxyController
|
||||
throw new BadRequestHttpException('You must provide a dateTo parameter');
|
||||
}
|
||||
|
||||
if (false === $dateTo = DateTimeImmutable::createFromFormat(
|
||||
DateTimeImmutable::ATOM,
|
||||
if (false === $dateTo = \DateTimeImmutable::createFromFormat(
|
||||
\DateTimeImmutable::ATOM,
|
||||
$request->query->get('dateTo')
|
||||
)) {
|
||||
throw new BadRequestHttpException('dateTo not parsable');
|
||||
@@ -87,8 +85,8 @@ class RemoteCalendarProxyController
|
||||
|
||||
// in some case, we cannot paginate: we have to fetch all the items at once. We must avoid
|
||||
// further requests by forcing the number of items returned.
|
||||
if (count($events) > $paginator->getItemsPerPage()) {
|
||||
$paginator->setItemsPerPage(count($events));
|
||||
if (\count($events) > $paginator->getItemsPerPage()) {
|
||||
$paginator->setItemsPerPage(\count($events));
|
||||
}
|
||||
|
||||
$collection = new Collection($events, $paginator);
|
||||
|
@@ -28,7 +28,7 @@ class LoadCalendarACL extends Fixture implements OrderedFixtureInterface
|
||||
foreach ([
|
||||
CalendarVoter::CREATE,
|
||||
CalendarVoter::DELETE,
|
||||
CalendarVoter::DELETE
|
||||
CalendarVoter::DELETE,
|
||||
] as $role) {
|
||||
$roleScopes[] = $r = (new RoleScope())
|
||||
->setRole($role);
|
||||
@@ -51,5 +51,4 @@ class LoadCalendarACL extends Fixture implements OrderedFixtureInterface
|
||||
{
|
||||
return 16000;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -18,7 +18,6 @@ use Chill\MainBundle\Entity\Location;
|
||||
use Chill\MainBundle\Entity\LocationType;
|
||||
use Chill\MainBundle\Entity\PostalCode;
|
||||
use Chill\MainBundle\Repository\UserRepository;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
@@ -63,7 +62,7 @@ class LoadCalendarRange extends Fixture implements FixtureGroupInterface, Ordere
|
||||
$manager->persist($type);
|
||||
$manager->persist($location);
|
||||
|
||||
$now = new DateTimeImmutable();
|
||||
$now = new \DateTimeImmutable();
|
||||
|
||||
$days = [
|
||||
'2021-08-23',
|
||||
@@ -74,8 +73,8 @@ class LoadCalendarRange extends Fixture implements FixtureGroupInterface, Ordere
|
||||
'2021-08-31',
|
||||
'2021-09-01',
|
||||
'2021-09-02',
|
||||
(new DateTimeImmutable('tomorrow'))->format('Y-m-d'),
|
||||
(new DateTimeImmutable('today'))->format('Y-m-d'),
|
||||
(new \DateTimeImmutable('tomorrow'))->format('Y-m-d'),
|
||||
(new \DateTimeImmutable('today'))->format('Y-m-d'),
|
||||
$now->add(new \DateInterval('P7D'))->format('Y-m-d'),
|
||||
$now->add(new \DateInterval('P8D'))->format('Y-m-d'),
|
||||
$now->add(new \DateInterval('P9D'))->format('Y-m-d'),
|
||||
@@ -92,9 +91,9 @@ class LoadCalendarRange extends Fixture implements FixtureGroupInterface, Ordere
|
||||
foreach ($users as $u) {
|
||||
foreach ($days as $d) {
|
||||
foreach ($hours as $h) {
|
||||
$event = $d . ' ' . $h;
|
||||
$startEvent = new DateTimeImmutable($event);
|
||||
$endEvent = new DateTimeImmutable($event . ' + 1 hours');
|
||||
$event = $d.' '.$h;
|
||||
$startEvent = new \DateTimeImmutable($event);
|
||||
$endEvent = new \DateTimeImmutable($event.' + 1 hours');
|
||||
$calendarRange = (new CalendarRange())
|
||||
->setUser($u)
|
||||
->setStartDate($startEvent)
|
||||
|
@@ -39,12 +39,12 @@ class LoadCancelReason extends Fixture implements FixtureGroupInterface
|
||||
];
|
||||
|
||||
foreach ($arr as $a) {
|
||||
echo 'Creating calendar cancel reason : ' . $a['name'] . "\n";
|
||||
echo 'Creating calendar cancel reason : '.$a['name']."\n";
|
||||
$cancelReason = (new CancelReason())
|
||||
->setCanceledBy($a['name'])
|
||||
->setActive(true);
|
||||
$manager->persist($cancelReason);
|
||||
$reference = 'CancelReason_' . $a['name'];
|
||||
$reference = 'CancelReason_'.$a['name'];
|
||||
$this->addReference($reference, $cancelReason);
|
||||
static::$references[] = $reference;
|
||||
}
|
||||
|
@@ -46,12 +46,12 @@ class LoadInvite extends Fixture implements FixtureGroupInterface
|
||||
];
|
||||
|
||||
foreach ($arr as $a) {
|
||||
echo 'Creating calendar invite : ' . $a['name']['fr'] . "\n";
|
||||
echo 'Creating calendar invite : '.$a['name']['fr']."\n";
|
||||
$invite = (new Invite())
|
||||
->setStatus($a['status'])
|
||||
->setUser($this->getRandomUser());
|
||||
$manager->persist($invite);
|
||||
$reference = 'Invite_' . $a['name']['fr'];
|
||||
$reference = 'Invite_'.$a['name']['fr'];
|
||||
$this->addReference($reference, $invite);
|
||||
static::$references[] = $reference;
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ class ChillCalendarExtension extends Extension implements PrependExtensionInterf
|
||||
$configuration = new Configuration();
|
||||
$config = $this->processConfiguration($configuration, $configs);
|
||||
|
||||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
|
||||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||
$loader->load('services.yml');
|
||||
$loader->load('services/exports.yaml');
|
||||
$loader->load('services/controller.yml');
|
||||
|
@@ -24,29 +24,26 @@ use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use DateInterval;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
use Doctrine\Common\Collections\ReadableCollection;
|
||||
use Doctrine\Common\Collections\Selectable;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use LogicException;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\Range;
|
||||
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
* @ORM\Table(
|
||||
* name="chill_calendar.calendar",
|
||||
* uniqueConstraints={@ORM\UniqueConstraint(name="idx_calendar_remote", columns={"remoteId"}, options={"where": "remoteId <> ''"})}
|
||||
* )
|
||||
*
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "chill_calendar_calendar": Calendar::class
|
||||
* })
|
||||
@@ -94,6 +91,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod", inversedBy="calendars")
|
||||
*
|
||||
* @Serializer\Groups({"calendar:read", "read"})
|
||||
*/
|
||||
private ?AccompanyingPeriod $accompanyingPeriod = null;
|
||||
@@ -105,6 +103,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
|
||||
|
||||
/**
|
||||
* @ORM\OneToOne(targetEntity="CalendarRange", inversedBy="calendar")
|
||||
*
|
||||
* @Serializer\Groups({"calendar:read", "read"})
|
||||
*/
|
||||
private ?CalendarRange $calendarRange = null;
|
||||
@@ -116,6 +115,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
|
||||
|
||||
/**
|
||||
* @ORM\Embedded(class=CommentEmbeddable::class, columnPrefix="comment_")
|
||||
*
|
||||
* @Serializer\Groups({"calendar:read", "read", "docgen:read"})
|
||||
*/
|
||||
private CommentEmbeddable $comment;
|
||||
@@ -127,21 +127,27 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
|
||||
|
||||
/**
|
||||
* @var Collection<CalendarDoc>
|
||||
*
|
||||
* @ORM\OneToMany(targetEntity=CalendarDoc::class, mappedBy="calendar", orphanRemoval=true)
|
||||
*/
|
||||
private Collection $documents;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable", nullable=false)
|
||||
*
|
||||
* @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"})
|
||||
*
|
||||
* @Assert\NotNull(message="calendar.An end date is required")
|
||||
*/
|
||||
private ?DateTimeImmutable $endDate = null;
|
||||
private ?\DateTimeImmutable $endDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"})
|
||||
*/
|
||||
private ?int $id = null;
|
||||
@@ -153,60 +159,80 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
|
||||
* orphanRemoval=true,
|
||||
* cascade={"persist", "remove", "merge", "detach"}
|
||||
* )
|
||||
*
|
||||
* @ORM\JoinTable(name="chill_calendar.calendar_to_invites")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*
|
||||
* @var Collection&Selectable<int, Invite>
|
||||
*/
|
||||
private Collection&Selectable $invites;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Location")
|
||||
*
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*
|
||||
* @Assert\NotNull(message="calendar.A location is required")
|
||||
*/
|
||||
private ?Location $location = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
||||
*
|
||||
* @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"})
|
||||
*
|
||||
* @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"})
|
||||
*
|
||||
* @Assert\NotNull(message="calendar.A main user is mandatory")
|
||||
*/
|
||||
private ?User $mainUser = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Person::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
*/
|
||||
private ?Person $person = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\Person", inversedBy="calendars")
|
||||
*
|
||||
* @ORM\JoinTable(name="chill_calendar.calendar_to_persons")
|
||||
*
|
||||
* @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"})
|
||||
*
|
||||
* @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"})
|
||||
*
|
||||
* @Assert\Count(min=1, minMessage="calendar.At least {{ limit }} person is required.")
|
||||
*
|
||||
* @var Collection<Person>
|
||||
*/
|
||||
private Collection $persons;
|
||||
|
||||
/**
|
||||
* @ORM\Embedded(class=PrivateCommentEmbeddable::class, columnPrefix="privateComment_")
|
||||
*
|
||||
* @Serializer\Groups({"calendar:read"})
|
||||
*/
|
||||
private PrivateCommentEmbeddable $privateComment;
|
||||
|
||||
/**
|
||||
* @var Collection<ThirdParty>
|
||||
*
|
||||
* @ORM\ManyToMany(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty")
|
||||
*
|
||||
* @ORM\JoinTable(name="chill_calendar.calendar_to_thirdparties")
|
||||
*
|
||||
* @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"})
|
||||
*
|
||||
* @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"})
|
||||
*/
|
||||
private Collection $professionals;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", nullable=true)
|
||||
*
|
||||
* @Serializer\Groups({"docgen:read"})
|
||||
*/
|
||||
private ?bool $sendSMS = false;
|
||||
@@ -218,21 +244,27 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable", nullable=false)
|
||||
*
|
||||
* @Serializer\Groups({"calendar:read", "read", "calendar:light", "docgen:read"})
|
||||
*
|
||||
* @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"})
|
||||
*
|
||||
* @Assert\NotNull(message="calendar.A start date is required")
|
||||
*/
|
||||
private ?DateTimeImmutable $startDate = null;
|
||||
private ?\DateTimeImmutable $startDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255, nullable=false, options={"default": "valid"})
|
||||
*
|
||||
* @Serializer\Groups({"calendar:read", "read", "calendar:light"})
|
||||
*
|
||||
* @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"})
|
||||
*/
|
||||
private string $status = self::STATUS_VALID;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean", nullable=true)
|
||||
*
|
||||
* @Serializer\Groups({"docgen:read"})
|
||||
*/
|
||||
private ?bool $urgent = false;
|
||||
@@ -265,7 +297,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
|
||||
public function addInvite(Invite $invite): self
|
||||
{
|
||||
if ($invite->getCalendar() instanceof Calendar && $invite->getCalendar() !== $this) {
|
||||
throw new LogicException('Not allowed to move an invitation to another Calendar');
|
||||
throw new \LogicException('Not allowed to move an invitation to another Calendar');
|
||||
}
|
||||
|
||||
$this->invites[] = $invite;
|
||||
@@ -324,7 +356,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
|
||||
return match ($this->getContext()) {
|
||||
'person' => [$this->getPerson()->getCenter()],
|
||||
'accompanying_period' => $this->getAccompanyingPeriod()->getCenters(),
|
||||
default => throw new LogicException('context not supported: ' . $this->getContext()),
|
||||
default => throw new \LogicException('context not supported: '.$this->getContext()),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -338,11 +370,11 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
|
||||
*/
|
||||
public function getContext(): ?string
|
||||
{
|
||||
if ($this->getAccompanyingPeriod() !== null) {
|
||||
if (null !== $this->getAccompanyingPeriod()) {
|
||||
return 'accompanying_period';
|
||||
}
|
||||
|
||||
if ($this->getPerson() !== null) {
|
||||
if (null !== $this->getPerson()) {
|
||||
return 'person';
|
||||
}
|
||||
|
||||
@@ -365,16 +397,16 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
|
||||
/**
|
||||
* @Serializer\Groups({"docgen:read"})
|
||||
*/
|
||||
public function getDuration(): ?DateInterval
|
||||
public function getDuration(): ?\DateInterval
|
||||
{
|
||||
if ($this->getStartDate() === null || $this->getEndDate() === null) {
|
||||
if (null === $this->getStartDate() || null === $this->getEndDate()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->getStartDate()->diff($this->getEndDate());
|
||||
}
|
||||
|
||||
public function getEndDate(): ?DateTimeImmutable
|
||||
public function getEndDate(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->endDate;
|
||||
}
|
||||
@@ -453,7 +485,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
|
||||
$personsNotAssociated = [];
|
||||
|
||||
foreach ($this->persons as $person) {
|
||||
if (!in_array($person, $this->getPersonsAssociated(), true)) {
|
||||
if (!\in_array($person, $this->getPersonsAssociated(), true)) {
|
||||
$personsNotAssociated[] = $person;
|
||||
}
|
||||
}
|
||||
@@ -487,7 +519,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
|
||||
return $this->smsStatus;
|
||||
}
|
||||
|
||||
public function getStartDate(): ?DateTimeImmutable
|
||||
public function getStartDate(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->startDate;
|
||||
}
|
||||
@@ -509,6 +541,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
|
||||
|
||||
/**
|
||||
* @return ReadableCollection<(int|string), User>
|
||||
*
|
||||
* @Serializer\Groups({"calendar:read", "read"})
|
||||
*/
|
||||
public function getUsers(): ReadableCollection
|
||||
@@ -558,7 +591,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
|
||||
public function removeDocument(CalendarDoc $calendarDoc): self
|
||||
{
|
||||
if ($calendarDoc->getCalendar() !== $this) {
|
||||
throw new LogicException('cannot remove document of another calendar');
|
||||
throw new \LogicException('cannot remove document of another calendar');
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -652,7 +685,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setEndDate(DateTimeImmutable $endDate): self
|
||||
public function setEndDate(\DateTimeImmutable $endDate): self
|
||||
{
|
||||
if (null === $this->endDate || $this->endDate->getTimestamp() !== $endDate->getTimestamp()) {
|
||||
$this->increaseaDatetimeVersion();
|
||||
@@ -710,7 +743,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setStartDate(DateTimeImmutable $startDate): self
|
||||
public function setStartDate(\DateTimeImmutable $startDate): self
|
||||
{
|
||||
if (null === $this->startDate || $this->startDate->getTimestamp() !== $startDate->getTimestamp()) {
|
||||
$this->increaseaDatetimeVersion();
|
||||
@@ -725,7 +758,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
|
||||
{
|
||||
$this->status = $status;
|
||||
|
||||
if (self::STATUS_CANCELED === $status && $this->getSmsStatus() === self::SMS_SENT) {
|
||||
if (self::STATUS_CANCELED === $status && self::SMS_SENT === $this->getSmsStatus()) {
|
||||
$this->setSmsStatus(self::SMS_CANCEL_PENDING);
|
||||
}
|
||||
|
||||
|
@@ -22,6 +22,7 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*
|
||||
* @ORM\Table(
|
||||
* name="chill_calendar.calendar_doc",
|
||||
* )
|
||||
@@ -34,6 +35,7 @@ class CalendarDoc implements TrackCreationInterface, TrackUpdateInterface
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Calendar::class, inversedBy="documents")
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private Calendar $calendar;
|
||||
@@ -45,7 +47,9 @@ class CalendarDoc implements TrackCreationInterface, TrackUpdateInterface
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private ?int $id = null;
|
||||
@@ -57,9 +61,10 @@ class CalendarDoc implements TrackCreationInterface, TrackUpdateInterface
|
||||
|
||||
public function __construct(Calendar $calendar, /**
|
||||
* @ORM\ManyToOne(targetEntity=StoredObject::class, cascade={"persist"})
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private ?\Chill\DocStoreBundle\Entity\StoredObject $storedObject)
|
||||
private ?StoredObject $storedObject)
|
||||
{
|
||||
$this->setCalendar($calendar);
|
||||
$this->datetimeVersion = $calendar->getDateTimeVersion();
|
||||
@@ -108,8 +113,6 @@ class CalendarDoc implements TrackCreationInterface, TrackUpdateInterface
|
||||
|
||||
/**
|
||||
* @internal use @see{Calendar::removeDocument} instead
|
||||
*
|
||||
* @param Calendar $calendar
|
||||
*/
|
||||
public function setCalendar(?Calendar $calendar): CalendarDoc
|
||||
{
|
||||
|
@@ -18,12 +18,14 @@ class CalendarDocCreateDTO
|
||||
{
|
||||
/**
|
||||
* @Assert\NotNull
|
||||
*
|
||||
* @Assert\Valid
|
||||
*/
|
||||
public ?StoredObject $doc = null;
|
||||
|
||||
/**
|
||||
* @Assert\NotBlank
|
||||
*
|
||||
* @Assert\NotNull
|
||||
*/
|
||||
public ?string $title = '';
|
||||
|
@@ -24,6 +24,7 @@ class CalendarDocEditDTO
|
||||
|
||||
/**
|
||||
* @Assert\NotBlank
|
||||
*
|
||||
* @Assert\NotNull
|
||||
*/
|
||||
public ?string $title = '';
|
||||
|
@@ -17,7 +17,6 @@ use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
|
||||
use Chill\MainBundle\Entity\Location;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
@@ -27,6 +26,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||
* name="chill_calendar.calendar_range",
|
||||
* uniqueConstraints={@ORM\UniqueConstraint(name="idx_calendar_range_remote", columns={"remoteId"}, options={"where": "remoteId <> ''"})}
|
||||
* )
|
||||
*
|
||||
* @ORM\Entity
|
||||
*/
|
||||
class CalendarRange implements TrackCreationInterface, TrackUpdateInterface
|
||||
@@ -44,37 +44,49 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable", nullable=false)
|
||||
*
|
||||
* @Groups({"read", "write", "calendar:read"})
|
||||
*
|
||||
* @Assert\NotNull
|
||||
*/
|
||||
private ?DateTimeImmutable $endDate = null;
|
||||
private ?\DateTimeImmutable $endDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=Location::class)
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*
|
||||
* @Groups({"read", "write", "calendar:read"})
|
||||
*
|
||||
* @Assert\NotNull
|
||||
*/
|
||||
private ?Location $location = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable", nullable=false)
|
||||
*
|
||||
* @groups({"read", "write", "calendar:read"})
|
||||
*
|
||||
* @Assert\NotNull
|
||||
*/
|
||||
private ?DateTimeImmutable $startDate = null;
|
||||
private ?\DateTimeImmutable $startDate = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
||||
*
|
||||
* @Groups({"read", "write", "calendar:read"})
|
||||
*
|
||||
* @Assert\NotNull
|
||||
*/
|
||||
private ?User $user = null;
|
||||
@@ -84,7 +96,7 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this->calendar;
|
||||
}
|
||||
|
||||
public function getEndDate(): ?DateTimeImmutable
|
||||
public function getEndDate(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->endDate;
|
||||
}
|
||||
@@ -99,7 +111,7 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this->location;
|
||||
}
|
||||
|
||||
public function getStartDate(): ?DateTimeImmutable
|
||||
public function getStartDate(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->startDate;
|
||||
}
|
||||
@@ -117,7 +129,7 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface
|
||||
$this->calendar = $calendar;
|
||||
}
|
||||
|
||||
public function setEndDate(DateTimeImmutable $endDate): self
|
||||
public function setEndDate(\DateTimeImmutable $endDate): self
|
||||
{
|
||||
$this->endDate = $endDate;
|
||||
|
||||
@@ -131,7 +143,7 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setStartDate(DateTimeImmutable $startDate): self
|
||||
public function setStartDate(\DateTimeImmutable $startDate): self
|
||||
{
|
||||
$this->startDate = $startDate;
|
||||
|
||||
|
@@ -16,6 +16,7 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Table(name="chill_calendar.cancel_reason")
|
||||
*
|
||||
* @ORM\Entity(repositoryClass=CancelReasonRepository::class)
|
||||
*/
|
||||
class CancelReason
|
||||
@@ -38,7 +39,9 @@ class CancelReason
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private ?int $id = null;
|
||||
|
@@ -17,7 +17,6 @@ use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use LogicException;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
|
||||
/**
|
||||
@@ -30,6 +29,7 @@ use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
* name="chill_calendar.invite",
|
||||
* uniqueConstraints={@ORM\UniqueConstraint(name="idx_calendar_invite_remote", columns={"remoteId"}, options={"where": "remoteId <> ''"})}
|
||||
* )
|
||||
*
|
||||
* @ORM\Entity
|
||||
*/
|
||||
class Invite implements TrackUpdateInterface, TrackCreationInterface
|
||||
@@ -65,21 +65,27 @@ class Invite implements TrackUpdateInterface, TrackCreationInterface
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
*
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
*
|
||||
* @Serializer\Groups(groups={"calendar:read", "read"})
|
||||
*/
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text", nullable=false, options={"default": "pending"})
|
||||
*
|
||||
* @Serializer\Groups(groups={"calendar:read", "read", "docgen:read"})
|
||||
*/
|
||||
private string $status = self::PENDING;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
||||
*
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*
|
||||
* @Serializer\Groups(groups={"calendar:read", "read", "docgen:read"})
|
||||
*/
|
||||
private ?User $user = null;
|
||||
@@ -122,7 +128,7 @@ class Invite implements TrackUpdateInterface, TrackCreationInterface
|
||||
public function setUser(?User $user): self
|
||||
{
|
||||
if ($user instanceof User && $this->user instanceof User && $user !== $this->user) {
|
||||
throw new LogicException('Not allowed to associate an invite to a different user');
|
||||
throw new \LogicException('Not allowed to associate an invite to a different user');
|
||||
}
|
||||
|
||||
$this->user = $user;
|
||||
|
@@ -15,8 +15,6 @@ use Chill\ActivityBundle\Entity\Activity;
|
||||
use Doctrine\Persistence\Event\LifecycleEventArgs;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
|
||||
use function array_key_exists;
|
||||
|
||||
class ListenToActivityCreate
|
||||
{
|
||||
public function __construct(private readonly RequestStack $requestStack) {}
|
||||
@@ -33,7 +31,7 @@ class ListenToActivityCreate
|
||||
if ($request->query->has('activityData')) {
|
||||
$activityData = $request->query->get('activityData');
|
||||
|
||||
if (array_key_exists('calendarId', $activityData)) {
|
||||
if (\array_key_exists('calendarId', $activityData)) {
|
||||
$calendarId = $activityData['calendarId'];
|
||||
|
||||
// Attach the activity to the calendar
|
||||
|
@@ -13,7 +13,7 @@ namespace Chill\CalendarBundle\Exception;
|
||||
|
||||
class UserAbsenceSyncException extends \LogicException
|
||||
{
|
||||
public function __construct(string $message = "", int $code = 20_230_706, ?\Throwable $previous = null)
|
||||
public function __construct(string $message = '', int $code = 20_230_706, \Throwable $previous = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
|
@@ -15,10 +15,8 @@ use Chill\CalendarBundle\Export\Declarations;
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Repository\UserRepository;
|
||||
use Chill\MainBundle\Templating\Entity\UserRender;
|
||||
use Closure;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use function in_array;
|
||||
|
||||
final readonly class AgentAggregator implements AggregatorInterface
|
||||
{
|
||||
@@ -31,7 +29,7 @@ final readonly class AgentAggregator implements AggregatorInterface
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
if (!in_array('caluser', $qb->getAllAliases(), true)) {
|
||||
if (!\in_array('caluser', $qb->getAllAliases(), true)) {
|
||||
$qb->join('cal.mainUser', 'caluser');
|
||||
}
|
||||
|
||||
@@ -48,12 +46,13 @@ final readonly class AgentAggregator implements AggregatorInterface
|
||||
{
|
||||
// no form
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data): Closure
|
||||
public function getLabels($key, array $values, $data): \Closure
|
||||
{
|
||||
return function ($value): string {
|
||||
if ('_header' === $value) {
|
||||
|
@@ -15,10 +15,8 @@ use Chill\CalendarBundle\Export\Declarations;
|
||||
use Chill\CalendarBundle\Repository\CancelReasonRepository;
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Closure;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use function in_array;
|
||||
|
||||
class CancelReasonAggregator implements AggregatorInterface
|
||||
{
|
||||
@@ -32,7 +30,7 @@ class CancelReasonAggregator implements AggregatorInterface
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
// TODO: still needs to take into account calendars without a cancel reason somehow
|
||||
if (!in_array('calcancel', $qb->getAllAliases(), true)) {
|
||||
if (!\in_array('calcancel', $qb->getAllAliases(), true)) {
|
||||
$qb->join('cal.cancelReason', 'calcancel');
|
||||
}
|
||||
|
||||
@@ -49,12 +47,13 @@ class CancelReasonAggregator implements AggregatorInterface
|
||||
{
|
||||
// no form
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data): Closure
|
||||
public function getLabels($key, array $values, $data): \Closure
|
||||
{
|
||||
return function ($value): string {
|
||||
if ('_header' === $value) {
|
||||
|
@@ -16,7 +16,6 @@ use Chill\MainBundle\Entity\User\UserJobHistory;
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Repository\UserJobRepository;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Closure;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
@@ -50,10 +49,10 @@ final readonly class JobAggregator implements AggregatorInterface
|
||||
// job_at based on cal.startDate
|
||||
->andWhere(
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->lte("{$p}_history.startDate", "cal.startDate"),
|
||||
$qb->expr()->lte("{$p}_history.startDate", 'cal.startDate'),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull("{$p}_history.endDate"),
|
||||
$qb->expr()->gt("{$p}_history.endDate", "cal.startDate")
|
||||
$qb->expr()->gt("{$p}_history.endDate", 'cal.startDate')
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -73,7 +72,7 @@ final readonly class JobAggregator implements AggregatorInterface
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data): Closure
|
||||
public function getLabels($key, array $values, $data): \Closure
|
||||
{
|
||||
return function ($value): string {
|
||||
if ('_header' === $value) {
|
||||
@@ -96,7 +95,7 @@ final readonly class JobAggregator implements AggregatorInterface
|
||||
|
||||
public function getQueryKeys($data): array
|
||||
{
|
||||
return [self::PREFIX . '_select'];
|
||||
return [self::PREFIX.'_select'];
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
|
@@ -14,10 +14,8 @@ namespace Chill\CalendarBundle\Export\Aggregator;
|
||||
use Chill\CalendarBundle\Export\Declarations;
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Repository\LocationRepository;
|
||||
use Closure;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use function in_array;
|
||||
|
||||
final readonly class LocationAggregator implements AggregatorInterface
|
||||
{
|
||||
@@ -30,7 +28,7 @@ final readonly class LocationAggregator implements AggregatorInterface
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
if (!in_array('calloc', $qb->getAllAliases(), true)) {
|
||||
if (!\in_array('calloc', $qb->getAllAliases(), true)) {
|
||||
$qb->join('cal.location', 'calloc');
|
||||
}
|
||||
$qb->addSelect('IDENTITY(cal.location) as location_aggregator');
|
||||
@@ -46,12 +44,13 @@ final readonly class LocationAggregator implements AggregatorInterface
|
||||
{
|
||||
// no form
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data): Closure
|
||||
public function getLabels($key, array $values, $data): \Closure
|
||||
{
|
||||
return function ($value): string {
|
||||
if ('_header' === $value) {
|
||||
|
@@ -15,10 +15,8 @@ use Chill\CalendarBundle\Export\Declarations;
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Repository\LocationTypeRepository;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Closure;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use function in_array;
|
||||
|
||||
final readonly class LocationTypeAggregator implements AggregatorInterface
|
||||
{
|
||||
@@ -31,7 +29,7 @@ final readonly class LocationTypeAggregator implements AggregatorInterface
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
if (!in_array('calloc', $qb->getAllAliases(), true)) {
|
||||
if (!\in_array('calloc', $qb->getAllAliases(), true)) {
|
||||
$qb->join('cal.location', 'calloc');
|
||||
}
|
||||
|
||||
@@ -48,12 +46,13 @@ final readonly class LocationTypeAggregator implements AggregatorInterface
|
||||
{
|
||||
// no form
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data): Closure
|
||||
public function getLabels($key, array $values, $data): \Closure
|
||||
{
|
||||
return function ($value): string {
|
||||
if ('_header' === $value) {
|
||||
|
@@ -13,7 +13,6 @@ namespace Chill\CalendarBundle\Export\Aggregator;
|
||||
|
||||
use Chill\CalendarBundle\Export\Declarations;
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Closure;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
@@ -40,12 +39,13 @@ class MonthYearAggregator implements AggregatorInterface
|
||||
{
|
||||
// No form needed
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data): Closure
|
||||
public function getLabels($key, array $values, $data): \Closure
|
||||
{
|
||||
return static function ($value): string {
|
||||
if ('_header' === $value) {
|
||||
|
@@ -16,14 +16,13 @@ use Chill\MainBundle\Entity\User\UserScopeHistory;
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Repository\ScopeRepository;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Closure;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
final readonly class ScopeAggregator implements AggregatorInterface
|
||||
{
|
||||
private const PREFIX = "cal_agg_scope";
|
||||
private const PREFIX = 'cal_agg_scope';
|
||||
|
||||
public function __construct(
|
||||
private ScopeRepository $scopeRepository,
|
||||
@@ -40,7 +39,7 @@ final readonly class ScopeAggregator implements AggregatorInterface
|
||||
$p = self::PREFIX;
|
||||
|
||||
$qb
|
||||
->leftJoin("cal.mainUser", "{$p}_user")
|
||||
->leftJoin('cal.mainUser', "{$p}_user")
|
||||
->leftJoin(
|
||||
UserScopeHistory::class,
|
||||
"{$p}_history",
|
||||
@@ -50,10 +49,10 @@ final readonly class ScopeAggregator implements AggregatorInterface
|
||||
// scope_at based on cal.startDate
|
||||
->andWhere(
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->lte("{$p}_history.startDate", "cal.startDate"),
|
||||
$qb->expr()->lte("{$p}_history.startDate", 'cal.startDate'),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull("{$p}_history.endDate"),
|
||||
$qb->expr()->gt("{$p}_history.endDate", "cal.startDate")
|
||||
$qb->expr()->gt("{$p}_history.endDate", 'cal.startDate')
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -73,7 +72,7 @@ final readonly class ScopeAggregator implements AggregatorInterface
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data): Closure
|
||||
public function getLabels($key, array $values, $data): \Closure
|
||||
{
|
||||
return function ($value): string {
|
||||
if ('_header' === $value) {
|
||||
@@ -96,7 +95,7 @@ final readonly class ScopeAggregator implements AggregatorInterface
|
||||
|
||||
public function getQueryKeys($data): array
|
||||
{
|
||||
return [self::PREFIX . '_select'];
|
||||
return [self::PREFIX.'_select'];
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
|
@@ -20,9 +20,7 @@ namespace Chill\CalendarBundle\Export\Aggregator;
|
||||
|
||||
use Chill\CalendarBundle\Export\Declarations;
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Closure;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use LogicException;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
@@ -50,12 +48,13 @@ class UrgencyAggregator implements AggregatorInterface
|
||||
{
|
||||
// no form
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data): Closure
|
||||
public function getLabels($key, array $values, $data): \Closure
|
||||
{
|
||||
return function ($value): string {
|
||||
if ('_header' === $value) {
|
||||
@@ -65,7 +64,7 @@ class UrgencyAggregator implements AggregatorInterface
|
||||
return match ($value) {
|
||||
true => $this->translator->trans('is urgent'),
|
||||
false => $this->translator->trans('is not urgent'),
|
||||
default => throw new LogicException(sprintf('The value %s is not valid', $value)),
|
||||
default => throw new \LogicException(sprintf('The value %s is not valid', $value)),
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@@ -18,7 +18,6 @@ use Chill\MainBundle\Export\ExportInterface;
|
||||
use Chill\MainBundle\Export\FormatterInterface;
|
||||
use Chill\MainBundle\Export\GroupedExportInterface;
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
use Closure;
|
||||
use Doctrine\ORM\AbstractQuery;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
@@ -32,6 +31,7 @@ class CountCalendars implements ExportInterface, GroupedExportInterface
|
||||
{
|
||||
// No form necessary
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
|
@@ -20,7 +20,6 @@ use Chill\MainBundle\Export\GroupedExportInterface;
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use LogicException;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface
|
||||
@@ -31,6 +30,7 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface
|
||||
{
|
||||
// no form needed
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
@@ -54,7 +54,7 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
if ('export_result' !== $key) {
|
||||
throw new LogicException("the key {$key} is not used by this export");
|
||||
throw new \LogicException("the key {$key} is not used by this export");
|
||||
}
|
||||
|
||||
$labels = array_combine($values, $values);
|
||||
|
@@ -20,7 +20,6 @@ use Chill\MainBundle\Export\GroupedExportInterface;
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use LogicException;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface
|
||||
@@ -31,6 +30,7 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface
|
||||
{
|
||||
// no form needed
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
@@ -54,7 +54,7 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
if ('export_result' !== $key) {
|
||||
throw new LogicException("the key {$key} is not used by this export");
|
||||
throw new \LogicException("the key {$key} is not used by this export");
|
||||
}
|
||||
|
||||
$labels = array_combine($values, $values);
|
||||
|
@@ -58,6 +58,7 @@ class AgentFilter implements FilterInterface
|
||||
'expanded' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
|
@@ -58,6 +58,7 @@ class BetweenDatesFilter implements FilterInterface
|
||||
->add('date_from', PickRollingDateType::class, [])
|
||||
->add('date_to', PickRollingDateType::class, []);
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return ['date_from' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), 'date_to' => new RollingDate(RollingDate::T_TODAY)];
|
||||
|
@@ -20,7 +20,6 @@ namespace Chill\CalendarBundle\Export\Filter;
|
||||
|
||||
use Chill\CalendarBundle\Export\Declarations;
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Doctrine\ORM\Query\Expr\Andx;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
@@ -66,6 +65,7 @@ class CalendarRangeFilter implements FilterInterface
|
||||
'empty_data' => self::DEFAULT_CHOICE,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return ['hasCalendarRange' => self::DEFAULT_CHOICE];
|
||||
|
@@ -20,7 +20,6 @@ use Doctrine\ORM\Query\Expr\Join;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
final readonly class JobFilter implements FilterInterface
|
||||
{
|
||||
@@ -40,7 +39,7 @@ final readonly class JobFilter implements FilterInterface
|
||||
$p = self::PREFIX;
|
||||
|
||||
$qb
|
||||
->leftJoin("cal.mainUser", "{$p}_user")
|
||||
->leftJoin('cal.mainUser', "{$p}_user")
|
||||
->leftJoin(
|
||||
UserJobHistory::class,
|
||||
"{$p}_history",
|
||||
@@ -50,19 +49,18 @@ final readonly class JobFilter implements FilterInterface
|
||||
// job_at based on cal.startDate
|
||||
->andWhere(
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->lte("{$p}_history.startDate", "cal.startDate"),
|
||||
$qb->expr()->lte("{$p}_history.startDate", 'cal.startDate'),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull("{$p}_history.endDate"),
|
||||
$qb->expr()->gt("{$p}_history.endDate", "cal.startDate")
|
||||
$qb->expr()->gt("{$p}_history.endDate", 'cal.startDate')
|
||||
)
|
||||
)
|
||||
)
|
||||
->andWhere($qb->expr()->in("{$p}_history.job", ":{$p}_job"))
|
||||
->setParameter(
|
||||
"{$p}_job",
|
||||
$data["job"]
|
||||
$data['job']
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public function applyOn(): string
|
||||
|
@@ -41,7 +41,7 @@ class ScopeFilter implements FilterInterface
|
||||
$p = self::PREFIX;
|
||||
|
||||
$qb
|
||||
->leftJoin("cal.mainUser", "{$p}_user")
|
||||
->leftJoin('cal.mainUser', "{$p}_user")
|
||||
->leftJoin(
|
||||
UserScopeHistory::class,
|
||||
"{$p}_history",
|
||||
@@ -51,17 +51,17 @@ class ScopeFilter implements FilterInterface
|
||||
// scope_at based on cal.startDate
|
||||
->andWhere(
|
||||
$qb->expr()->andX(
|
||||
$qb->expr()->lte("{$p}_history.startDate", "cal.startDate"),
|
||||
$qb->expr()->lte("{$p}_history.startDate", 'cal.startDate'),
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull("{$p}_history.endDate"),
|
||||
$qb->expr()->gt("{$p}_history.endDate", "cal.startDate")
|
||||
$qb->expr()->gt("{$p}_history.endDate", 'cal.startDate')
|
||||
)
|
||||
)
|
||||
)
|
||||
->andWhere($qb->expr()->in("{$p}_history.scope", ":{$p}_scope"))
|
||||
->setParameter(
|
||||
"{$p}_scope",
|
||||
$data["scope"]
|
||||
$data['scope']
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -12,7 +12,6 @@ declare(strict_types=1);
|
||||
namespace Chill\CalendarBundle\Form;
|
||||
|
||||
use Chill\CalendarBundle\Entity\CalendarDoc\CalendarDocEditDTO;
|
||||
use Chill\DocStoreBundle\Form\StoredObjectType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
@@ -21,7 +21,6 @@ use Chill\MainBundle\Form\Type\CommentType;
|
||||
use Chill\MainBundle\Form\Type\PrivateCommentType;
|
||||
use Chill\PersonBundle\Form\DataTransformer\PersonsToIdDataTransformer;
|
||||
use Chill\ThirdPartyBundle\Form\DataTransformer\ThirdPartiesToIdDataTransformer;
|
||||
use DateTimeImmutable;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\CallbackTransformer;
|
||||
@@ -72,42 +71,42 @@ class CalendarType extends AbstractType
|
||||
$builder->add('startDate', HiddenType::class);
|
||||
$builder->get('startDate')
|
||||
->addModelTransformer(new CallbackTransformer(
|
||||
static function (?DateTimeImmutable $dateTimeImmutable): string {
|
||||
static function (?\DateTimeImmutable $dateTimeImmutable): string {
|
||||
if (null !== $dateTimeImmutable) {
|
||||
$res = date_format($dateTimeImmutable, DateTimeImmutable::ATOM);
|
||||
$res = date_format($dateTimeImmutable, \DateTimeImmutable::ATOM);
|
||||
} else {
|
||||
$res = '';
|
||||
}
|
||||
|
||||
return $res;
|
||||
},
|
||||
static function (?string $dateAsString): ?DateTimeImmutable {
|
||||
static function (?string $dateAsString): ?\DateTimeImmutable {
|
||||
if ('' === $dateAsString || null === $dateAsString) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return DateTimeImmutable::createFromFormat(DateTimeImmutable::ATOM, $dateAsString);
|
||||
return \DateTimeImmutable::createFromFormat(\DateTimeImmutable::ATOM, $dateAsString);
|
||||
}
|
||||
));
|
||||
|
||||
$builder->add('endDate', HiddenType::class);
|
||||
$builder->get('endDate')
|
||||
->addModelTransformer(new CallbackTransformer(
|
||||
static function (?DateTimeImmutable $dateTimeImmutable): string {
|
||||
static function (?\DateTimeImmutable $dateTimeImmutable): string {
|
||||
if (null !== $dateTimeImmutable) {
|
||||
$res = date_format($dateTimeImmutable, DateTimeImmutable::ATOM);
|
||||
$res = date_format($dateTimeImmutable, \DateTimeImmutable::ATOM);
|
||||
} else {
|
||||
$res = '';
|
||||
}
|
||||
|
||||
return $res;
|
||||
},
|
||||
static function (?string $dateAsString): ?DateTimeImmutable {
|
||||
static function (?string $dateAsString): ?\DateTimeImmutable {
|
||||
if ('' === $dateAsString || null === $dateAsString) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return DateTimeImmutable::createFromFormat(DateTimeImmutable::ATOM, $dateAsString);
|
||||
return \DateTimeImmutable::createFromFormat(\DateTimeImmutable::ATOM, $dateAsString);
|
||||
}
|
||||
));
|
||||
|
||||
|
@@ -21,7 +21,6 @@ namespace Chill\CalendarBundle\Messenger\Doctrine;
|
||||
use Chill\CalendarBundle\Entity\Calendar;
|
||||
use Chill\CalendarBundle\Messenger\Message\CalendarMessage;
|
||||
use Chill\CalendarBundle\Messenger\Message\CalendarRemovedMessage;
|
||||
use Doctrine\ORM\Event\LifecycleEventArgs;
|
||||
use Doctrine\ORM\Event\PostPersistEventArgs;
|
||||
use Doctrine\ORM\Event\PostRemoveEventArgs;
|
||||
use Doctrine\ORM\Event\PostUpdateEventArgs;
|
||||
|
@@ -21,7 +21,6 @@ namespace Chill\CalendarBundle\Messenger\Doctrine;
|
||||
use Chill\CalendarBundle\Entity\CalendarRange;
|
||||
use Chill\CalendarBundle\Messenger\Message\CalendarRangeMessage;
|
||||
use Chill\CalendarBundle\Messenger\Message\CalendarRangeRemovedMessage;
|
||||
use Doctrine\ORM\Event\LifecycleEventArgs;
|
||||
use Doctrine\ORM\Event\PostPersistEventArgs;
|
||||
use Doctrine\ORM\Event\PostRemoveEventArgs;
|
||||
use Doctrine\ORM\Event\PostUpdateEventArgs;
|
||||
|
@@ -43,7 +43,7 @@ class MSGraphChangeNotificationHandler implements MessageHandlerInterface
|
||||
$user = $this->userRepository->find($changeNotificationMessage->getUserId());
|
||||
|
||||
if (null === $user) {
|
||||
$this->logger->warning(self::class . ' notification concern non-existent user, skipping');
|
||||
$this->logger->warning(self::class.' notification concern non-existent user, skipping');
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -52,7 +52,7 @@ class MSGraphChangeNotificationHandler implements MessageHandlerInterface
|
||||
$secret = $this->mapCalendarToUser->getSubscriptionSecret($user);
|
||||
|
||||
if ($secret !== ($notification['clientState'] ?? -1)) {
|
||||
$this->logger->warning(self::class . ' could not validate secret, skipping');
|
||||
$this->logger->warning(self::class.' could not validate secret, skipping');
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -67,7 +67,7 @@ class MSGraphChangeNotificationHandler implements MessageHandlerInterface
|
||||
$this->calendarSyncer->handleCalendarSync($calendar, $notification, $user);
|
||||
$this->em->flush();
|
||||
} else {
|
||||
$this->logger->info(self::class . ' id not found in any calendar nor calendar range');
|
||||
$this->logger->info(self::class.' id not found in any calendar nor calendar range');
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -19,8 +19,6 @@ declare(strict_types=1);
|
||||
namespace Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use DateTimeImmutable;
|
||||
use LogicException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
@@ -33,18 +31,18 @@ class EventsOnUserSubscriptionCreator
|
||||
public function __construct(private readonly LoggerInterface $logger, private readonly MachineHttpClient $machineHttpClient, private readonly MapCalendarToUser $mapCalendarToUser, private readonly UrlGeneratorInterface $urlGenerator) {}
|
||||
|
||||
/**
|
||||
* @return array{secret: string, id: string, expiration: int}
|
||||
*
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws \Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface
|
||||
* @throws \Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface
|
||||
* @throws \Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface
|
||||
* @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
|
||||
*
|
||||
* @return array<secret: string, id: string, expiration: int>
|
||||
*/
|
||||
public function createSubscriptionForUser(User $user, DateTimeImmutable $expiration): array
|
||||
public function createSubscriptionForUser(User $user, \DateTimeImmutable $expiration): array
|
||||
{
|
||||
if (null === $userId = $this->mapCalendarToUser->getUserId($user)) {
|
||||
throw new LogicException('no user id');
|
||||
throw new \LogicException('no user id');
|
||||
}
|
||||
|
||||
$subscription = [
|
||||
@@ -56,7 +54,7 @@ class EventsOnUserSubscriptionCreator
|
||||
),
|
||||
'resource' => "/users/{$userId}/calendar/events",
|
||||
'clientState' => $secret = base64_encode(openssl_random_pseudo_bytes(92, $cstrong)),
|
||||
'expirationDateTime' => $expiration->format(DateTimeImmutable::ATOM),
|
||||
'expirationDateTime' => $expiration->format(\DateTimeImmutable::ATOM),
|
||||
];
|
||||
|
||||
try {
|
||||
@@ -79,26 +77,26 @@ class EventsOnUserSubscriptionCreator
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{secret: string, id: string, expiration: int}
|
||||
*
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws \Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface
|
||||
* @throws \Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface
|
||||
* @throws \Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface
|
||||
* @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
|
||||
*
|
||||
* @return array<secret: string, id: string, expiration: int>
|
||||
*/
|
||||
public function renewSubscriptionForUser(User $user, DateTimeImmutable $expiration): array
|
||||
public function renewSubscriptionForUser(User $user, \DateTimeImmutable $expiration): array
|
||||
{
|
||||
if (null === $userId = $this->mapCalendarToUser->getUserId($user)) {
|
||||
throw new LogicException('no user id');
|
||||
throw new \LogicException('no user id');
|
||||
}
|
||||
|
||||
if (null === $subscriptionId = $this->mapCalendarToUser->getActiveSubscriptionId($user)) {
|
||||
throw new LogicException('no user id');
|
||||
throw new \LogicException('no user id');
|
||||
}
|
||||
|
||||
$subscription = [
|
||||
'expirationDateTime' => $expiration->format(DateTimeImmutable::ATOM),
|
||||
'expirationDateTime' => $expiration->format(\DateTimeImmutable::ATOM),
|
||||
];
|
||||
|
||||
try {
|
||||
|
@@ -13,7 +13,6 @@ namespace Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph;
|
||||
|
||||
use Chill\CalendarBundle\Exception\UserAbsenceSyncException;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Clock\ClockInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
|
||||
@@ -43,25 +42,24 @@ final readonly class MSUserAbsenceReader implements MSUserAbsenceReaderInterface
|
||||
|
||||
try {
|
||||
$automaticRepliesSettings = $this->machineHttpClient
|
||||
->request('GET', 'users/' . $id . '/mailboxSettings/automaticRepliesSetting')
|
||||
->request('GET', 'users/'.$id.'/mailboxSettings/automaticRepliesSetting')
|
||||
->toArray(true);
|
||||
} catch (ClientExceptionInterface|DecodingExceptionInterface|RedirectionExceptionInterface|TransportExceptionInterface $e) {
|
||||
throw new UserAbsenceSyncException("Error receiving response for mailboxSettings", 0, $e);
|
||||
throw new UserAbsenceSyncException('Error receiving response for mailboxSettings', 0, $e);
|
||||
} catch (ServerExceptionInterface $e) {
|
||||
throw new UserAbsenceSyncException("Server error receiving response for mailboxSettings", 0, $e);
|
||||
throw new UserAbsenceSyncException('Server error receiving response for mailboxSettings', 0, $e);
|
||||
}
|
||||
|
||||
if (!array_key_exists("status", $automaticRepliesSettings)) {
|
||||
throw new \LogicException("no key \"status\" on automatic replies settings: " . json_encode($automaticRepliesSettings, JSON_THROW_ON_ERROR));
|
||||
if (!array_key_exists('status', $automaticRepliesSettings)) {
|
||||
throw new \LogicException('no key "status" on automatic replies settings: '.json_encode($automaticRepliesSettings, JSON_THROW_ON_ERROR));
|
||||
}
|
||||
|
||||
return match ($automaticRepliesSettings['status']) {
|
||||
'disabled' => false,
|
||||
'alwaysEnabled' => true,
|
||||
'scheduled' =>
|
||||
RemoteEventConverter::convertStringDateWithoutTimezone($automaticRepliesSettings['scheduledStartDateTime']['dateTime']) < $this->clock->now()
|
||||
'scheduled' => RemoteEventConverter::convertStringDateWithoutTimezone($automaticRepliesSettings['scheduledStartDateTime']['dateTime']) < $this->clock->now()
|
||||
&& RemoteEventConverter::convertStringDateWithoutTimezone($automaticRepliesSettings['scheduledEndDateTime']['dateTime']) > $this->clock->now(),
|
||||
default => throw new UserAbsenceSyncException("this status is not documented by Microsoft")
|
||||
default => throw new UserAbsenceSyncException('this status is not documented by Microsoft')
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -36,13 +36,13 @@ readonly class MSUserAbsenceSync
|
||||
return;
|
||||
}
|
||||
|
||||
$this->logger->info("will change user absence", ['userId' => $user->getId()]);
|
||||
$this->logger->info('will change user absence', ['userId' => $user->getId()]);
|
||||
|
||||
if ($absence) {
|
||||
$this->logger->debug("make user absent", ['userId' => $user->getId()]);
|
||||
$this->logger->debug('make user absent', ['userId' => $user->getId()]);
|
||||
$user->setAbsenceStart($this->clock->now());
|
||||
} else {
|
||||
$this->logger->debug("make user present", ['userId' => $user->getId()]);
|
||||
$this->logger->debug('make user present', ['userId' => $user->getId()]);
|
||||
$user->setAbsenceStart(null);
|
||||
}
|
||||
}
|
||||
|
@@ -19,7 +19,6 @@ declare(strict_types=1);
|
||||
namespace Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph;
|
||||
|
||||
use League\OAuth2\Client\Tool\BearerAuthorizationTrait;
|
||||
use LogicException;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
use Symfony\Contracts\HttpClient\ResponseInterface;
|
||||
use Symfony\Contracts\HttpClient\ResponseStreamInterface;
|
||||
@@ -30,17 +29,14 @@ class MachineHttpClient implements HttpClientInterface
|
||||
|
||||
private readonly HttpClientInterface $decoratedClient;
|
||||
|
||||
/**
|
||||
* @param HttpClientInterface $decoratedClient
|
||||
*/
|
||||
public function __construct(private readonly MachineTokenStorage $machineTokenStorage, ?HttpClientInterface $decoratedClient = null)
|
||||
public function __construct(private readonly MachineTokenStorage $machineTokenStorage, HttpClientInterface $decoratedClient = null)
|
||||
{
|
||||
$this->decoratedClient = $decoratedClient ?? \Symfony\Component\HttpClient\HttpClient::create();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
|
||||
* @throws LogicException if method is not supported
|
||||
* @throws \LogicException if method is not supported
|
||||
*/
|
||||
public function request(string $method, string $url, array $options = []): ResponseInterface
|
||||
{
|
||||
@@ -66,13 +62,13 @@ class MachineHttpClient implements HttpClientInterface
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new LogicException("Method not supported: {$method}");
|
||||
throw new \LogicException("Method not supported: {$method}");
|
||||
}
|
||||
|
||||
return $this->decoratedClient->request($method, $url, $options);
|
||||
}
|
||||
|
||||
public function stream($responses, ?float $timeout = null): ResponseStreamInterface
|
||||
public function stream($responses, float $timeout = null): ResponseStreamInterface
|
||||
{
|
||||
return $this->decoratedClient->stream($responses, $timeout);
|
||||
}
|
||||
|
@@ -19,12 +19,9 @@ declare(strict_types=1);
|
||||
namespace Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use DateTimeImmutable;
|
||||
use LogicException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
use function array_key_exists;
|
||||
|
||||
/**
|
||||
* Write metadata to user, which allow to find his default calendar.
|
||||
@@ -43,12 +40,12 @@ class MapCalendarToUser
|
||||
|
||||
public function getActiveSubscriptionId(User $user): string
|
||||
{
|
||||
if (!array_key_exists(self::METADATA_KEY, $user->getAttributes())) {
|
||||
throw new LogicException('do not contains msgraph metadata');
|
||||
if (!\array_key_exists(self::METADATA_KEY, $user->getAttributes())) {
|
||||
throw new \LogicException('do not contains msgraph metadata');
|
||||
}
|
||||
|
||||
if (!array_key_exists(self::ID_SUBSCRIPTION_EVENT, $user->getAttributes()[self::METADATA_KEY])) {
|
||||
throw new LogicException('do not contains metadata for subscription id');
|
||||
if (!\array_key_exists(self::ID_SUBSCRIPTION_EVENT, $user->getAttributes()[self::METADATA_KEY])) {
|
||||
throw new \LogicException('do not contains metadata for subscription id');
|
||||
}
|
||||
|
||||
return $user->getAttributes()[self::METADATA_KEY][self::ID_SUBSCRIPTION_EVENT];
|
||||
@@ -83,12 +80,12 @@ class MapCalendarToUser
|
||||
|
||||
public function getSubscriptionSecret(User $user): string
|
||||
{
|
||||
if (!array_key_exists(self::METADATA_KEY, $user->getAttributes())) {
|
||||
throw new LogicException('do not contains msgraph metadata');
|
||||
if (!\array_key_exists(self::METADATA_KEY, $user->getAttributes())) {
|
||||
throw new \LogicException('do not contains msgraph metadata');
|
||||
}
|
||||
|
||||
if (!array_key_exists(self::SECRET_SUBSCRIPTION_EVENT, $user->getAttributes()[self::METADATA_KEY])) {
|
||||
throw new LogicException('do not contains secret in msgraph');
|
||||
if (!\array_key_exists(self::SECRET_SUBSCRIPTION_EVENT, $user->getAttributes()[self::METADATA_KEY])) {
|
||||
throw new \LogicException('do not contains secret in msgraph');
|
||||
}
|
||||
|
||||
return $user->getAttributes()[self::METADATA_KEY][self::SECRET_SUBSCRIPTION_EVENT];
|
||||
@@ -114,25 +111,25 @@ class MapCalendarToUser
|
||||
|
||||
public function hasActiveSubscription(User $user): bool
|
||||
{
|
||||
if (!array_key_exists(self::METADATA_KEY, $user->getAttributes())) {
|
||||
if (!\array_key_exists(self::METADATA_KEY, $user->getAttributes())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!array_key_exists(self::EXPIRATION_SUBSCRIPTION_EVENT, $user->getAttributes()[self::METADATA_KEY])) {
|
||||
if (!\array_key_exists(self::EXPIRATION_SUBSCRIPTION_EVENT, $user->getAttributes()[self::METADATA_KEY])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $user->getAttributes()[self::METADATA_KEY][self::EXPIRATION_SUBSCRIPTION_EVENT]
|
||||
>= (new DateTimeImmutable('now'))->getTimestamp();
|
||||
>= (new \DateTimeImmutable('now'))->getTimestamp();
|
||||
}
|
||||
|
||||
public function hasSubscriptionSecret(User $user): bool
|
||||
{
|
||||
if (!array_key_exists(self::METADATA_KEY, $user->getAttributes())) {
|
||||
if (!\array_key_exists(self::METADATA_KEY, $user->getAttributes())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return array_key_exists(self::SECRET_SUBSCRIPTION_EVENT, $user->getAttributes()[self::METADATA_KEY]);
|
||||
return \array_key_exists(self::SECRET_SUBSCRIPTION_EVENT, $user->getAttributes()[self::METADATA_KEY]);
|
||||
}
|
||||
|
||||
public function hasUserId(User $user): bool
|
||||
@@ -141,11 +138,11 @@ class MapCalendarToUser
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!array_key_exists(self::METADATA_KEY, $user->getAttributes())) {
|
||||
if (!\array_key_exists(self::METADATA_KEY, $user->getAttributes())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return array_key_exists('id', $user->getAttributes()[self::METADATA_KEY]);
|
||||
return \array_key_exists('id', $user->getAttributes()[self::METADATA_KEY]);
|
||||
}
|
||||
|
||||
public function writeMetadata(User $user): User
|
||||
@@ -179,8 +176,8 @@ class MapCalendarToUser
|
||||
public function writeSubscriptionMetadata(
|
||||
User $user,
|
||||
int $expiration,
|
||||
?string $id = null,
|
||||
?string $secret = null
|
||||
string $id = null,
|
||||
string $secret = null
|
||||
): void {
|
||||
$user->setAttributeByDomain(self::METADATA_KEY, self::EXPIRATION_SUBSCRIPTION_EVENT, $expiration);
|
||||
|
||||
|
@@ -19,7 +19,6 @@ declare(strict_types=1);
|
||||
namespace Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph;
|
||||
|
||||
use League\OAuth2\Client\Tool\BearerAuthorizationTrait;
|
||||
use LogicException;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
use Symfony\Contracts\HttpClient\ResponseInterface;
|
||||
use Symfony\Contracts\HttpClient\ResponseStreamInterface;
|
||||
@@ -30,10 +29,7 @@ class OnBehalfOfUserHttpClient
|
||||
|
||||
private readonly HttpClientInterface $decoratedClient;
|
||||
|
||||
/**
|
||||
* @param HttpClientInterface $decoratedClient
|
||||
*/
|
||||
public function __construct(private readonly OnBehalfOfUserTokenStorage $tokenStorage, ?HttpClientInterface $decoratedClient = null)
|
||||
public function __construct(private readonly OnBehalfOfUserTokenStorage $tokenStorage, HttpClientInterface $decoratedClient = null)
|
||||
{
|
||||
$this->decoratedClient = $decoratedClient ?? \Symfony\Component\HttpClient\HttpClient::create();
|
||||
}
|
||||
@@ -61,13 +57,13 @@ class OnBehalfOfUserHttpClient
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new LogicException("Method not supported: {$method}");
|
||||
throw new \LogicException("Method not supported: {$method}");
|
||||
}
|
||||
|
||||
return $this->decoratedClient->request($method, $url, $options);
|
||||
}
|
||||
|
||||
public function stream($responses, ?float $timeout = null): ResponseStreamInterface
|
||||
public function stream($responses, float $timeout = null): ResponseStreamInterface
|
||||
{
|
||||
return $this->decoratedClient->stream($responses, $timeout);
|
||||
}
|
||||
|
@@ -18,7 +18,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph;
|
||||
|
||||
use LogicException;
|
||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||
use TheNetworg\OAuth2\Client\Provider\Azure;
|
||||
use TheNetworg\OAuth2\Client\Token\AccessToken;
|
||||
@@ -38,7 +37,7 @@ class OnBehalfOfUserTokenStorage
|
||||
$token = $this->session->get(self::MS_GRAPH_ACCESS_TOKEN, null);
|
||||
|
||||
if (null === $token) {
|
||||
throw new LogicException('unexisting token');
|
||||
throw new \LogicException('unexisting token');
|
||||
}
|
||||
|
||||
if ($token->hasExpired()) {
|
||||
|
@@ -24,11 +24,7 @@ use Chill\CalendarBundle\Entity\Invite;
|
||||
use Chill\CalendarBundle\RemoteCalendar\Model\RemoteEvent;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Templating\Entity\PersonRenderInterface;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeZone;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use RuntimeException;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
@@ -52,9 +48,9 @@ class RemoteEventConverter
|
||||
|
||||
private const REMOTE_DATETIME_WITHOUT_TZ_FORMAT = 'Y-m-d\TH:i:s.u?';
|
||||
|
||||
private readonly DateTimeZone $defaultDateTimeZone;
|
||||
private readonly \DateTimeZone $defaultDateTimeZone;
|
||||
|
||||
private readonly DateTimeZone $remoteDateTimeZone;
|
||||
private readonly \DateTimeZone $remoteDateTimeZone;
|
||||
|
||||
public function __construct(
|
||||
private readonly \Twig\Environment $engine,
|
||||
@@ -63,7 +59,7 @@ class RemoteEventConverter
|
||||
private readonly PersonRenderInterface $personRender,
|
||||
private readonly TranslatorInterface $translator
|
||||
) {
|
||||
$this->defaultDateTimeZone = (new DateTimeImmutable())->getTimezone();
|
||||
$this->defaultDateTimeZone = (new \DateTimeImmutable())->getTimezone();
|
||||
$this->remoteDateTimeZone = self::getRemoteTimeZone();
|
||||
}
|
||||
|
||||
@@ -103,7 +99,7 @@ class RemoteEventConverter
|
||||
{
|
||||
$result = array_merge(
|
||||
[
|
||||
'subject' => '[Chill] ' .
|
||||
'subject' => '[Chill] '.
|
||||
implode(
|
||||
', ',
|
||||
$calendar->getPersons()->map(fn (Person $p) => $this->personRender->renderString($p, []))->toArray()
|
||||
@@ -119,7 +115,7 @@ class RemoteEventConverter
|
||||
'timeZone' => 'UTC',
|
||||
],
|
||||
'allowNewTimeProposals' => false,
|
||||
'transactionId' => 'calendar_' . $calendar->getId(),
|
||||
'transactionId' => 'calendar_'.$calendar->getId(),
|
||||
'body' => [
|
||||
'contentType' => 'text',
|
||||
'content' => $this->engine->render(
|
||||
@@ -152,45 +148,45 @@ class RemoteEventConverter
|
||||
public function convertAvailabilityToRemoteEvent(array $event): RemoteEvent
|
||||
{
|
||||
$startDate =
|
||||
DateTimeImmutable::createFromFormat(self::REMOTE_DATE_FORMAT, $event['start']['dateTime'], $this->remoteDateTimeZone)
|
||||
\DateTimeImmutable::createFromFormat(self::REMOTE_DATE_FORMAT, $event['start']['dateTime'], $this->remoteDateTimeZone)
|
||||
->setTimezone($this->defaultDateTimeZone);
|
||||
$endDate =
|
||||
DateTimeImmutable::createFromFormat(self::REMOTE_DATE_FORMAT, $event['end']['dateTime'], $this->remoteDateTimeZone)
|
||||
\DateTimeImmutable::createFromFormat(self::REMOTE_DATE_FORMAT, $event['end']['dateTime'], $this->remoteDateTimeZone)
|
||||
->setTimezone($this->defaultDateTimeZone);
|
||||
|
||||
return new RemoteEvent(
|
||||
uniqid('generated_'),
|
||||
$this->translator->trans('remote_ms_graph.freebusy_statuses.' . $event['status']),
|
||||
$this->translator->trans('remote_ms_graph.freebusy_statuses.'.$event['status']),
|
||||
'',
|
||||
$startDate,
|
||||
$endDate
|
||||
);
|
||||
}
|
||||
|
||||
public static function convertStringDateWithoutTimezone(string $date): DateTimeImmutable
|
||||
public static function convertStringDateWithoutTimezone(string $date): \DateTimeImmutable
|
||||
{
|
||||
$d = DateTimeImmutable::createFromFormat(
|
||||
$d = \DateTimeImmutable::createFromFormat(
|
||||
self::REMOTE_DATETIME_WITHOUT_TZ_FORMAT,
|
||||
$date,
|
||||
self::getRemoteTimeZone()
|
||||
);
|
||||
|
||||
if (false === $d) {
|
||||
throw new RuntimeException("could not convert string date to datetime: {$date}");
|
||||
throw new \RuntimeException("could not convert string date to datetime: {$date}");
|
||||
}
|
||||
|
||||
return $d->setTimezone((new DateTimeImmutable())->getTimezone());
|
||||
return $d->setTimezone((new \DateTimeImmutable())->getTimezone());
|
||||
}
|
||||
|
||||
public static function convertStringDateWithTimezone(string $date): DateTimeImmutable
|
||||
public static function convertStringDateWithTimezone(string $date): \DateTimeImmutable
|
||||
{
|
||||
$d = DateTimeImmutable::createFromFormat(self::REMOTE_DATETIMEZONE_FORMAT, $date);
|
||||
$d = \DateTimeImmutable::createFromFormat(self::REMOTE_DATETIMEZONE_FORMAT, $date);
|
||||
|
||||
if (false === $d) {
|
||||
throw new RuntimeException("could not convert string date to datetime: {$date}");
|
||||
throw new \RuntimeException("could not convert string date to datetime: {$date}");
|
||||
}
|
||||
|
||||
$d->setTimezone((new DateTimeImmutable())->getTimezone());
|
||||
$d->setTimezone((new \DateTimeImmutable())->getTimezone());
|
||||
|
||||
return $d;
|
||||
}
|
||||
@@ -198,10 +194,10 @@ class RemoteEventConverter
|
||||
public function convertToRemote(array $event): RemoteEvent
|
||||
{
|
||||
$startDate =
|
||||
DateTimeImmutable::createFromFormat(self::REMOTE_DATE_FORMAT, $event['start']['dateTime'], $this->remoteDateTimeZone)
|
||||
\DateTimeImmutable::createFromFormat(self::REMOTE_DATE_FORMAT, $event['start']['dateTime'], $this->remoteDateTimeZone)
|
||||
->setTimezone($this->defaultDateTimeZone);
|
||||
$endDate =
|
||||
DateTimeImmutable::createFromFormat(self::REMOTE_DATE_FORMAT, $event['end']['dateTime'], $this->remoteDateTimeZone)
|
||||
\DateTimeImmutable::createFromFormat(self::REMOTE_DATE_FORMAT, $event['end']['dateTime'], $this->remoteDateTimeZone)
|
||||
->setTimezone($this->defaultDateTimeZone);
|
||||
|
||||
return new RemoteEvent(
|
||||
@@ -214,26 +210,22 @@ class RemoteEventConverter
|
||||
);
|
||||
}
|
||||
|
||||
public function getLastModifiedDate(array $event): DateTimeImmutable
|
||||
public function getLastModifiedDate(array $event): \DateTimeImmutable
|
||||
{
|
||||
$date = DateTimeImmutable::createFromFormat(self::REMOTE_DATETIMEZONE_FORMAT, $event['lastModifiedDateTime']);
|
||||
$date = \DateTimeImmutable::createFromFormat(self::REMOTE_DATETIMEZONE_FORMAT, $event['lastModifiedDateTime']);
|
||||
|
||||
if (false === $date) {
|
||||
$date = DateTimeImmutable::createFromFormat(self::REMOTE_DATETIMEZONE_FORMAT_ALT, $event['lastModifiedDateTime']);
|
||||
$date = \DateTimeImmutable::createFromFormat(self::REMOTE_DATETIMEZONE_FORMAT_ALT, $event['lastModifiedDateTime']);
|
||||
}
|
||||
|
||||
if (false === $date) {
|
||||
$this->logger->error(self::class . ' Could not convert lastModifiedDate', [
|
||||
$this->logger->error(self::class.' Could not convert lastModifiedDate', [
|
||||
'actual' => $event['lastModifiedDateTime'],
|
||||
'format' => self::REMOTE_DATETIMEZONE_FORMAT,
|
||||
'format_alt' => self::REMOTE_DATETIMEZONE_FORMAT_ALT,
|
||||
]);
|
||||
|
||||
throw new RuntimeException(sprintf(
|
||||
'could not convert lastModifiedDate: %s, expected format: %s',
|
||||
$event['lastModifiedDateTime'],
|
||||
self::REMOTE_DATETIMEZONE_FORMAT . ' and ' . self::REMOTE_DATETIMEZONE_FORMAT_ALT
|
||||
));
|
||||
throw new \RuntimeException(sprintf('could not convert lastModifiedDate: %s, expected format: %s', $event['lastModifiedDateTime'], self::REMOTE_DATETIMEZONE_FORMAT.' and '.self::REMOTE_DATETIMEZONE_FORMAT_ALT));
|
||||
}
|
||||
|
||||
return $date;
|
||||
@@ -247,9 +239,9 @@ class RemoteEventConverter
|
||||
return 'Y-m-d\TH:i:s';
|
||||
}
|
||||
|
||||
public static function getRemoteTimeZone(): DateTimeZone
|
||||
public static function getRemoteTimeZone(): \DateTimeZone
|
||||
{
|
||||
return new DateTimeZone('UTC');
|
||||
return new \DateTimeZone('UTC');
|
||||
}
|
||||
|
||||
private function buildInviteToAttendee(Invite $invite): array
|
||||
|
@@ -24,7 +24,6 @@ use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\RemoteEventConverter;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use RuntimeException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
|
||||
@@ -45,7 +44,7 @@ class CalendarRangeSyncer
|
||||
}
|
||||
$calendarRange->preventEnqueueChanges = true;
|
||||
|
||||
$this->logger->info(self::class . ' remove a calendar range because deleted on remote calendar');
|
||||
$this->logger->info(self::class.' remove a calendar range because deleted on remote calendar');
|
||||
$this->em->remove($calendarRange);
|
||||
|
||||
break;
|
||||
@@ -57,7 +56,7 @@ class CalendarRangeSyncer
|
||||
$notification['resource']
|
||||
)->toArray();
|
||||
} catch (ClientExceptionInterface $clientException) {
|
||||
$this->logger->warning(self::class . ' could not retrieve event from ms graph. Already deleted ?', [
|
||||
$this->logger->warning(self::class.' could not retrieve event from ms graph. Already deleted ?', [
|
||||
'calendarRangeId' => $calendarRange->getId(),
|
||||
'remoteEventId' => $notification['resource'],
|
||||
]);
|
||||
@@ -68,7 +67,7 @@ class CalendarRangeSyncer
|
||||
$lastModified = RemoteEventConverter::convertStringDateWithTimezone($new['lastModifiedDateTime']);
|
||||
|
||||
if ($calendarRange->getRemoteAttributes()['lastModifiedDateTime'] === $lastModified->getTimestamp()) {
|
||||
$this->logger->info(self::class . ' change key is equals. Source is probably a local update', [
|
||||
$this->logger->info(self::class.' change key is equals. Source is probably a local update', [
|
||||
'calendarRangeId' => $calendarRange->getId(),
|
||||
'remoteEventId' => $notification['resource'],
|
||||
]);
|
||||
@@ -90,7 +89,7 @@ class CalendarRangeSyncer
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new RuntimeException('This changeType is not suppored: ' . $notification['changeType']);
|
||||
throw new \RuntimeException('This changeType is not suppored: '.$notification['changeType']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -23,12 +23,9 @@ use Chill\CalendarBundle\Entity\Invite;
|
||||
use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\RemoteEventConverter;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Repository\UserRepositoryInterface;
|
||||
use LogicException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use RuntimeException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
use function in_array;
|
||||
|
||||
class CalendarSyncer
|
||||
{
|
||||
@@ -39,7 +36,7 @@ class CalendarSyncer
|
||||
match ($notification['changeType']) {
|
||||
'deleted' => $this->handleDeleteCalendar($calendar, $notification, $user),
|
||||
'updated' => $this->handleUpdateCalendar($calendar, $notification, $user),
|
||||
default => throw new RuntimeException('this change type is not supported: ' . $notification['changeType']),
|
||||
default => throw new \RuntimeException('this change type is not supported: '.$notification['changeType']),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -59,7 +56,7 @@ class CalendarSyncer
|
||||
$notification['resource']
|
||||
)->toArray();
|
||||
} catch (ClientExceptionInterface $clientException) {
|
||||
$this->logger->warning(self::class . ' could not retrieve event from ms graph. Already deleted ?', [
|
||||
$this->logger->warning(self::class.' could not retrieve event from ms graph. Already deleted ?', [
|
||||
'calendarId' => $calendar->getId(),
|
||||
'remoteEventId' => $notification['resource'],
|
||||
]);
|
||||
@@ -76,7 +73,7 @@ class CalendarSyncer
|
||||
);
|
||||
|
||||
if ($calendar->getRemoteAttributes()['lastModifiedDateTime'] === $lastModified->getTimestamp()) {
|
||||
$this->logger->info(self::class . ' change key is equals. Source is probably a local update', [
|
||||
$this->logger->info(self::class.' change key is equals. Source is probably a local update', [
|
||||
'calendarRangeId' => $calendar->getId(),
|
||||
'remoteEventId' => $notification['resource'],
|
||||
]);
|
||||
@@ -135,12 +132,12 @@ class CalendarSyncer
|
||||
'tentativelyAccepted' => $invite->setStatus(Invite::TENTATIVELY_ACCEPTED),
|
||||
'accepted' => $invite->setStatus(Invite::ACCEPTED),
|
||||
'declined' => $invite->setStatus(Invite::DECLINED),
|
||||
default => throw new LogicException('should not happens, not implemented: ' . $status),
|
||||
default => throw new \LogicException('should not happens, not implemented: '.$status),
|
||||
};
|
||||
}
|
||||
|
||||
foreach ($calendar->getUsers() as $user) {
|
||||
if (!in_array(strtolower($user->getEmailCanonical()), $emails, true)) {
|
||||
if (!\in_array(strtolower($user->getEmailCanonical()), $emails, true)) {
|
||||
$calendar->removeUser($user);
|
||||
}
|
||||
}
|
||||
|
@@ -28,8 +28,6 @@ use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\RemoteEventConverter;
|
||||
use Chill\CalendarBundle\Repository\CalendarRangeRepository;
|
||||
use Chill\CalendarBundle\Repository\CalendarRepository;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use DateTimeImmutable;
|
||||
use Exception;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
@@ -38,8 +36,6 @@ use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use function array_key_exists;
|
||||
use function count;
|
||||
|
||||
class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
{
|
||||
@@ -47,7 +43,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
|
||||
public function __construct(private readonly CalendarRepository $calendarRepository, private readonly CalendarRangeRepository $calendarRangeRepository, private readonly HttpClientInterface $machineHttpClient, private readonly MapCalendarToUser $mapCalendarToUser, private readonly LoggerInterface $logger, private readonly OnBehalfOfUserTokenStorage $tokenStorage, private readonly OnBehalfOfUserHttpClient $userHttpClient, private readonly RemoteEventConverter $remoteEventConverter, private readonly TranslatorInterface $translator, private readonly UrlGeneratorInterface $urlGenerator, private readonly Security $security) {}
|
||||
|
||||
public function countEventsForUser(User $user, DateTimeImmutable $startDate, DateTimeImmutable $endDate): int
|
||||
public function countEventsForUser(User $user, \DateTimeImmutable $startDate, \DateTimeImmutable $endDate): int
|
||||
{
|
||||
$userId = $this->mapCalendarToUser->getUserId($user);
|
||||
|
||||
@@ -58,7 +54,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
try {
|
||||
$data = $this->userHttpClient->request(
|
||||
'GET',
|
||||
'users/' . $userId . '/calendarView',
|
||||
'users/'.$userId.'/calendarView',
|
||||
[
|
||||
'query' => [
|
||||
'startDateTime' => $startDate->setTimezone(RemoteEventConverter::getRemoteTimeZone())->format(RemoteEventConverter::getRemoteDateTimeSimpleFormat()),
|
||||
@@ -70,7 +66,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
)->toArray();
|
||||
} catch (ClientExceptionInterface $e) {
|
||||
if (403 === $e->getResponse()->getStatusCode()) {
|
||||
return count($this->getScheduleTimesForUser($user, $startDate, $endDate));
|
||||
return \count($this->getScheduleTimesForUser($user, $startDate, $endDate));
|
||||
}
|
||||
|
||||
$this->logger->error('Could not get list of event on MSGraph', [
|
||||
@@ -107,6 +103,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
$this->logger->debug('mark user ready for msgraph calendar as he does not have any mapping', [
|
||||
'userId' => $user->getId(),
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -114,14 +111,14 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|\Chill\CalendarBundle\RemoteCalendar\Model\RemoteEvent[]
|
||||
*
|
||||
* @throws \Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface
|
||||
* @throws \Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface
|
||||
* @throws \Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface
|
||||
* @throws \Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface
|
||||
*
|
||||
* @return array|\Chill\CalendarBundle\RemoteCalendar\Model\RemoteEvent[]
|
||||
*/
|
||||
public function listEventsForUser(User $user, DateTimeImmutable $startDate, DateTimeImmutable $endDate, ?int $offset = 0, ?int $limit = 50): array
|
||||
public function listEventsForUser(User $user, \DateTimeImmutable $startDate, \DateTimeImmutable $endDate, ?int $offset = 0, ?int $limit = 50): array
|
||||
{
|
||||
$userId = $this->mapCalendarToUser->getUserId($user);
|
||||
|
||||
@@ -132,7 +129,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
try {
|
||||
$bareEvents = $this->userHttpClient->request(
|
||||
'GET',
|
||||
'users/' . $userId . '/calendarView',
|
||||
'users/'.$userId.'/calendarView',
|
||||
[
|
||||
'query' => [
|
||||
'startDateTime' => $startDate->setTimezone(RemoteEventConverter::getRemoteTimeZone())->format(RemoteEventConverter::getRemoteDateTimeSimpleFormat()),
|
||||
@@ -172,7 +169,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function removeCalendar(string $remoteId, array $remoteAttributes, User $user, ?CalendarRange $associatedCalendarRange = null): void
|
||||
public function removeCalendar(string $remoteId, array $remoteAttributes, User $user, CalendarRange $associatedCalendarRange = null): void
|
||||
{
|
||||
if ('' === $remoteId) {
|
||||
return;
|
||||
@@ -222,7 +219,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
$calendar->getRemoteId(),
|
||||
$this->translator->trans('remote_ms_graph.cancel_event_because_main_user_is_%label%', ['%label%' => $calendar->getMainUser()]),
|
||||
$previousMainUser,
|
||||
'calendar_' . $calendar->getRemoteId()
|
||||
'calendar_'.$calendar->getRemoteId()
|
||||
);
|
||||
$this->createCalendarOnRemote($calendar);
|
||||
} else {
|
||||
@@ -300,7 +297,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Exception('not supported');
|
||||
throw new \Exception('not supported');
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -313,7 +310,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
$this->logger->warning('could not update calendar range to remote', [
|
||||
'exception' => $e->getTraceAsString(),
|
||||
'content' => $e->getResponse()->getContent(),
|
||||
'calendarRangeId' => 'invite_' . $invite->getId(),
|
||||
'calendarRangeId' => 'invite_'.$invite->getId(),
|
||||
]);
|
||||
|
||||
throw $e;
|
||||
@@ -355,7 +352,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
'id' => $id,
|
||||
'lastModifiedDateTime' => $lastModified,
|
||||
'changeKey' => $changeKey
|
||||
] = $this->createOnRemote($eventData, $calendar->getMainUser(), 'calendar_' . $calendar->getId());
|
||||
] = $this->createOnRemote($eventData, $calendar->getMainUser(), 'calendar_'.$calendar->getId());
|
||||
|
||||
if (null === $id) {
|
||||
return;
|
||||
@@ -390,7 +387,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
try {
|
||||
$event = $this->machineHttpClient->request(
|
||||
'POST',
|
||||
'users/' . $userId . '/calendar/events',
|
||||
'users/'.$userId.'/calendar/events',
|
||||
[
|
||||
'json' => $eventData,
|
||||
]
|
||||
@@ -434,7 +431,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
] = $this->createOnRemote(
|
||||
$eventData,
|
||||
$calendarRange->getUser(),
|
||||
'calendar_range_' . $calendarRange->getId()
|
||||
'calendar_range_'.$calendarRange->getId()
|
||||
);
|
||||
|
||||
$calendarRange->setRemoteId($id)
|
||||
@@ -457,7 +454,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
$userId = $this->mapCalendarToUser->getUserId($user);
|
||||
|
||||
if ('' === $iCalUid = ($event['iCalUId'] ?? '')) {
|
||||
throw new Exception('no iCalUid for this event');
|
||||
throw new \Exception('no iCalUid for this event');
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -475,8 +472,8 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
throw $clientException;
|
||||
}
|
||||
|
||||
if (1 !== count($events['value'])) {
|
||||
throw new Exception('multiple events found with same iCalUid');
|
||||
if (1 !== \count($events['value'])) {
|
||||
throw new \Exception('multiple events found with same iCalUid');
|
||||
}
|
||||
|
||||
return $events['value'][0]['id'];
|
||||
@@ -487,19 +484,13 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
$userId = $this->mapCalendarToUser->getUserId($user);
|
||||
|
||||
if (null === $userId) {
|
||||
throw new Exception(
|
||||
sprintf(
|
||||
'no remote calendar for this user: %s, remoteid: %s',
|
||||
$user->getId(),
|
||||
$remoteId
|
||||
)
|
||||
);
|
||||
throw new \Exception(sprintf('no remote calendar for this user: %s, remoteid: %s', $user->getId(), $remoteId));
|
||||
}
|
||||
|
||||
try {
|
||||
return $this->machineHttpClient->request(
|
||||
'GET',
|
||||
'users/' . $userId . '/calendar/events/' . $remoteId
|
||||
'users/'.$userId.'/calendar/events/'.$remoteId
|
||||
)->toArray();
|
||||
} catch (ClientExceptionInterface $e) {
|
||||
$this->logger->warning('Could not get event from calendar', [
|
||||
@@ -510,11 +501,11 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
}
|
||||
}
|
||||
|
||||
private function getScheduleTimesForUser(User $user, DateTimeImmutable $startDate, DateTimeImmutable $endDate): array
|
||||
private function getScheduleTimesForUser(User $user, \DateTimeImmutable $startDate, \DateTimeImmutable $endDate): array
|
||||
{
|
||||
$userId = $this->mapCalendarToUser->getUserId($user);
|
||||
|
||||
if (array_key_exists($userId, $this->cacheScheduleTimeForUser)) {
|
||||
if (\array_key_exists($userId, $this->cacheScheduleTimeForUser)) {
|
||||
return $this->cacheScheduleTimeForUser[$userId];
|
||||
}
|
||||
|
||||
@@ -529,17 +520,17 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
$body = [
|
||||
'schedules' => [$user->getEmailCanonical()],
|
||||
'startTime' => [
|
||||
'dateTime' => ($startDate->setTimezone(RemoteEventConverter::getRemoteTimeZone())->format(RemoteEventConverter::getRemoteDateTimeSimpleFormat())),
|
||||
'dateTime' => $startDate->setTimezone(RemoteEventConverter::getRemoteTimeZone())->format(RemoteEventConverter::getRemoteDateTimeSimpleFormat()),
|
||||
'timeZone' => 'UTC',
|
||||
],
|
||||
'endTime' => [
|
||||
'dateTime' => ($endDate->setTimezone(RemoteEventConverter::getRemoteTimeZone())->format(RemoteEventConverter::getRemoteDateTimeSimpleFormat())),
|
||||
'dateTime' => $endDate->setTimezone(RemoteEventConverter::getRemoteTimeZone())->format(RemoteEventConverter::getRemoteDateTimeSimpleFormat()),
|
||||
'timeZone' => 'UTC',
|
||||
],
|
||||
];
|
||||
|
||||
try {
|
||||
$response = $this->userHttpClient->request('POST', 'users/' . $userId . '/calendar/getSchedule', [
|
||||
$response = $this->userHttpClient->request('POST', 'users/'.$userId.'/calendar/getSchedule', [
|
||||
'json' => $body,
|
||||
])->toArray();
|
||||
} catch (ClientExceptionInterface $e) {
|
||||
@@ -564,7 +555,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
$eventDatas = [];
|
||||
$eventDatas[] = $this->remoteEventConverter->calendarToEvent($calendar);
|
||||
|
||||
if (0 < count($newInvites)) {
|
||||
if (0 < \count($newInvites)) {
|
||||
// it seems that invitaiton are always send, even if attendee changes are mixed with other datas
|
||||
// $eventDatas[] = $this->remoteEventConverter->calendarToEventAttendeesOnly($calendar);
|
||||
}
|
||||
@@ -578,7 +569,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
$calendar->getRemoteId(),
|
||||
$eventData,
|
||||
$calendar->getMainUser(),
|
||||
'calendar_' . $calendar->getId()
|
||||
'calendar_'.$calendar->getId()
|
||||
);
|
||||
|
||||
$calendar->addRemoteAttributes([
|
||||
@@ -609,7 +600,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
try {
|
||||
$event = $this->machineHttpClient->request(
|
||||
'PATCH',
|
||||
'users/' . $userId . '/calendar/events/' . $remoteId,
|
||||
'users/'.$userId.'/calendar/events/'.$remoteId,
|
||||
[
|
||||
'json' => $eventData,
|
||||
]
|
||||
@@ -637,7 +628,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
try {
|
||||
$this->machineHttpClient->request(
|
||||
'DELETE',
|
||||
'users/' . $userId . '/calendar/events/' . $remoteId
|
||||
'users/'.$userId.'/calendar/events/'.$remoteId
|
||||
);
|
||||
} catch (ClientExceptionInterface) {
|
||||
$this->logger->warning('could not remove event from calendar', [
|
||||
@@ -664,7 +655,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
try {
|
||||
$event = $this->machineHttpClient->request(
|
||||
'GET',
|
||||
'users/' . $userId . '/calendar/events/' . $calendarRange->getRemoteId()
|
||||
'users/'.$userId.'/calendar/events/'.$calendarRange->getRemoteId()
|
||||
)->toArray();
|
||||
} catch (ClientExceptionInterface $e) {
|
||||
$this->logger->warning('Could not get event from calendar', [
|
||||
@@ -691,7 +682,7 @@ class MSGraphRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
try {
|
||||
$event = $this->machineHttpClient->request(
|
||||
'PATCH',
|
||||
'users/' . $userId . '/calendar/events/' . $calendarRange->getRemoteId(),
|
||||
'users/'.$userId.'/calendar/events/'.$calendarRange->getRemoteId(),
|
||||
[
|
||||
'json' => $eventData,
|
||||
]
|
||||
|
@@ -22,20 +22,18 @@ use Chill\CalendarBundle\Entity\Calendar;
|
||||
use Chill\CalendarBundle\Entity\CalendarRange;
|
||||
use Chill\CalendarBundle\Entity\Invite;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use DateTimeImmutable;
|
||||
use LogicException;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class NullRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
{
|
||||
public function countEventsForUser(User $user, DateTimeImmutable $startDate, DateTimeImmutable $endDate): int
|
||||
public function countEventsForUser(User $user, \DateTimeImmutable $startDate, \DateTimeImmutable $endDate): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getMakeReadyResponse(string $returnPath): Response
|
||||
{
|
||||
throw new LogicException('As this connector is always ready, this method should not be called');
|
||||
throw new \LogicException('As this connector is always ready, this method should not be called');
|
||||
}
|
||||
|
||||
public function isReady(): bool
|
||||
@@ -43,12 +41,12 @@ class NullRemoteCalendarConnector implements RemoteCalendarConnectorInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
public function listEventsForUser(User $user, DateTimeImmutable $startDate, DateTimeImmutable $endDate, ?int $offset = 0, ?int $limit = 50): array
|
||||
public function listEventsForUser(User $user, \DateTimeImmutable $startDate, \DateTimeImmutable $endDate, ?int $offset = 0, ?int $limit = 50): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function removeCalendar(string $remoteId, array $remoteAttributes, User $user, ?CalendarRange $associatedCalendarRange = null): void {}
|
||||
public function removeCalendar(string $remoteId, array $remoteAttributes, User $user, CalendarRange $associatedCalendarRange = null): void {}
|
||||
|
||||
public function removeCalendarRange(string $remoteId, array $remoteAttributes, User $user): void {}
|
||||
|
||||
|
@@ -23,12 +23,11 @@ use Chill\CalendarBundle\Entity\CalendarRange;
|
||||
use Chill\CalendarBundle\Entity\Invite;
|
||||
use Chill\CalendarBundle\RemoteCalendar\Model\RemoteEvent;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use DateTimeImmutable;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
interface RemoteCalendarConnectorInterface
|
||||
{
|
||||
public function countEventsForUser(User $user, DateTimeImmutable $startDate, DateTimeImmutable $endDate): int;
|
||||
public function countEventsForUser(User $user, \DateTimeImmutable $startDate, \DateTimeImmutable $endDate): int;
|
||||
|
||||
/**
|
||||
* Return a response, more probably a RedirectResponse, where the user
|
||||
@@ -46,9 +45,9 @@ interface RemoteCalendarConnectorInterface
|
||||
/**
|
||||
* @return array|RemoteEvent[]
|
||||
*/
|
||||
public function listEventsForUser(User $user, DateTimeImmutable $startDate, DateTimeImmutable $endDate, ?int $offset = 0, ?int $limit = 50): array;
|
||||
public function listEventsForUser(User $user, \DateTimeImmutable $startDate, \DateTimeImmutable $endDate, ?int $offset = 0, ?int $limit = 50): array;
|
||||
|
||||
public function removeCalendar(string $remoteId, array $remoteAttributes, User $user, ?CalendarRange $associatedCalendarRange = null): void;
|
||||
public function removeCalendar(string $remoteId, array $remoteAttributes, User $user, CalendarRange $associatedCalendarRange = null): void;
|
||||
|
||||
public function removeCalendarRange(string $remoteId, array $remoteAttributes, User $user): void;
|
||||
|
||||
|
@@ -28,7 +28,6 @@ use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\MSUserAbsenceSync;
|
||||
use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraphRemoteCalendarConnector;
|
||||
use Chill\CalendarBundle\RemoteCalendar\Connector\NullRemoteCalendarConnector;
|
||||
use Chill\CalendarBundle\RemoteCalendar\Connector\RemoteCalendarConnectorInterface;
|
||||
use RuntimeException;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
@@ -43,7 +42,7 @@ class RemoteCalendarCompilerPass implements CompilerPassInterface
|
||||
if (true === $config['remote_calendars_sync']['microsoft_graph']['enabled']) {
|
||||
$connector = MSGraphRemoteCalendarConnector::class;
|
||||
|
||||
$container->setAlias(HttpClientInterface::class . ' $machineHttpClient', MachineHttpClient::class);
|
||||
$container->setAlias(HttpClientInterface::class.' $machineHttpClient', MachineHttpClient::class);
|
||||
} else {
|
||||
$connector = NullRemoteCalendarConnector::class;
|
||||
// remove services which cannot be loaded
|
||||
|
@@ -18,7 +18,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\CalendarBundle\RemoteCalendar\Model;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
|
||||
class RemoteEvent
|
||||
@@ -36,11 +35,11 @@ class RemoteEvent
|
||||
/**
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
public DateTimeImmutable $startDate,
|
||||
public \DateTimeImmutable $startDate,
|
||||
/**
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
public DateTimeImmutable $endDate,
|
||||
public \DateTimeImmutable $endDate,
|
||||
/**
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
|
@@ -23,7 +23,6 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepositoryInterface;
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
|
||||
@@ -31,7 +30,7 @@ class CalendarACLAwareRepository implements CalendarACLAwareRepositoryInterface
|
||||
{
|
||||
public function __construct(private readonly AccompanyingPeriodACLAwareRepositoryInterface $accompanyingPeriodACLAwareRepository, private readonly EntityManagerInterface $em) {}
|
||||
|
||||
public function buildQueryByAccompanyingPeriod(AccompanyingPeriod $period, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): QueryBuilder
|
||||
public function buildQueryByAccompanyingPeriod(AccompanyingPeriod $period, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate): QueryBuilder
|
||||
{
|
||||
$qb = $this->em->createQueryBuilder();
|
||||
$qb->from(Calendar::class, 'c');
|
||||
@@ -54,7 +53,7 @@ class CalendarACLAwareRepository implements CalendarACLAwareRepositoryInterface
|
||||
return $qb;
|
||||
}
|
||||
|
||||
public function buildQueryByAccompanyingPeriodIgnoredByDates(AccompanyingPeriod $period, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): QueryBuilder
|
||||
public function buildQueryByAccompanyingPeriodIgnoredByDates(AccompanyingPeriod $period, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate): QueryBuilder
|
||||
{
|
||||
$qb = $this->em->createQueryBuilder();
|
||||
$qb->from(Calendar::class, 'c');
|
||||
@@ -80,7 +79,7 @@ class CalendarACLAwareRepository implements CalendarACLAwareRepositoryInterface
|
||||
/**
|
||||
* Base implementation. The list of allowed accompanying period is retrieved "manually" from @see{AccompanyingPeriodACLAwareRepository}.
|
||||
*/
|
||||
public function buildQueryByPerson(Person $person, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): QueryBuilder
|
||||
public function buildQueryByPerson(Person $person, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate): QueryBuilder
|
||||
{
|
||||
$qb = $this->em->createQueryBuilder()
|
||||
->from(Calendar::class, 'c');
|
||||
@@ -104,7 +103,7 @@ class CalendarACLAwareRepository implements CalendarACLAwareRepositoryInterface
|
||||
/**
|
||||
* Base implementation. The list of allowed accompanying period is retrieved "manually" from @see{AccompanyingPeriodACLAwareRepository}.
|
||||
*/
|
||||
public function buildQueryByPersonIgnoredByDates(Person $person, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): QueryBuilder
|
||||
public function buildQueryByPersonIgnoredByDates(Person $person, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate): QueryBuilder
|
||||
{
|
||||
$qb = $this->em->createQueryBuilder()
|
||||
->from(Calendar::class, 'c');
|
||||
@@ -125,14 +124,14 @@ class CalendarACLAwareRepository implements CalendarACLAwareRepositoryInterface
|
||||
return $qb;
|
||||
}
|
||||
|
||||
public function countByAccompanyingPeriod(AccompanyingPeriod $period, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): int
|
||||
public function countByAccompanyingPeriod(AccompanyingPeriod $period, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate): int
|
||||
{
|
||||
$qb = $this->buildQueryByAccompanyingPeriod($period, $startDate, $endDate)->select('count(c)');
|
||||
|
||||
return $qb->getQuery()->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function countByPerson(Person $person, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): int
|
||||
public function countByPerson(Person $person, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate): int
|
||||
{
|
||||
return $this->buildQueryByPerson($person, $startDate, $endDate)
|
||||
->select('COUNT(c)')
|
||||
@@ -140,14 +139,14 @@ class CalendarACLAwareRepository implements CalendarACLAwareRepositoryInterface
|
||||
->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function countIgnoredByAccompanyingPeriod(AccompanyingPeriod $period, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): int
|
||||
public function countIgnoredByAccompanyingPeriod(AccompanyingPeriod $period, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate): int
|
||||
{
|
||||
$qb = $this->buildQueryByAccompanyingPeriodIgnoredByDates($period, $startDate, $endDate)->select('count(c)');
|
||||
|
||||
return $qb->getQuery()->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function countIgnoredByPerson(Person $person, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): int
|
||||
public function countIgnoredByPerson(Person $person, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate): int
|
||||
{
|
||||
return $this->buildQueryByPersonIgnoredByDates($person, $startDate, $endDate)
|
||||
->select('COUNT(c)')
|
||||
@@ -158,12 +157,12 @@ class CalendarACLAwareRepository implements CalendarACLAwareRepositoryInterface
|
||||
/**
|
||||
* @return array|Calendar[]
|
||||
*/
|
||||
public function findByAccompanyingPeriod(AccompanyingPeriod $period, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate, ?array $orderBy = [], ?int $offset = null, ?int $limit = null): array
|
||||
public function findByAccompanyingPeriod(AccompanyingPeriod $period, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate, ?array $orderBy = [], int $offset = null, int $limit = null): array
|
||||
{
|
||||
$qb = $this->buildQueryByAccompanyingPeriod($period, $startDate, $endDate)->select('c');
|
||||
|
||||
foreach ($orderBy as $sort => $order) {
|
||||
$qb->addOrderBy('c.' . $sort, $order);
|
||||
$qb->addOrderBy('c.'.$sort, $order);
|
||||
}
|
||||
|
||||
if (null !== $offset) {
|
||||
@@ -177,13 +176,13 @@ class CalendarACLAwareRepository implements CalendarACLAwareRepositoryInterface
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
public function findByPerson(Person $person, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate, ?array $orderBy = [], ?int $offset = null, ?int $limit = null): array
|
||||
public function findByPerson(Person $person, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate, ?array $orderBy = [], int $offset = null, int $limit = null): array
|
||||
{
|
||||
$qb = $this->buildQueryByPerson($person, $startDate, $endDate)
|
||||
->select('c');
|
||||
|
||||
foreach ($orderBy as $sort => $order) {
|
||||
$qb->addOrderBy('c.' . $sort, $order);
|
||||
$qb->addOrderBy('c.'.$sort, $order);
|
||||
}
|
||||
|
||||
if (null !== $offset) {
|
||||
|
@@ -21,33 +21,32 @@ namespace Chill\CalendarBundle\Repository;
|
||||
use Chill\CalendarBundle\Entity\Calendar;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use DateTimeImmutable;
|
||||
|
||||
interface CalendarACLAwareRepositoryInterface
|
||||
{
|
||||
public function countByAccompanyingPeriod(AccompanyingPeriod $period, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): int;
|
||||
public function countByAccompanyingPeriod(AccompanyingPeriod $period, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate): int;
|
||||
|
||||
/**
|
||||
* Return the number or calendars associated with a person. See condition on @see{self::findByPerson}.
|
||||
*/
|
||||
public function countByPerson(Person $person, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): int;
|
||||
public function countByPerson(Person $person, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate): int;
|
||||
|
||||
/**
|
||||
* Return the number or calendars associated with an accompanyign period which **does not** match the date conditions.
|
||||
*/
|
||||
public function countIgnoredByAccompanyingPeriod(AccompanyingPeriod $period, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): int;
|
||||
public function countIgnoredByAccompanyingPeriod(AccompanyingPeriod $period, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate): int;
|
||||
|
||||
/**
|
||||
* Return the number or calendars associated with a person which **does not** match the date conditions.
|
||||
*
|
||||
* See condition on @see{self::findByPerson}.
|
||||
*/
|
||||
public function countIgnoredByPerson(Person $person, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate): int;
|
||||
public function countIgnoredByPerson(Person $person, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate): int;
|
||||
|
||||
/**
|
||||
* @return array|Calendar[]
|
||||
*/
|
||||
public function findByAccompanyingPeriod(AccompanyingPeriod $period, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate, ?array $orderBy = [], ?int $offset = null, ?int $limit = null): array;
|
||||
public function findByAccompanyingPeriod(AccompanyingPeriod $period, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate, ?array $orderBy = [], int $offset = null, int $limit = null): array;
|
||||
|
||||
/**
|
||||
* Return all the calendars which are associated with a person, either on @see{Calendar::person} or within.
|
||||
@@ -59,5 +58,5 @@ interface CalendarACLAwareRepositoryInterface
|
||||
*
|
||||
* @return array|Calendar[]
|
||||
*/
|
||||
public function findByPerson(Person $person, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate, ?array $orderBy = [], ?int $offset = null, ?int $limit = null): array;
|
||||
public function findByPerson(Person $person, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate, ?array $orderBy = [], int $offset = null, int $limit = null): array;
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ class CalendarDocRepository implements ObjectRepository, CalendarDocRepositoryIn
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
|
||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null)
|
||||
public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null)
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ interface CalendarDocRepositoryInterface
|
||||
/**
|
||||
* @return array|CalendarDoc[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null);
|
||||
public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null);
|
||||
|
||||
public function findOneBy(array $criteria): ?CalendarDoc;
|
||||
|
||||
|
@@ -13,14 +13,12 @@ namespace Chill\CalendarBundle\Repository;
|
||||
|
||||
use Chill\CalendarBundle\Entity\CalendarRange;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\Query\ResultSetMapping;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
use function count;
|
||||
|
||||
class CalendarRangeRepository implements ObjectRepository
|
||||
{
|
||||
@@ -31,7 +29,7 @@ class CalendarRangeRepository implements ObjectRepository
|
||||
$this->repository = $em->getRepository(CalendarRange::class);
|
||||
}
|
||||
|
||||
public function countByAvailableRangesForUser(User $user, DateTimeImmutable $from, DateTimeImmutable $to): int
|
||||
public function countByAvailableRangesForUser(User $user, \DateTimeImmutable $from, \DateTimeImmutable $to): int
|
||||
{
|
||||
return $this->buildQueryAvailableRangesForUser($user, $from, $to)
|
||||
->select('COUNT(cr)')
|
||||
@@ -54,7 +52,7 @@ class CalendarRangeRepository implements ObjectRepository
|
||||
/**
|
||||
* @return array|CalendarRange[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null)
|
||||
public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null)
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
@@ -64,10 +62,10 @@ class CalendarRangeRepository implements ObjectRepository
|
||||
*/
|
||||
public function findByAvailableRangesForUser(
|
||||
User $user,
|
||||
DateTimeImmutable $from,
|
||||
DateTimeImmutable $to,
|
||||
?int $limit = null,
|
||||
?int $offset = null
|
||||
\DateTimeImmutable $from,
|
||||
\DateTimeImmutable $to,
|
||||
int $limit = null,
|
||||
int $offset = null
|
||||
): array {
|
||||
$qb = $this->buildQueryAvailableRangesForUser($user, $from, $to);
|
||||
|
||||
@@ -98,7 +96,7 @@ class CalendarRangeRepository implements ObjectRepository
|
||||
*/
|
||||
public function findRemoteIdsPresent(array $remoteIds): array
|
||||
{
|
||||
if (0 === count($remoteIds)) {
|
||||
if (0 === \count($remoteIds)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -113,7 +111,7 @@ class CalendarRangeRepository implements ObjectRepository
|
||||
|
||||
$remoteIdsStr = implode(
|
||||
', ',
|
||||
array_fill(0, count($remoteIds), '((?))')
|
||||
array_fill(0, \count($remoteIds), '((?))')
|
||||
);
|
||||
|
||||
$rsm = new ResultSetMapping();
|
||||
@@ -143,7 +141,7 @@ class CalendarRangeRepository implements ObjectRepository
|
||||
return CalendarRange::class;
|
||||
}
|
||||
|
||||
private function buildQueryAvailableRangesForUser(User $user, DateTimeImmutable $from, DateTimeImmutable $to): QueryBuilder
|
||||
private function buildQueryAvailableRangesForUser(User $user, \DateTimeImmutable $from, \DateTimeImmutable $to): QueryBuilder
|
||||
{
|
||||
$qb = $this->repository->createQueryBuilder('cr');
|
||||
|
||||
|
@@ -14,14 +14,12 @@ namespace Chill\CalendarBundle\Repository;
|
||||
use Chill\CalendarBundle\Entity\Calendar;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\Query\ResultSetMapping;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
use function count;
|
||||
|
||||
class CalendarRepository implements ObjectRepository
|
||||
{
|
||||
@@ -40,7 +38,7 @@ class CalendarRepository implements ObjectRepository
|
||||
return $this->repository->count(['accompanyingPeriod' => $period]);
|
||||
}
|
||||
|
||||
public function countByUser(User $user, DateTimeImmutable $from, DateTimeImmutable $to): int
|
||||
public function countByUser(User $user, \DateTimeImmutable $from, \DateTimeImmutable $to): int
|
||||
{
|
||||
return $this->buildQueryByUser($user, $from, $to)
|
||||
->select('COUNT(c)')
|
||||
@@ -48,7 +46,7 @@ class CalendarRepository implements ObjectRepository
|
||||
->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder
|
||||
public function createQueryBuilder(string $alias, string $indexBy = null): QueryBuilder
|
||||
{
|
||||
return $this->repository->createQueryBuilder($alias, $indexBy);
|
||||
}
|
||||
@@ -69,7 +67,7 @@ class CalendarRepository implements ObjectRepository
|
||||
/**
|
||||
* @return array|Calendar[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array
|
||||
public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
@@ -77,7 +75,7 @@ class CalendarRepository implements ObjectRepository
|
||||
/**
|
||||
* @return array|Calendar[]
|
||||
*/
|
||||
public function findByAccompanyingPeriod(AccompanyingPeriod $period, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array
|
||||
public function findByAccompanyingPeriod(AccompanyingPeriod $period, array $orderBy = null, int $limit = null, int $offset = null): array
|
||||
{
|
||||
return $this->findBy(
|
||||
[
|
||||
@@ -89,7 +87,7 @@ class CalendarRepository implements ObjectRepository
|
||||
);
|
||||
}
|
||||
|
||||
public function findByNotificationAvailable(DateTimeImmutable $startDate, DateTimeImmutable $endDate, ?int $limit = null, ?int $offset = null): array
|
||||
public function findByNotificationAvailable(\DateTimeImmutable $startDate, \DateTimeImmutable $endDate, int $limit = null, int $offset = null): array
|
||||
{
|
||||
$qb = $this->queryByNotificationAvailable($startDate, $endDate)->select('c');
|
||||
|
||||
@@ -107,7 +105,7 @@ class CalendarRepository implements ObjectRepository
|
||||
/**
|
||||
* @return array|Calendar[]
|
||||
*/
|
||||
public function findByUser(User $user, DateTimeImmutable $from, DateTimeImmutable $to, ?int $limit = null, ?int $offset = null): array
|
||||
public function findByUser(User $user, \DateTimeImmutable $from, \DateTimeImmutable $to, int $limit = null, int $offset = null): array
|
||||
{
|
||||
$qb = $this->buildQueryByUser($user, $from, $to)->select('c');
|
||||
|
||||
@@ -138,13 +136,13 @@ class CalendarRepository implements ObjectRepository
|
||||
*/
|
||||
public function findRemoteIdsPresent(array $remoteIds): array
|
||||
{
|
||||
if (0 === count($remoteIds)) {
|
||||
if (0 === \count($remoteIds)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$remoteIdsStr = implode(
|
||||
', ',
|
||||
array_fill(0, count($remoteIds), '((?))')
|
||||
array_fill(0, \count($remoteIds), '((?))')
|
||||
);
|
||||
|
||||
$sql = "SELECT
|
||||
@@ -183,7 +181,7 @@ class CalendarRepository implements ObjectRepository
|
||||
return Calendar::class;
|
||||
}
|
||||
|
||||
private function buildQueryByUser(User $user, DateTimeImmutable $from, DateTimeImmutable $to): QueryBuilder
|
||||
private function buildQueryByUser(User $user, \DateTimeImmutable $from, \DateTimeImmutable $to): QueryBuilder
|
||||
{
|
||||
$qb = $this->repository->createQueryBuilder('c');
|
||||
|
||||
@@ -202,7 +200,7 @@ class CalendarRepository implements ObjectRepository
|
||||
]);
|
||||
}
|
||||
|
||||
private function queryByNotificationAvailable(DateTimeImmutable $startDate, DateTimeImmutable $endDate): QueryBuilder
|
||||
private function queryByNotificationAvailable(\DateTimeImmutable $startDate, \DateTimeImmutable $endDate): QueryBuilder
|
||||
{
|
||||
$qb = $this->repository->createQueryBuilder('c');
|
||||
|
||||
|
@@ -41,7 +41,7 @@ class InviteRepository implements ObjectRepository
|
||||
/**
|
||||
* @return array|Invite[]
|
||||
*/
|
||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null)
|
||||
public function findBy(array $criteria, array $orderBy = null, int $limit = null, int $offset = null)
|
||||
{
|
||||
return $this->entityRepository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
@@ -15,8 +15,6 @@ use Chill\CalendarBundle\Entity\CalendarDoc;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use UnexpectedValueException;
|
||||
use function in_array;
|
||||
|
||||
class CalendarDocVoter extends Voter
|
||||
{
|
||||
@@ -33,19 +31,18 @@ class CalendarDocVoter extends Voter
|
||||
|
||||
protected function supports($attribute, $subject): bool
|
||||
{
|
||||
return in_array($attribute, self::ALL, true) && $subject instanceof CalendarDoc;
|
||||
return \in_array($attribute, self::ALL, true) && $subject instanceof CalendarDoc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CalendarDoc $subject
|
||||
* @param mixed $attribute
|
||||
*/
|
||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
||||
{
|
||||
return match ($attribute) {
|
||||
self::EDIT => $this->security->isGranted(CalendarVoter::EDIT, $subject->getCalendar()),
|
||||
self::SEE => $this->security->isGranted(CalendarVoter::SEE, $subject->getCalendar()),
|
||||
default => throw new UnexpectedValueException('Attribute not supported: ' . $attribute),
|
||||
default => throw new \UnexpectedValueException('Attribute not supported: '.$attribute),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -20,15 +20,12 @@ namespace Chill\CalendarBundle\Security\Voter;
|
||||
|
||||
use Chill\CalendarBundle\Entity\Calendar;
|
||||
use Chill\MainBundle\Security\Authorization\AbstractChillVoter;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
|
||||
use Chill\MainBundle\Security\Authorization\VoterHelperFactoryInterface;
|
||||
use Chill\MainBundle\Security\Authorization\VoterHelperInterface;
|
||||
use Chill\MainBundle\Security\ProvideRoleHierarchyInterface;
|
||||
use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||
use LogicException;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
@@ -92,7 +89,7 @@ class CalendarVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn
|
||||
switch ($attribute) {
|
||||
case self::SEE:
|
||||
case self::CREATE:
|
||||
if ($subject->getStep() === AccompanyingPeriod::STEP_DRAFT) {
|
||||
if (AccompanyingPeriod::STEP_DRAFT === $subject->getStep()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -122,6 +119,6 @@ class CalendarVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn
|
||||
}
|
||||
}
|
||||
|
||||
throw new LogicException('attribute or not implemented');
|
||||
throw new \LogicException('attribute or not implemented');
|
||||
}
|
||||
}
|
||||
|
@@ -29,7 +29,6 @@ use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use function count;
|
||||
|
||||
final readonly class CalendarContext implements CalendarContextInterface
|
||||
{
|
||||
@@ -122,8 +121,6 @@ final readonly class CalendarContext implements CalendarContextInterface
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function getData(DocGeneratorTemplate $template, mixed $entity, array $contextGenerationData = []): array
|
||||
{
|
||||
$options = $this->getOptions($template);
|
||||
@@ -173,7 +170,7 @@ final readonly class CalendarContext implements CalendarContextInterface
|
||||
if ($options['askMainPerson']) {
|
||||
$data['mainPerson'] = null;
|
||||
|
||||
if (1 === count($entity->getPersons())) {
|
||||
if (1 === \count($entity->getPersons())) {
|
||||
$data['mainPerson'] = $entity->getPersons()->first();
|
||||
}
|
||||
}
|
||||
@@ -181,7 +178,7 @@ final readonly class CalendarContext implements CalendarContextInterface
|
||||
if ($options['askThirdParty']) {
|
||||
$data['thirdParty'] = null;
|
||||
|
||||
if (1 === count($entity->getProfessionals())) {
|
||||
if (1 === \count($entity->getProfessionals())) {
|
||||
$data['thirdParty'] = $entity->getProfessionals()->first();
|
||||
}
|
||||
}
|
||||
|
@@ -12,12 +12,8 @@ declare(strict_types=1);
|
||||
namespace Chill\CalendarBundle\Service\DocGenerator;
|
||||
|
||||
use Chill\CalendarBundle\Entity\Calendar;
|
||||
use Chill\DocGeneratorBundle\Context\DocGeneratorContextInterface;
|
||||
use Chill\DocGeneratorBundle\Context\DocGeneratorContextWithAdminFormInterface;
|
||||
use Chill\DocGeneratorBundle\Context\DocGeneratorContextWithPublicFormInterface;
|
||||
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
/**
|
||||
* @extends DocGeneratorContextWithPublicFormInterface<Calendar>
|
||||
|
@@ -22,7 +22,6 @@ use Chill\DocStoreBundle\GenericDoc\GenericDocForPersonProviderInterface;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\Mapping\MappingException;
|
||||
@@ -44,7 +43,7 @@ final readonly class AccompanyingPeriodCalendarGenericDocProvider implements Gen
|
||||
/**
|
||||
* @throws MappingException
|
||||
*/
|
||||
public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface
|
||||
public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null, string $origin = null): FetchQueryInterface
|
||||
{
|
||||
$classMetadata = $this->em->getClassMetadata(CalendarDoc::class);
|
||||
$storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class);
|
||||
@@ -91,7 +90,7 @@ final readonly class AccompanyingPeriodCalendarGenericDocProvider implements Gen
|
||||
return $this->security->isGranted(CalendarVoter::SEE, $accompanyingPeriod);
|
||||
}
|
||||
|
||||
public function buildFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface
|
||||
public function buildFetchQueryForPerson(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null, string $origin = null): FetchQueryInterface
|
||||
{
|
||||
$classMetadata = $this->em->getClassMetadata(CalendarDoc::class);
|
||||
$storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class);
|
||||
@@ -136,8 +135,8 @@ final readonly class AccompanyingPeriodCalendarGenericDocProvider implements Gen
|
||||
$storedObjectMetadata->getColumnName('createdAt')
|
||||
);
|
||||
$orParams = [...$orParams, $participation->getAccompanyingPeriod()->getId(),
|
||||
DateTimeImmutable::createFromInterface($participation->getStartDate()),
|
||||
null === $participation->getEndDate() ? null : DateTimeImmutable::createFromInterface($participation->getEndDate())];
|
||||
\DateTimeImmutable::createFromInterface($participation->getStartDate()),
|
||||
null === $participation->getEndDate() ? null : \DateTimeImmutable::createFromInterface($participation->getEndDate())];
|
||||
$orTypes = [...$orTypes, Types::INTEGER, Types::DATE_IMMUTABLE, Types::DATE_IMMUTABLE];
|
||||
}
|
||||
|
||||
@@ -147,7 +146,7 @@ final readonly class AccompanyingPeriodCalendarGenericDocProvider implements Gen
|
||||
return $query;
|
||||
}
|
||||
|
||||
$query->addWhereClause(implode(" OR ", $or), $orParams, $orTypes);
|
||||
$query->addWhereClause(implode(' OR ', $or), $orParams, $orTypes);
|
||||
|
||||
return $this->addWhereClausesToQuery($query, $startDate, $endDate, $content);
|
||||
}
|
||||
@@ -159,7 +158,7 @@ final readonly class AccompanyingPeriodCalendarGenericDocProvider implements Gen
|
||||
return $this->security->isGranted(AccompanyingPeriodVoter::SEE, $person);
|
||||
}
|
||||
|
||||
private function addWhereClausesToQuery(FetchQuery $query, ?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate, ?string $content): FetchQuery
|
||||
private function addWhereClausesToQuery(FetchQuery $query, ?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate, ?string $content): FetchQuery
|
||||
{
|
||||
$storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class);
|
||||
|
||||
@@ -182,7 +181,7 @@ final readonly class AccompanyingPeriodCalendarGenericDocProvider implements Gen
|
||||
if (null !== $content) {
|
||||
$query->addWhereClause(
|
||||
sprintf('doc_store.%s ilike ?', $storedObjectMetadata->getColumnName('title')),
|
||||
['%' . $content . '%'],
|
||||
['%'.$content.'%'],
|
||||
[Types::STRING]
|
||||
);
|
||||
}
|
||||
|
@@ -19,8 +19,6 @@ use Chill\DocStoreBundle\GenericDoc\FetchQuery;
|
||||
use Chill\DocStoreBundle\GenericDoc\FetchQueryInterface;
|
||||
use Chill\DocStoreBundle\GenericDoc\GenericDocForPersonProviderInterface;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodWorkVoter;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\Mapping\MappingException;
|
||||
@@ -28,7 +26,7 @@ use Service\GenericDoc\Providers\PersonCalendarGenericDocProviderTest;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
/**
|
||||
* Provide calendar documents for calendar associated to persons
|
||||
* Provide calendar documents for calendar associated to persons.
|
||||
*
|
||||
* @see PersonCalendarGenericDocProviderTest
|
||||
*/
|
||||
@@ -41,7 +39,7 @@ final readonly class PersonCalendarGenericDocProvider implements GenericDocForPe
|
||||
private EntityManagerInterface $em
|
||||
) {}
|
||||
|
||||
private function addWhereClausesToQuery(FetchQuery $query, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null): FetchQuery
|
||||
private function addWhereClausesToQuery(FetchQuery $query, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null): FetchQuery
|
||||
{
|
||||
$storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class);
|
||||
|
||||
@@ -64,7 +62,7 @@ final readonly class PersonCalendarGenericDocProvider implements GenericDocForPe
|
||||
if (null !== $content) {
|
||||
$query->addWhereClause(
|
||||
sprintf('doc_store.%s ilike ?', $storedObjectMetadata->getColumnName('title')),
|
||||
['%' . $content . '%'],
|
||||
['%'.$content.'%'],
|
||||
[Types::STRING]
|
||||
);
|
||||
}
|
||||
@@ -75,7 +73,7 @@ final readonly class PersonCalendarGenericDocProvider implements GenericDocForPe
|
||||
/**
|
||||
* @throws MappingException
|
||||
*/
|
||||
public function buildFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface
|
||||
public function buildFetchQueryForPerson(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null, string $origin = null): FetchQueryInterface
|
||||
{
|
||||
$classMetadata = $this->em->getClassMetadata(CalendarDoc::class);
|
||||
$storedObjectMetadata = $this->em->getClassMetadata(StoredObject::class);
|
||||
@@ -114,10 +112,6 @@ final readonly class PersonCalendarGenericDocProvider implements GenericDocForPe
|
||||
return $this->addWhereClausesToQuery($query, $startDate, $endDate, $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Person $person
|
||||
* @return bool
|
||||
*/
|
||||
public function isAllowedForPerson(Person $person): bool
|
||||
{
|
||||
return $this->security->isGranted(CalendarVoter::SEE, $person);
|
||||
|
@@ -23,7 +23,7 @@ final readonly class AccompanyingPeriodCalendarGenericDocRenderer implements Gen
|
||||
|
||||
public function supports(GenericDocDTO $genericDocDTO, $options = []): bool
|
||||
{
|
||||
return $genericDocDTO->key === AccompanyingPeriodCalendarGenericDocProvider::KEY || $genericDocDTO->key === PersonCalendarGenericDocProvider::KEY;
|
||||
return AccompanyingPeriodCalendarGenericDocProvider::KEY === $genericDocDTO->key || PersonCalendarGenericDocProvider::KEY === $genericDocDTO->key;
|
||||
}
|
||||
|
||||
public function getTemplate(GenericDocDTO $genericDocDTO, $options = []): string
|
||||
|
@@ -19,7 +19,6 @@ declare(strict_types=1);
|
||||
namespace Chill\CalendarBundle\Service\ShortMessageNotification;
|
||||
|
||||
use Chill\CalendarBundle\Entity\Calendar;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Messenger\MessageBusInterface;
|
||||
@@ -33,7 +32,7 @@ class BulkCalendarShortMessageSender
|
||||
$countCalendars = 0;
|
||||
$countSms = 0;
|
||||
|
||||
foreach ($this->provider->getCalendars(new DateTimeImmutable('now')) as $calendar) {
|
||||
foreach ($this->provider->getCalendars(new \DateTimeImmutable('now')) as $calendar) {
|
||||
$smses = $this->messageForCalendarBuilder->buildMessageForCalendar($calendar);
|
||||
|
||||
foreach ($smses as $sms) {
|
||||
@@ -42,13 +41,13 @@ class BulkCalendarShortMessageSender
|
||||
}
|
||||
|
||||
$this->em
|
||||
->createQuery('UPDATE ' . Calendar::class . ' c SET c.smsStatus = :smsStatus WHERE c.id = :id')
|
||||
->createQuery('UPDATE '.Calendar::class.' c SET c.smsStatus = :smsStatus WHERE c.id = :id')
|
||||
->setParameters(['smsStatus' => Calendar::SMS_SENT, 'id' => $calendar->getId()])
|
||||
->execute();
|
||||
++$countCalendars;
|
||||
$this->em->refresh($calendar);
|
||||
}
|
||||
|
||||
$this->logger->info(self::class . 'a bulk of messages was sent', ['count_calendars' => $countCalendars, 'count_sms' => $countSms]);
|
||||
$this->logger->info(self::class.'a bulk of messages was sent', ['count_calendars' => $countCalendars, 'count_sms' => $countSms]);
|
||||
}
|
||||
}
|
||||
|
@@ -20,9 +20,7 @@ namespace Chill\CalendarBundle\Service\ShortMessageNotification;
|
||||
|
||||
use Chill\CalendarBundle\Entity\Calendar;
|
||||
use Chill\CalendarBundle\Repository\CalendarRepository;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use function count;
|
||||
|
||||
class CalendarForShortMessageProvider
|
||||
{
|
||||
@@ -35,7 +33,7 @@ class CalendarForShortMessageProvider
|
||||
*
|
||||
* @return iterable|Calendar[]
|
||||
*/
|
||||
public function getCalendars(DateTimeImmutable $at): iterable
|
||||
public function getCalendars(\DateTimeImmutable $at): iterable
|
||||
{
|
||||
$range = $this->rangeGenerator->generateRange($at);
|
||||
|
||||
@@ -62,6 +60,6 @@ class CalendarForShortMessageProvider
|
||||
|
||||
$calendars = $this->calendarRepository
|
||||
->findByNotificationAvailable($startDate, $endDate, $batchSize, $offset);
|
||||
} while (count($calendars) === $batchSize);
|
||||
} while (\count($calendars) === $batchSize);
|
||||
}
|
||||
}
|
||||
|
@@ -18,9 +18,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\CalendarBundle\Service\ShortMessageNotification;
|
||||
|
||||
use DateInterval;
|
||||
use Monolog\DateTimeImmutable;
|
||||
use UnexpectedValueException;
|
||||
|
||||
/**
|
||||
* * Lundi => Envoi des rdv du mardi et mercredi.
|
||||
@@ -33,7 +31,7 @@ class DefaultRangeGenerator implements RangeGeneratorInterface
|
||||
{
|
||||
public function generateRange(\DateTimeImmutable $date): ?array
|
||||
{
|
||||
$onMidnight = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $date->format('Y-m-d') . ' 00:00:00');
|
||||
$onMidnight = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $date->format('Y-m-d').' 00:00:00');
|
||||
|
||||
switch ($dow = (int) $onMidnight->format('w')) {
|
||||
case 6: // Saturday
|
||||
@@ -42,32 +40,32 @@ class DefaultRangeGenerator implements RangeGeneratorInterface
|
||||
|
||||
case 1: // Monday
|
||||
// send for Tuesday and Wednesday
|
||||
$startDate = $onMidnight->add(new DateInterval('P1D'));
|
||||
$endDate = $startDate->add(new DateInterval('P2D'));
|
||||
$startDate = $onMidnight->add(new \DateInterval('P1D'));
|
||||
$endDate = $startDate->add(new \DateInterval('P2D'));
|
||||
|
||||
break;
|
||||
|
||||
case 2: // tuesday
|
||||
case 3: // wednesday
|
||||
$startDate = $onMidnight->add(new DateInterval('P2D'));
|
||||
$endDate = $startDate->add(new DateInterval('P1D'));
|
||||
$startDate = $onMidnight->add(new \DateInterval('P2D'));
|
||||
$endDate = $startDate->add(new \DateInterval('P1D'));
|
||||
|
||||
break;
|
||||
|
||||
case 4: // thursday
|
||||
$startDate = $onMidnight->add(new DateInterval('P2D'));
|
||||
$endDate = $startDate->add(new DateInterval('P2D'));
|
||||
$startDate = $onMidnight->add(new \DateInterval('P2D'));
|
||||
$endDate = $startDate->add(new \DateInterval('P2D'));
|
||||
|
||||
break;
|
||||
|
||||
case 5: // friday
|
||||
$startDate = $onMidnight->add(new DateInterval('P3D'));
|
||||
$endDate = $startDate->add(new DateInterval('P1D'));
|
||||
$startDate = $onMidnight->add(new \DateInterval('P3D'));
|
||||
$endDate = $startDate->add(new \DateInterval('P1D'));
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new UnexpectedValueException('a day of a week should not have the value: ' . $dow);
|
||||
throw new \UnexpectedValueException('a day of a week should not have the value: '.$dow);
|
||||
}
|
||||
|
||||
return ['startDate' => $startDate, 'endDate' => $endDate];
|
||||
|
@@ -20,7 +20,6 @@ namespace Chill\CalendarBundle\Service\ShortMessageNotification;
|
||||
|
||||
use Chill\CalendarBundle\Entity\Calendar;
|
||||
use Chill\MainBundle\Service\ShortMessage\ShortMessage;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
|
||||
class DefaultShortMessageForCalendarBuilder implements ShortMessageForCalendarBuilderInterface
|
||||
{
|
||||
|
@@ -18,12 +18,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\CalendarBundle\Service\ShortMessageNotification;
|
||||
|
||||
use DateTimeImmutable;
|
||||
|
||||
interface RangeGeneratorInterface
|
||||
{
|
||||
/**
|
||||
* @return ?array{startDate: DateTimeImmutable, endDate: DateTimeImmutable} when return is null, then no ShortMessage must be send
|
||||
* @return ?array{startDate: \DateTimeImmutable, endDate: \DateTimeImmutable} when return is null, then no ShortMessage must be send
|
||||
*/
|
||||
public function generateRange(DateTimeImmutable $date): ?array;
|
||||
public function generateRange(\DateTimeImmutable $date): ?array;
|
||||
}
|
||||
|
@@ -13,15 +13,14 @@ namespace Chill\CalendarBundle\Tests\Controller;
|
||||
|
||||
use Chill\MainBundle\Test\PrepareClientTrait;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use function random_int;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class CalendarControllerTest extends WebTestCase
|
||||
@@ -75,7 +74,7 @@ final class CalendarControllerTest extends WebTestCase
|
||||
->join('ac.scopes', 's')
|
||||
->andWhere('JSON_EXTRACT(s.name,\'fr\') LIKE :s')
|
||||
->setParameter('s', 'social')
|
||||
->setFirstResult(random_int(0, $nb - 1))
|
||||
->setFirstResult(\random_int(0, $nb - 1))
|
||||
->setMaxResults(1)
|
||||
->getQuery()
|
||||
->getSingleScalarResult(),
|
||||
|
@@ -23,6 +23,7 @@ use Symfony\Component\Messenger\Transport\InMemoryTransport;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class RemoteCalendarMSGraphSyncControllerTest extends WebTestCase
|
||||
|
@@ -18,6 +18,7 @@ use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class CalendarDocTest extends TestCase
|
||||
|
@@ -24,6 +24,7 @@ use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class CalendarTest extends TestCase
|
||||
|
@@ -25,6 +25,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class AgentAggregatorTest extends AbstractAggregatorTest
|
||||
@@ -59,7 +60,7 @@ final class AgentAggregatorTest extends AbstractAggregatorTest
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('count(cal.id)')
|
||||
->from(Calendar::class, 'cal')
|
||||
->from(Calendar::class, 'cal'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class CancelReasonAggregatorTest extends AbstractAggregatorTest
|
||||
@@ -59,7 +60,7 @@ final class CancelReasonAggregatorTest extends AbstractAggregatorTest
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('count(cal.id)')
|
||||
->from(Calendar::class, 'cal')
|
||||
->from(Calendar::class, 'cal'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class JobAggregatorTest extends AbstractAggregatorTest
|
||||
@@ -46,7 +47,7 @@ final class JobAggregatorTest extends AbstractAggregatorTest
|
||||
public function getFormData(): array
|
||||
{
|
||||
return [
|
||||
[]
|
||||
[],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -59,7 +60,7 @@ final class JobAggregatorTest extends AbstractAggregatorTest
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('count(cal.id)')
|
||||
->from(Calendar::class, 'cal')
|
||||
->from(Calendar::class, 'cal'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class LocationAggregatorTest extends AbstractAggregatorTest
|
||||
@@ -59,7 +60,7 @@ final class LocationAggregatorTest extends AbstractAggregatorTest
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('count(cal.id)')
|
||||
->from(Calendar::class, 'cal')
|
||||
->from(Calendar::class, 'cal'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class LocationTypeAggregatorTest extends AbstractAggregatorTest
|
||||
@@ -59,7 +60,7 @@ final class LocationTypeAggregatorTest extends AbstractAggregatorTest
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('count(cal.id)')
|
||||
->from(Calendar::class, 'cal')
|
||||
->from(Calendar::class, 'cal'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class MonthYearAggregatorTest extends AbstractAggregatorTest
|
||||
|
@@ -25,6 +25,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ScopeAggregatorTest extends AbstractAggregatorTest
|
||||
@@ -59,7 +60,7 @@ final class ScopeAggregatorTest extends AbstractAggregatorTest
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('count(cal.id)')
|
||||
->from(Calendar::class, 'cal')
|
||||
->from(Calendar::class, 'cal'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class AgentFilterTest extends AbstractFilterTest
|
||||
@@ -78,10 +79,9 @@ final class AgentFilterTest extends AbstractFilterTest
|
||||
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
yield
|
||||
$em->createQueryBuilder()
|
||||
->select('cal.id')
|
||||
->from(Calendar::class, 'cal')
|
||||
yield $em->createQueryBuilder()
|
||||
->select('cal.id')
|
||||
->from(Calendar::class, 'cal')
|
||||
;
|
||||
|
||||
self::ensureKernelShutdown();
|
||||
|
@@ -22,11 +22,11 @@ use Chill\CalendarBundle\Entity\Calendar;
|
||||
use Chill\CalendarBundle\Export\Filter\BetweenDatesFilter;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class BetweenDatesFilterTest extends AbstractFilterTest
|
||||
|
@@ -27,6 +27,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class JobFilterTest extends AbstractFilterTest
|
||||
@@ -65,8 +66,8 @@ final class JobFilterTest extends AbstractFilterTest
|
||||
|
||||
return [
|
||||
[
|
||||
'job' => new ArrayCollection($array)
|
||||
]
|
||||
'job' => new ArrayCollection($array),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -79,7 +80,7 @@ final class JobFilterTest extends AbstractFilterTest
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('cal.id')
|
||||
->from(Calendar::class, 'cal')
|
||||
->from(Calendar::class, 'cal'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -27,6 +27,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ScopeFilterTest extends AbstractFilterTest
|
||||
@@ -65,8 +66,8 @@ final class ScopeFilterTest extends AbstractFilterTest
|
||||
|
||||
return [
|
||||
[
|
||||
'scope' => new ArrayCollection($array)
|
||||
]
|
||||
'scope' => new ArrayCollection($array),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -79,7 +80,7 @@ final class ScopeFilterTest extends AbstractFilterTest
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('cal.id')
|
||||
->from(Calendar::class, 'cal')
|
||||
->from(Calendar::class, 'cal'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -35,11 +35,9 @@ use Chill\PersonBundle\Form\DataTransformer\PersonsToIdDataTransformer;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Chill\ThirdPartyBundle\Form\DataTransformer\ThirdPartiesToIdDataTransformer;
|
||||
use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Prophecy\Argument;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use ReflectionProperty;
|
||||
use Symfony\Component\Form\PreloadedExtension;
|
||||
use Symfony\Component\Form\Test\TypeTestCase;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
@@ -48,6 +46,7 @@ use Symfony\Component\Security\Core\Security;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class CalendarTypeTest extends TypeTestCase
|
||||
@@ -112,8 +111,8 @@ final class CalendarTypeTest extends TypeTestCase
|
||||
$form->submit($formData);
|
||||
|
||||
$this->assertTrue($form->isSynchronized());
|
||||
$this->assertEquals(DateTimeImmutable::createFromFormat('Y-m-d H:i:s', '2022-05-05 14:00:00'), $calendar->getStartDate());
|
||||
$this->assertEquals(DateTimeImmutable::createFromFormat('Y-m-d H:i:s', '2022-05-05 14:30:00'), $calendar->getEndDate());
|
||||
$this->assertEquals(\DateTimeImmutable::createFromFormat('Y-m-d H:i:s', '2022-05-05 14:00:00'), $calendar->getStartDate());
|
||||
$this->assertEquals(\DateTimeImmutable::createFromFormat('Y-m-d H:i:s', '2022-05-05 14:30:00'), $calendar->getEndDate());
|
||||
$this->assertEquals(7, $calendar->getPersons()->first()->getId());
|
||||
$this->assertEquals(8, $calendar->getCalendarRange()->getId());
|
||||
$this->assertEquals(9, $calendar->getLocation()->getId());
|
||||
@@ -181,7 +180,7 @@ final class CalendarTypeTest extends TypeTestCase
|
||||
return array_map(
|
||||
static function ($id) use ($objClass) {
|
||||
$obj = new $objClass();
|
||||
$reflectionProperty = new ReflectionProperty($objClass, 'id');
|
||||
$reflectionProperty = new \ReflectionProperty($objClass, 'id');
|
||||
$reflectionProperty->setAccessible(true);
|
||||
$reflectionProperty->setValue($obj, (int) $id);
|
||||
|
||||
@@ -209,7 +208,7 @@ final class CalendarTypeTest extends TypeTestCase
|
||||
return null;
|
||||
}
|
||||
$obj = new $class();
|
||||
$reflectionProperty = new ReflectionProperty($class, 'id');
|
||||
$reflectionProperty = new \ReflectionProperty($class, 'id');
|
||||
$reflectionProperty->setAccessible(true);
|
||||
$reflectionProperty->setValue($obj, (int) $args[0]);
|
||||
|
||||
|
@@ -27,10 +27,10 @@ use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\Argument;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class AddressConverterTest extends TestCase
|
||||
|
@@ -22,7 +22,6 @@ use Chill\CalendarBundle\Entity\Calendar;
|
||||
use Chill\CalendarBundle\Entity\CalendarRange;
|
||||
use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\RemoteToLocalSync\CalendarRangeSyncer;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\Argument;
|
||||
@@ -33,6 +32,7 @@ use Symfony\Component\HttpClient\Response\MockResponse;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class CalendarRangeSyncerTest extends TestCase
|
||||
@@ -228,8 +228,8 @@ final class CalendarRangeSyncerTest extends TestCase
|
||||
$calendarRange = new CalendarRange();
|
||||
$calendarRange
|
||||
->setUser($user = new User())
|
||||
->setStartDate(new DateTimeImmutable('2020-01-01 15:00:00'))
|
||||
->setEndDate(new DateTimeImmutable('2020-01-01 15:30:00'))
|
||||
->setStartDate(new \DateTimeImmutable('2020-01-01 15:00:00'))
|
||||
->setEndDate(new \DateTimeImmutable('2020-01-01 15:30:00'))
|
||||
->addRemoteAttributes([
|
||||
'lastModifiedDateTime' => 0,
|
||||
'changeKey' => 'abc',
|
||||
@@ -244,11 +244,11 @@ final class CalendarRangeSyncerTest extends TestCase
|
||||
|
||||
$this->assertStringContainsString(
|
||||
'2022-06-10T15:30:00',
|
||||
$calendarRange->getStartDate()->format(DateTimeImmutable::ATOM)
|
||||
$calendarRange->getStartDate()->format(\DateTimeImmutable::ATOM)
|
||||
);
|
||||
$this->assertStringContainsString(
|
||||
'2022-06-10T17:30:00',
|
||||
$calendarRange->getEndDate()->format(DateTimeImmutable::ATOM)
|
||||
$calendarRange->getEndDate()->format(\DateTimeImmutable::ATOM)
|
||||
);
|
||||
$this->assertTrue($calendarRange->preventEnqueueChanges);
|
||||
}
|
||||
|
@@ -24,8 +24,6 @@ use Chill\CalendarBundle\Entity\Invite;
|
||||
use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\RemoteToLocalSync\CalendarSyncer;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Repository\UserRepositoryInterface;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeZone;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\Argument;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
@@ -35,6 +33,7 @@ use Symfony\Component\HttpClient\Response\MockResponse;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class CalendarSyncerTest extends TestCase
|
||||
@@ -362,9 +361,9 @@ final class CalendarSyncerTest extends TestCase
|
||||
parent::setUp();
|
||||
|
||||
// all tests should run when timezone = +02:00
|
||||
$brussels = new DateTimeZone('Europe/Brussels');
|
||||
$brussels = new \DateTimeZone('Europe/Brussels');
|
||||
|
||||
if (7200 === $brussels->getOffset(new DateTimeImmutable())) {
|
||||
if (7200 === $brussels->getOffset(new \DateTimeImmutable())) {
|
||||
date_default_timezone_set('Europe/Brussels');
|
||||
} else {
|
||||
date_default_timezone_set('Europe/Moscow');
|
||||
@@ -403,8 +402,8 @@ final class CalendarSyncerTest extends TestCase
|
||||
$calendar = new Calendar();
|
||||
$calendar
|
||||
->setMainUser($user = new User())
|
||||
->setStartDate(new DateTimeImmutable('2022-06-11 14:30:00'))
|
||||
->setEndDate(new DateTimeImmutable('2022-06-11 15:30:00'))
|
||||
->setStartDate(new \DateTimeImmutable('2022-06-11 14:30:00'))
|
||||
->setEndDate(new \DateTimeImmutable('2022-06-11 15:30:00'))
|
||||
->addUser($userA)
|
||||
->addUser($userB)
|
||||
->setCalendarRange(new CalendarRange())
|
||||
@@ -480,8 +479,8 @@ final class CalendarSyncerTest extends TestCase
|
||||
$calendar = new Calendar();
|
||||
$calendar
|
||||
->setMainUser($user = new User())
|
||||
->setStartDate(new DateTimeImmutable('2020-01-01 10:00:00'))
|
||||
->setEndDate(new DateTimeImmutable('2020-01-01 12:00:00'))
|
||||
->setStartDate(new \DateTimeImmutable('2020-01-01 10:00:00'))
|
||||
->setEndDate(new \DateTimeImmutable('2020-01-01 12:00:00'))
|
||||
->setCalendarRange(new CalendarRange())
|
||||
->addRemoteAttributes([
|
||||
'lastModifiedDateTime' => 0,
|
||||
@@ -498,11 +497,11 @@ final class CalendarSyncerTest extends TestCase
|
||||
|
||||
$this->assertStringContainsString(
|
||||
'2022-06-10T15:30:00',
|
||||
$calendar->getStartDate()->format(DateTimeImmutable::ATOM)
|
||||
$calendar->getStartDate()->format(\DateTimeImmutable::ATOM)
|
||||
);
|
||||
$this->assertStringContainsString(
|
||||
'2022-06-10T17:30:00',
|
||||
$calendar->getEndDate()->format(DateTimeImmutable::ATOM)
|
||||
$calendar->getEndDate()->format(\DateTimeImmutable::ATOM)
|
||||
);
|
||||
$this->assertTrue($calendar->preventEnqueueChanges);
|
||||
$this->assertGreaterThan($previousVersion, $calendar->getDateTimeVersion());
|
||||
@@ -524,8 +523,8 @@ final class CalendarSyncerTest extends TestCase
|
||||
$calendar = new Calendar();
|
||||
$calendar
|
||||
->setMainUser($user = new User())
|
||||
->setStartDate(new DateTimeImmutable('2022-06-10 15:30:00'))
|
||||
->setEndDate(new DateTimeImmutable('2022-06-10 17:30:00'))
|
||||
->setStartDate(new \DateTimeImmutable('2022-06-10 15:30:00'))
|
||||
->setEndDate(new \DateTimeImmutable('2022-06-10 17:30:00'))
|
||||
->setCalendarRange(new CalendarRange())
|
||||
->addRemoteAttributes([
|
||||
'lastModifiedDateTime' => 0,
|
||||
@@ -541,11 +540,11 @@ final class CalendarSyncerTest extends TestCase
|
||||
|
||||
$this->assertStringContainsString(
|
||||
'2022-06-10T15:30:00',
|
||||
$calendar->getStartDate()->format(DateTimeImmutable::ATOM)
|
||||
$calendar->getStartDate()->format(\DateTimeImmutable::ATOM)
|
||||
);
|
||||
$this->assertStringContainsString(
|
||||
'2022-06-10T17:30:00',
|
||||
$calendar->getEndDate()->format(DateTimeImmutable::ATOM)
|
||||
$calendar->getEndDate()->format(\DateTimeImmutable::ATOM)
|
||||
);
|
||||
$this->assertTrue($calendar->preventEnqueueChanges);
|
||||
$this->assertEquals(Calendar::STATUS_VALID, $calendar->getStatus());
|
||||
@@ -568,8 +567,8 @@ final class CalendarSyncerTest extends TestCase
|
||||
$calendar = new Calendar();
|
||||
$calendar
|
||||
->setMainUser($user = new User())
|
||||
->setStartDate(new DateTimeImmutable('2020-01-01 10:00:00'))
|
||||
->setEndDate(new DateTimeImmutable('2020-01-01 12:00:00'))
|
||||
->setStartDate(new \DateTimeImmutable('2020-01-01 10:00:00'))
|
||||
->setEndDate(new \DateTimeImmutable('2020-01-01 12:00:00'))
|
||||
->setCalendarRange(new CalendarRange())
|
||||
->addRemoteAttributes([
|
||||
'lastModifiedDateTime' => 0,
|
||||
@@ -585,11 +584,11 @@ final class CalendarSyncerTest extends TestCase
|
||||
|
||||
$this->assertStringContainsString(
|
||||
'2020-01-01T10:00:00',
|
||||
$calendar->getStartDate()->format(DateTimeImmutable::ATOM)
|
||||
$calendar->getStartDate()->format(\DateTimeImmutable::ATOM)
|
||||
);
|
||||
$this->assertStringContainsString(
|
||||
'2020-01-01T12:00:00',
|
||||
$calendar->getEndDate()->format(DateTimeImmutable::ATOM)
|
||||
$calendar->getEndDate()->format(\DateTimeImmutable::ATOM)
|
||||
);
|
||||
|
||||
$this->assertEquals(Calendar::STATUS_VALID, $calendar->getStatus());
|
||||
|
@@ -30,6 +30,7 @@ use Prophecy\PhpUnit\ProphecyTrait;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class LocationConverterTest extends TestCase
|
||||
|
@@ -22,6 +22,7 @@ use Symfony\Component\HttpClient\Response\MockResponse;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class MSUserAbsenceReaderTest extends TestCase
|
||||
@@ -55,7 +56,7 @@ class MSUserAbsenceReaderTest extends TestCase
|
||||
|
||||
$absenceReader = new MSUserAbsenceReader($client, $mapUser->reveal(), $clock);
|
||||
|
||||
self::assertNull($absenceReader->isUserAbsent($user), "when no user found, absence should be null");
|
||||
self::assertNull($absenceReader->isUserAbsent($user), 'when no user found, absence should be null');
|
||||
}
|
||||
|
||||
public function provideDataTestUserAbsence(): iterable
|
||||
@@ -81,7 +82,7 @@ class MSUserAbsenceReaderTest extends TestCase
|
||||
}
|
||||
JSON,
|
||||
false,
|
||||
"User is present"
|
||||
'User is present',
|
||||
];
|
||||
|
||||
yield [
|
||||
@@ -103,7 +104,7 @@ class MSUserAbsenceReaderTest extends TestCase
|
||||
}
|
||||
JSON,
|
||||
true,
|
||||
'User is absent with absence scheduled, we are within this period'
|
||||
'User is absent with absence scheduled, we are within this period',
|
||||
];
|
||||
|
||||
yield [
|
||||
@@ -125,7 +126,7 @@ class MSUserAbsenceReaderTest extends TestCase
|
||||
}
|
||||
JSON,
|
||||
false,
|
||||
'User is present: absence is scheduled for later'
|
||||
'User is present: absence is scheduled for later',
|
||||
];
|
||||
|
||||
yield [
|
||||
@@ -147,7 +148,7 @@ class MSUserAbsenceReaderTest extends TestCase
|
||||
}
|
||||
JSON,
|
||||
false,
|
||||
'User is present: absence is past'
|
||||
'User is present: absence is past',
|
||||
];
|
||||
|
||||
yield [
|
||||
@@ -169,7 +170,7 @@ class MSUserAbsenceReaderTest extends TestCase
|
||||
}
|
||||
JSON,
|
||||
true,
|
||||
"User is absent: absence is always enabled"
|
||||
'User is absent: absence is always enabled',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user