$uriVariables * @param array $context * @return object */ public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []) { if($operation instanceof Delete){ throw new \RuntimeException('not supported', Response::HTTP_METHOD_NOT_ALLOWED); } /** @var Access $access */ $access = $this->security->getUser(); if ($data->getOrganization()->getId() !== $access->getOrganization()->getId()) { // TODO: voir à déplacer dans un voter? throw new \RuntimeException('forbidden', Response::HTTP_FORBIDDEN); } if ($operation instanceof Post) { // Create a new subdomain $subdomain = $this->subdomainService->addNewSubdomain( $data->getOrganization(), $data->getSubdomain(), $data->isActive() ); } else if ($operation instanceof Put && $data->isActive()) { // Activate a subdomain $data->setActive(false); // On triche : c'est le service qui va activer ce sous-domaine, pas le processor $subdomain = $this->subdomainService->activateSubdomain($data); } else { throw new \RuntimeException('not supported', Response::HTTP_METHOD_NOT_ALLOWED); } return $subdomain; } }