add caldav:sync murph task
This commit is contained in:
parent
cc4491447d
commit
8aea7dd8f4
|
@ -17,6 +17,7 @@ use App\Core\Manager\EntityManager;
|
|||
use App\Repository\EventRepositoryQuery;
|
||||
use App\Factory\EventFactory;
|
||||
use App\Entity\Speaker;
|
||||
use App\Entity\Event;
|
||||
|
||||
#[AsCommand(
|
||||
name: 'caldav:sync',
|
||||
|
@ -89,7 +90,13 @@ class CaldavSyncCommand extends Command
|
|||
continue;
|
||||
}
|
||||
|
||||
$this->addEvent($project, $calEvent, $speaker);
|
||||
$event = $this->addEvent($project, $calEvent, $speaker);
|
||||
|
||||
$output->writeln(sprintf(
|
||||
'Évènement <comment>[%s] %s</comment> importé',
|
||||
$event->getStartAt()->format('d/m/Y H:i'),
|
||||
$event->getSummary()
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +104,7 @@ class CaldavSyncCommand extends Command
|
|||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
protected function addEvent(Project $project, CalEvent $calEvent, Speaker $speaker)
|
||||
protected function addEvent(Project $project, CalEvent $calEvent, Speaker $speaker): Event
|
||||
{
|
||||
$event = $this->eventQuery->create()
|
||||
->where('.uid = :uid')
|
||||
|
@ -115,5 +122,7 @@ class CaldavSyncCommand extends Command
|
|||
|
||||
$this->manager->update($event);
|
||||
$this->manager->update($speaker);
|
||||
|
||||
return $event;
|
||||
}
|
||||
}
|
||||
|
|
43
src/EventSubscriber/Task/CaldavSyncEventSubscriber.php
Normal file
43
src/EventSubscriber/Task/CaldavSyncEventSubscriber.php
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace App\EventSubscriber\Task;
|
||||
|
||||
use App\Core\Event\Task\TaskInitEvent;
|
||||
use App\Core\Event\Task\TaskRunRequestedEvent;
|
||||
use App\Core\EventSubscriber\Task\TaskEventSubscriber;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
|
||||
class CaldavSyncEventSubscriber extends TaskEventSubscriber
|
||||
{
|
||||
protected KernelInterface $kernel;
|
||||
|
||||
public function __construct(KernelInterface $kernel)
|
||||
{
|
||||
$this->kernel = $kernel;
|
||||
}
|
||||
|
||||
public function onInit(TaskInitEvent $event)
|
||||
{
|
||||
$event->addTask('caldav:sync', '📅 Calendrier', 'Synchronisation');
|
||||
}
|
||||
|
||||
public function onRunRequest(TaskRunRequestedEvent $event)
|
||||
{
|
||||
if ('caldav:sync' !== $event->getTask()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$application = new Application($this->kernel);
|
||||
$application->setAutoExit(false);
|
||||
|
||||
$input = new ArrayInput([
|
||||
'command' => 'caldav:sync',
|
||||
'-e' => $this->kernel->getEnvironment(),
|
||||
]);
|
||||
|
||||
$application->run($input, $event->getOutput());
|
||||
}
|
||||
}
|
|
@ -95,7 +95,7 @@ class CaldavClient
|
|||
continue;
|
||||
}
|
||||
|
||||
@list($tz, $time) = explode(':', $lines);
|
||||
$time = explode(':', $lines)[1] ?? null;
|
||||
|
||||
if (empty($time)) {
|
||||
continue;
|
||||
|
|
Loading…
Reference in a new issue