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\Product;
use App\Entity\ProductConstructeurLink;
use App\Mcp\Tool\McpToolHelper;
use App\Repository\ConstructeurRepository;
use App\Repository\ModelTypeRepository;
@@ -71,15 +72,18 @@ class UpdateProductTool
}
if (null !== $constructeurIds) {
foreach ($product->getConstructeurs()->toArray() as $existing) {
$product->removeConstructeur($existing);
foreach ($product->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}");
}
$product->addConstructeur($c);
$link = new ProductConstructeurLink();
$link->setProduct($product);
$link->setConstructeur($c);
$this->em->persist($link);
}
}