Linux SRV-16 6.18.44-paas #1 SMP PREEMPT_DYNAMIC Thu Aug 13 10:08:12 UTC 2026 x86_64
/
srv
/
data
/
web
/
vhosts
/
716cf56cb2.url-de-test.ws
/
htdocs
/
src
/
Command
/
/srv/data/web/vhosts/716cf56cb2.url-de-test.ws/htdocs/src/Command/SyncCalendarCommand.php
<?php namespace App\Command; use App\Repository\LogementRepository; use App\Service\IcalService; use Psr\Log\LoggerInterface; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; class SyncCalendarCommand extends Command { protected static $defaultName = 'SyncCalendar'; protected static $defaultDescription = 'Add a short description for your command'; private $logementRepository; private $icalService; private $logger; public function __construct(LogementRepository $logementRepository, IcalService $icalService, LoggerInterface $logger) { parent::__construct(); $this->logementRepository = $logementRepository; $this->icalService = $icalService; $this->logger = $logger; } protected function execute(InputInterface $input, OutputInterface $output): int { try { $logements = $this->logementRepository->findLogementsNotDeleted(); $date = new \DateTime(); foreach ($logements as $logement) { foreach ($logement->getIcals() as $ical) { if (!$ical->isIsGenerated()) { $this->icalService->import($logement, $ical->getAccessLink()); } } } $output->writeln('Synchronization effectué ' . $date->format('d-m-Y h:i')); $this->logger->info('Synchronization effectuée ' . $date->format('d-m-Y h:i')); return Command::SUCCESS; } catch (\Exception $e) { $this->logger->error('Erreur lors de la synchronisation : ' . $e->getMessage()); return Command::FAILURE; } } }