mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-03-03 12:39:42 +00:00
apply rector rules
This commit is contained in:
@@ -26,14 +26,13 @@ use Chill\MainBundle\Repository\UserRepositoryInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
#[\Symfony\Component\Console\Attribute\AsCommand(name:'chill:calendar:msgraph-user-map-subscribe')]
|
||||
final class MapAndSubscribeUserCalendarCommand extends Command
|
||||
final class MapAndSubscribeUserCalendarCommand
|
||||
{
|
||||
protected static $defaultDescription = 'MSGraph: collect user metadata and create subscription on events for users, and sync the user absence-presence';
|
||||
private static $defaultDescription = 'MSGraph: collect user metadata and create subscription on events for users, and sync the user absence-presence';
|
||||
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $em,
|
||||
@@ -43,16 +42,20 @@ final class MapAndSubscribeUserCalendarCommand extends Command
|
||||
private readonly UserRepositoryInterface $userRepository,
|
||||
private readonly MSUserAbsenceSync $userAbsenceSync,
|
||||
) {
|
||||
parent::__construct('chill:calendar:msgraph-user-map-subscribe');
|
||||
}
|
||||
|
||||
public function execute(InputInterface $input, OutputInterface $output): int
|
||||
public function __invoke(
|
||||
#[\Symfony\Component\Console\Attribute\Option(name: 'renew-before-end-interval', shortcut: 'r', mode: InputOption::VALUE_OPTIONAL, description: 'delay before renewing subscription')]
|
||||
string $renewBeforeEndInterval = 'P1D',
|
||||
#[\Symfony\Component\Console\Attribute\Option(name: 'subscription-duration', shortcut: 's', mode: InputOption::VALUE_OPTIONAL, description: 'duration for the subscription')]
|
||||
string $subscriptionDuration = 'PT4230M',
|
||||
OutputInterface $output): int
|
||||
{
|
||||
$this->logger->info(self::class.' execute command');
|
||||
|
||||
$limit = 50;
|
||||
$offset = 0;
|
||||
$expiration = (new \DateTimeImmutable('now'))->add(new \DateInterval($input->getOption('subscription-duration')));
|
||||
$expiration = (new \DateTimeImmutable('now'))->add(new \DateInterval($subscriptionDuration));
|
||||
$users = $this->userRepository->findAllAsArray('fr');
|
||||
$created = 0;
|
||||
$renewed = 0;
|
||||
@@ -156,25 +159,4 @@ final class MapAndSubscribeUserCalendarCommand extends Command
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
protected function configure(): void
|
||||
{
|
||||
parent::configure();
|
||||
|
||||
$this
|
||||
->addOption(
|
||||
'renew-before-end-interval',
|
||||
'r',
|
||||
InputOption::VALUE_OPTIONAL,
|
||||
'delay before renewing subscription',
|
||||
'P1D'
|
||||
)
|
||||
->addOption(
|
||||
'subscription-duration',
|
||||
's',
|
||||
InputOption::VALUE_OPTIONAL,
|
||||
'duration for the subscription',
|
||||
'PT4230M'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,14 +30,13 @@ use libphonenumber\PhoneNumberType;
|
||||
use libphonenumber\PhoneNumberUtil;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Helper\QuestionHelper;
|
||||
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 Symfony\Component\Notifier\TexterInterface;
|
||||
|
||||
#[\Symfony\Component\Console\Attribute\AsCommand(name: 'chill:calendar:test-send-short-message', description: 'Test sending a SMS for a dummy calendar appointment')]
|
||||
class SendTestShortMessageOnCalendarCommand extends Command
|
||||
class SendTestShortMessageOnCalendarCommand
|
||||
{
|
||||
protected static $defaultDescription = 'Test sending a SMS for a dummy calendar appointment';
|
||||
|
||||
@@ -48,12 +47,9 @@ class SendTestShortMessageOnCalendarCommand extends Command
|
||||
private readonly TexterInterface $transporter,
|
||||
private readonly UserRepositoryInterface $userRepository,
|
||||
) {
|
||||
parent::__construct('chill:calendar:test-send-short-message');
|
||||
}
|
||||
|
||||
protected function configure() {}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
public function __invoke(OutputInterface $output): int
|
||||
{
|
||||
$calendar = new Calendar();
|
||||
$calendar->setSendSMS(true);
|
||||
|
||||
@@ -499,15 +499,9 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
|
||||
public static function loadValidatorMetadata(ClassMetadata $metadata): void
|
||||
{
|
||||
$metadata->addPropertyConstraint('startDate', new NotBlank());
|
||||
$metadata->addPropertyConstraint('startDate', new Range([
|
||||
'min' => '2 years ago',
|
||||
'max' => '+ 2 years',
|
||||
]));
|
||||
$metadata->addPropertyConstraint('startDate', new Range(min: '2 years ago', max: '+ 2 years'));
|
||||
$metadata->addPropertyConstraint('endDate', new NotBlank());
|
||||
$metadata->addPropertyConstraint('endDate', new Range([
|
||||
'min' => '2 years ago',
|
||||
'max' => '+ 2 years',
|
||||
]));
|
||||
$metadata->addPropertyConstraint('endDate', new Range(min: '2 years ago', max: '+ 2 years'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -156,10 +156,6 @@ class CalendarRangeRepository implements ObjectRepository
|
||||
$qb->expr()->isNull('calendar')
|
||||
)
|
||||
)
|
||||
->setParameters([
|
||||
'user' => $user,
|
||||
'startDate' => $from,
|
||||
'endDate' => $to,
|
||||
]);
|
||||
->setParameters(new \Doctrine\Common\Collections\ArrayCollection([new \Doctrine\ORM\Query\Parameter('user', $user), new \Doctrine\ORM\Query\Parameter('startDate', $from), new \Doctrine\ORM\Query\Parameter('endDate', $to)]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,11 +193,7 @@ class CalendarRepository implements ObjectRepository
|
||||
$qb->expr()->lte('c.endDate', ':endDate'),
|
||||
)
|
||||
)
|
||||
->setParameters([
|
||||
'user' => $user,
|
||||
'startDate' => $from,
|
||||
'endDate' => $to,
|
||||
]);
|
||||
->setParameters(new \Doctrine\Common\Collections\ArrayCollection([new \Doctrine\ORM\Query\Parameter('user', $user), new \Doctrine\ORM\Query\Parameter('startDate', $from), new \Doctrine\ORM\Query\Parameter('endDate', $to)]));
|
||||
}
|
||||
|
||||
private function queryByNotificationAvailable(\DateTimeImmutable $startDate, \DateTimeImmutable $endDate): QueryBuilder
|
||||
@@ -216,13 +212,7 @@ class CalendarRepository implements ObjectRepository
|
||||
)
|
||||
);
|
||||
|
||||
$qb->setParameters([
|
||||
'true' => true,
|
||||
'startDate' => $startDate,
|
||||
'endDate' => $endDate,
|
||||
'pending' => Calendar::SMS_PENDING,
|
||||
'cancel_pending' => Calendar::SMS_CANCEL_PENDING,
|
||||
]);
|
||||
$qb->setParameters(new \Doctrine\Common\Collections\ArrayCollection([new \Doctrine\ORM\Query\Parameter('true', true), new \Doctrine\ORM\Query\Parameter('startDate', $startDate), new \Doctrine\ORM\Query\Parameter('endDate', $endDate), new \Doctrine\ORM\Query\Parameter('pending', Calendar::SMS_PENDING), new \Doctrine\ORM\Query\Parameter('cancel_pending', Calendar::SMS_CANCEL_PENDING)]));
|
||||
|
||||
return $qb;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ use Doctrine\Persistence\ManagerRegistry;
|
||||
* @method CancelReason|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method CancelReason[] findAll()
|
||||
* @method CancelReason[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*
|
||||
* @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\CalendarBundle\Entity\CancelReason>
|
||||
*/
|
||||
class CancelReasonRepository extends ServiceEntityRepository
|
||||
{
|
||||
|
||||
@@ -36,7 +36,7 @@ class CalendarDocVoter extends Voter
|
||||
return \in_array($attribute, self::ALL, true) && ($subject instanceof CalendarDoc || $subject instanceof Calendar);
|
||||
}
|
||||
|
||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool
|
||||
{
|
||||
if ($subject instanceof Calendar) {
|
||||
return match ($attribute) {
|
||||
|
||||
@@ -35,7 +35,7 @@ class InviteVoter extends Voter
|
||||
* @param string $attribute
|
||||
* @param Invite $subject
|
||||
*/
|
||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool
|
||||
{
|
||||
return $token->getUser() === $subject->getUser();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user