diff --git a/src/Command/UserBookingCacheChangeCommand.php b/src/Command/UserBookingCacheChangeCommand.php index bbe61c3..db4d877 100644 --- a/src/Command/UserBookingCacheChangeCommand.php +++ b/src/Command/UserBookingCacheChangeCommand.php @@ -16,6 +16,7 @@ class UserBookingCacheChangeCommand extends Command { public const DATE_FORMAT = 'Y-m-d\TH:i:s'; + public function __construct( private readonly UserBookingCacheServiceInterface $userBookingCacheServiceInterface ) { @@ -44,7 +45,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int 0 ); - $fieldValue = $io->ask('Please enter the value for ' .$field .' field (In case of date fields use format ' . UserBookingCacheChangeCommand::DATE_FORMAT . ')'); + $fieldValue = $io->ask('Please enter the value for '.$field.' field (In case of date fields use format '.UserBookingCacheChangeCommand::DATE_FORMAT.')'); // Date fields expect Datetime object. if ('start' === $field || 'end' === $field) { @@ -53,7 +54,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $data[$field] = $fieldValue; // Info on current state to be changed. - $io->writeln('Making the following changes to Cache Entry with id: ' . $entityId); + $io->writeln('Making the following changes to Cache Entry with id: '.$entityId); $io->info(json_encode($data)); $another = $io->confirm( diff --git a/src/DataPersister/UserBookingDataPersister.php b/src/DataPersister/UserBookingDataPersister.php index 0124fa9..a9095eb 100644 --- a/src/DataPersister/UserBookingDataPersister.php +++ b/src/DataPersister/UserBookingDataPersister.php @@ -46,8 +46,8 @@ public function remove($data, array $context = []): void NotificationTypeEnum::DELETE_SUCCESS )); - // @todo enable cache deletion. - //$this->userBookingCacheService->deleteCacheEntry($exchangeId); + // @todo enable cache deletion. + // $this->userBookingCacheService->deleteCacheEntry($exchangeId); } } catch (MicrosoftGraphCommunicationException|UserBookingException $e) { throw new HttpException($e->getCode(), 'Booking could not be deleted.'); @@ -70,7 +70,7 @@ public function persist($data, array $context = []): mixed )); // @todo enable cache alteration. - //$this->userBookingCacheService->changeCacheEntry($exchangeId, $newData); + // $this->userBookingCacheService->changeCacheEntry($exchangeId, $newData); } return $data; diff --git a/src/Service/BookingServiceInterface.php b/src/Service/BookingServiceInterface.php index 5392823..1f02f7e 100644 --- a/src/Service/BookingServiceInterface.php +++ b/src/Service/BookingServiceInterface.php @@ -120,10 +120,10 @@ public function getUserBookingFromApiData(array $data): UserBooking; */ public function createBodyUserId(string $id): string; - /** - * Get all future bookings. - * - * @return mixed - */ + /** + * Get all future bookings. + * + * @return mixed + */ public function getAllFutureBookings(string $token): GraphResponse; } diff --git a/src/Service/MicrosoftGraphBookingService.php b/src/Service/MicrosoftGraphBookingService.php index 3076fb7..f45afe3 100644 --- a/src/Service/MicrosoftGraphBookingService.php +++ b/src/Service/MicrosoftGraphBookingService.php @@ -509,23 +509,24 @@ public function getUserBookingFromApiData(array $data): UserBooking } } - /** - * {@inheritdoc} - */ - public function getAllFutureBookings($token): GraphResponse { - $now = new \DateTime(); - $nowFormatted = $now->setTimezone(new \DateTimeZone('UTC'))->format(MicrosoftGraphBookingService::DATE_FORMAT).'Z'; - - $query = implode('&', [ - "\$filter=end/dateTime gt '$nowFormatted'", - '$top=100', + /** + * {@inheritdoc} + */ + public function getAllFutureBookings($token): GraphResponse + { + $now = new \DateTime(); + $nowFormatted = $now->setTimezone(new \DateTimeZone('UTC'))->format(MicrosoftGraphBookingService::DATE_FORMAT).'Z'; + + $query = implode('&', [ + "\$filter=end/dateTime gt '$nowFormatted'", + '$top=100', ] - ); + ); - return $this->graphHelperService->request("/me/events?$query", $token); + return $this->graphHelperService->request("/me/events?$query", $token); } - /** + /** * {@inheritdoc} */ public function createBodyUserId(string $id): string diff --git a/src/Service/UserBookingCacheService.php b/src/Service/UserBookingCacheService.php index cbb3d62..54a8880 100644 --- a/src/Service/UserBookingCacheService.php +++ b/src/Service/UserBookingCacheService.php @@ -81,10 +81,10 @@ public function addCacheEntry(UserBooking $userBooking): void public function changeCacheEntry(string $exchangeId, array $changes): void { $entity = $this->entityManager->getRepository(UserBookingCacheEntry::class) - ->findOneBy(['exchangeId' => $exchangeId]); + ->findOneBy(['exchangeId' => $exchangeId]); if (!$entity) { - throw new \Exception('No cache entry found for exchangeId: '. $exchangeId); + throw new \Exception('No cache entry found for exchangeId: '.$exchangeId); } foreach ($changes as $field => $value) { @@ -107,12 +107,11 @@ public function changeCacheEntry(string $exchangeId, array $changes): void */ public function deleteCacheEntry(string $exchangeId): void { - $entity = $this->entityManager->getRepository(UserBookingCacheEntry::class) - ->findOneBy(['exchangeId' => $exchangeId]); - if ($entity) { - $this->entityManager->remove($entity); - } - + $entity = $this->entityManager->getRepository(UserBookingCacheEntry::class) + ->findOneBy(['exchangeId' => $exchangeId]); + if ($entity) { + $this->entityManager->remove($entity); + } } /** @@ -169,16 +168,17 @@ private function clearUserBookingCache(): void } } - /** - * Remove UID from front and back of id. - * - * @param $documentBodyUid - * - * @return string - */ - private function extractRealUid($documentBodyUid): string { - $documentBodyUid = ltrim($documentBodyUid, 'UID-'); - - return rtrim($documentBodyUid, '-UID'); + /** + * Remove UID from front and back of id. + * + * @param $documentBodyUid + * + * @return string + */ + private function extractRealUid($documentBodyUid): string + { + $documentBodyUid = ltrim($documentBodyUid, 'UID-'); + + return rtrim($documentBodyUid, '-UID'); } } diff --git a/src/Service/UserBookingCacheServiceInterface.php b/src/Service/UserBookingCacheServiceInterface.php index 6970b00..a176823 100644 --- a/src/Service/UserBookingCacheServiceInterface.php +++ b/src/Service/UserBookingCacheServiceInterface.php @@ -3,7 +3,6 @@ namespace App\Service; use App\Entity\Main\UserBooking; -use App\Entity\Main\UserBookingCacheEntry; /** * @see https://github.com/microsoftgraph/msgraph-sdk-php