requireRole($this->security, 'ROLE_GESTIONNAIRE'); $link = match ($linkType) { 'composant' => $this->componentLinks->find($linkId), 'piece' => $this->pieceLinks->find($linkId), 'product' => $this->productLinks->find($linkId), default => $this->mcpError('Validation', "Unknown link type '{$linkType}'. Expected composant, piece, or product."), }; if (null === $link) { $this->mcpError('NotFound', "Link {$linkId} of type {$linkType} not found."); } $this->em->remove($link); $this->em->flush(); return $this->jsonResponse(['deleted' => true, 'id' => $linkId, 'type' => $linkType]); } }