['syncPxeTemplate', EventPriorities::POST_WRITE], ]; } /** * @throws TransportExceptionInterface * @throws ServerExceptionInterface * @throws RedirectionExceptionInterface * @throws ClientExceptionInterface */ public function syncPxeTemplate(ViewEvent $event): void { $pxeTemplateOutput = $event->getControllerResult(); $method = $event->getRequest()->getMethod(); if (!$pxeTemplateOutput instanceof PxeTemplateOutput || !in_array($method, [Request::METHOD_POST, Request::METHOD_PUT, Request::METHOD_PATCH])) { return; } /** @var PxeTemplate $templateEntity */ $templateEntity = $pxeTemplateOutput->getEntity(); try { $this->postTemplateAction->__invoke($templateEntity); } catch (\Exception $e) { return ; } $clients = $this->entityManager->getRepository(Client::class)->findBy(['template' => $templateEntity]); foreach ($clients as $client) { $this->postAction->__invoke($client, $templateEntity); } } }