publisher = $publisher; $this->em = $em; $this->logger = $logger; $this->updatesGenerator = $updatesGenerator; } public function __invoke(VisitLocated $shortUrlLocated): void { $visitId = $shortUrlLocated->visitId(); /** @var Visit|null $visit */ $visit = $this->em->find(Visit::class, $visitId); if ($visit === null) { $this->logger->warning('Tried to notify mercure for visit with id "{visitId}", but it does not exist.', [ 'visitId' => $visitId, ]); return; } try { ($this->publisher)($this->updatesGenerator->newShortUrlVisitUpdate($visit)); ($this->publisher)($this->updatesGenerator->newVisitUpdate($visit)); } catch (Throwable $e) { $this->logger->debug('Error while trying to notify mercure hub with new visit. {e}', [ 'e' => $e, ]); } } }