['updateNetworkSettings', EventPriorities::POST_WRITE], ]; } /** * @throws TransportExceptionInterface * @throws ServerExceptionInterface * @throws RedirectionExceptionInterface * @throws ClientExceptionInterface */ public function updateNetworkSettings(ViewEvent $event): void { $organizationalUnitOutput = $event->getControllerResult(); $method = $event->getRequest()->getMethod(); if (!$organizationalUnitOutput instanceof OrganizationalUnitOutput || !in_array($method, [Request::METHOD_POST, Request::METHOD_PUT, Request::METHOD_PATCH])) { return; } /** @var OrganizationalUnit $organizationalUnitEntity */ $organizationalUnitEntity = $organizationalUnitOutput->getEntity(); if ($organizationalUnitEntity->getType() === OrganizationalUnitTypes::CLASSROOM) { $this->syncOgBoot($organizationalUnitEntity); } } /** * @throws TransportExceptionInterface * @throws ServerExceptionInterface * @throws RedirectionExceptionInterface * @throws ClientExceptionInterface */ private function syncOgBoot(OrganizationalUnit $organizationalUnitEntity): void { $clients = $this->entityManager->getRepository(Client::class)->findClientsByOrganizationalUnitAndDescendants($organizationalUnitEntity->getId(), []); if (empty($clients)) { return; } /** @var Client $client */ foreach ($clients as $client) { if ($client->getTemplate() === null) { continue; } $this->postAction->__invoke($client, $client->getTemplate()); } } }