requireRole($this->security, 'ROLE_GESTIONNAIRE'); $constructeur = $this->constructeurs->find($constructeurId); if (!$constructeur) { $this->mcpError('not_found', "Constructeur not found: {$constructeurId}"); } if (null !== $name) { $constructeur->setName($name); } if (null !== $email) { $constructeur->setEmail($email); } if (null !== $phone && '' !== $phone) { $alreadyPresent = false; foreach ($constructeur->getTelephones() as $existing) { if ($existing->getNumero() === $phone) { $alreadyPresent = true; break; } } if (!$alreadyPresent) { $telephone = new ConstructeurTelephone(); $telephone->setNumero($phone); $constructeur->addTelephone($telephone); } } $this->em->flush(); return $this->jsonResponse(['id' => $constructeur->getId(), 'name' => $constructeur->getName()]); } }