refactor(mcp) : update MCP tools to use ConstructeurLinks

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Matthieu
2026-03-31 14:29:10 +02:00
parent 43fafc2251
commit 691f632be0
12 changed files with 64 additions and 28 deletions

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace App\Mcp\Tool\Piece;
use App\Entity\PieceConstructeurLink;
use App\Mcp\Tool\McpToolHelper;
use App\Repository\ConstructeurRepository;
use App\Repository\ModelTypeRepository;
@@ -75,15 +76,18 @@ class UpdatePieceTool
}
if (null !== $constructeurIds) {
foreach ($piece->getConstructeurs()->toArray() as $existing) {
$piece->removeConstructeur($existing);
foreach ($piece->getConstructeurLinks()->toArray() as $existing) {
$this->em->remove($existing);
}
foreach ($constructeurIds as $cId) {
$c = $this->constructeurs->find($cId);
if (!$c) {
$this->mcpError('not_found', "Constructeur not found: {$cId}");
}
$piece->addConstructeur($c);
$link = new PieceConstructeurLink();
$link->setPiece($piece);
$link->setConstructeur($c);
$this->em->persist($link);
}
}