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:
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace App\Mcp\Tool\Composant;
|
namespace App\Mcp\Tool\Composant;
|
||||||
|
|
||||||
use App\Entity\Composant;
|
use App\Entity\Composant;
|
||||||
|
use App\Entity\ComposantConstructeurLink;
|
||||||
use App\Mcp\Tool\McpToolHelper;
|
use App\Mcp\Tool\McpToolHelper;
|
||||||
use App\Repository\ConstructeurRepository;
|
use App\Repository\ConstructeurRepository;
|
||||||
use App\Repository\ModelTypeRepository;
|
use App\Repository\ModelTypeRepository;
|
||||||
@@ -67,7 +68,10 @@ class CreateComposantTool
|
|||||||
if (!$c) {
|
if (!$c) {
|
||||||
$this->mcpError('not_found', "Constructeur not found: {$cId}");
|
$this->mcpError('not_found', "Constructeur not found: {$cId}");
|
||||||
}
|
}
|
||||||
$composant->addConstructeur($c);
|
$link = new ComposantConstructeurLink();
|
||||||
|
$link->setComposant($composant);
|
||||||
|
$link->setConstructeur($c);
|
||||||
|
$this->em->persist($link);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->em->persist($composant);
|
$this->em->persist($composant);
|
||||||
|
|||||||
@@ -30,10 +30,11 @@ class GetComposantTool
|
|||||||
}
|
}
|
||||||
|
|
||||||
$constructeurs = [];
|
$constructeurs = [];
|
||||||
foreach ($composant->getConstructeurs() as $c) {
|
foreach ($composant->getConstructeurLinks() as $link) {
|
||||||
$constructeurs[] = [
|
$constructeurs[] = [
|
||||||
'id' => $c->getId(),
|
'id' => $link->getConstructeur()->getId(),
|
||||||
'name' => $c->getName(),
|
'name' => $link->getConstructeur()->getName(),
|
||||||
|
'supplierReference' => $link->getSupplierReference(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Mcp\Tool\Composant;
|
namespace App\Mcp\Tool\Composant;
|
||||||
|
|
||||||
|
use App\Entity\ComposantConstructeurLink;
|
||||||
use App\Mcp\Tool\McpToolHelper;
|
use App\Mcp\Tool\McpToolHelper;
|
||||||
use App\Repository\ComposantRepository;
|
use App\Repository\ComposantRepository;
|
||||||
use App\Repository\ConstructeurRepository;
|
use App\Repository\ConstructeurRepository;
|
||||||
@@ -75,15 +76,18 @@ class UpdateComposantTool
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $constructeurIds) {
|
if (null !== $constructeurIds) {
|
||||||
foreach ($composant->getConstructeurs()->toArray() as $existing) {
|
foreach ($composant->getConstructeurLinks()->toArray() as $existing) {
|
||||||
$composant->removeConstructeur($existing);
|
$this->em->remove($existing);
|
||||||
}
|
}
|
||||||
foreach ($constructeurIds as $cId) {
|
foreach ($constructeurIds as $cId) {
|
||||||
$c = $this->constructeurs->find($cId);
|
$c = $this->constructeurs->find($cId);
|
||||||
if (!$c) {
|
if (!$c) {
|
||||||
$this->mcpError('not_found', "Constructeur not found: {$cId}");
|
$this->mcpError('not_found', "Constructeur not found: {$cId}");
|
||||||
}
|
}
|
||||||
$composant->addConstructeur($c);
|
$link = new ComposantConstructeurLink();
|
||||||
|
$link->setComposant($composant);
|
||||||
|
$link->setConstructeur($c);
|
||||||
|
$this->em->persist($link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace App\Mcp\Tool\Machine;
|
namespace App\Mcp\Tool\Machine;
|
||||||
|
|
||||||
use App\Entity\Machine;
|
use App\Entity\Machine;
|
||||||
|
use App\Entity\MachineConstructeurLink;
|
||||||
use App\Mcp\Tool\McpToolHelper;
|
use App\Mcp\Tool\McpToolHelper;
|
||||||
use App\Repository\ConstructeurRepository;
|
use App\Repository\ConstructeurRepository;
|
||||||
use App\Repository\SiteRepository;
|
use App\Repository\SiteRepository;
|
||||||
@@ -61,7 +62,10 @@ class CreateMachineTool
|
|||||||
if (!$c) {
|
if (!$c) {
|
||||||
$this->mcpError('not_found', "Constructeur not found: {$cId}");
|
$this->mcpError('not_found', "Constructeur not found: {$cId}");
|
||||||
}
|
}
|
||||||
$machine->addConstructeur($c);
|
$link = new MachineConstructeurLink();
|
||||||
|
$link->setMachine($machine);
|
||||||
|
$link->setConstructeur($c);
|
||||||
|
$this->em->persist($link);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->em->persist($machine);
|
$this->em->persist($machine);
|
||||||
|
|||||||
@@ -30,10 +30,11 @@ class GetMachineTool
|
|||||||
}
|
}
|
||||||
|
|
||||||
$constructeurs = [];
|
$constructeurs = [];
|
||||||
foreach ($machine->getConstructeurs() as $c) {
|
foreach ($machine->getConstructeurLinks() as $link) {
|
||||||
$constructeurs[] = [
|
$constructeurs[] = [
|
||||||
'id' => $c->getId(),
|
'id' => $link->getConstructeur()->getId(),
|
||||||
'name' => $c->getName(),
|
'name' => $link->getConstructeur()->getName(),
|
||||||
|
'supplierReference' => $link->getSupplierReference(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Mcp\Tool\Machine;
|
namespace App\Mcp\Tool\Machine;
|
||||||
|
|
||||||
|
use App\Entity\MachineConstructeurLink;
|
||||||
use App\Mcp\Tool\McpToolHelper;
|
use App\Mcp\Tool\McpToolHelper;
|
||||||
use App\Repository\ConstructeurRepository;
|
use App\Repository\ConstructeurRepository;
|
||||||
use App\Repository\MachineRepository;
|
use App\Repository\MachineRepository;
|
||||||
@@ -67,15 +68,18 @@ class UpdateMachineTool
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $constructeurIds) {
|
if (null !== $constructeurIds) {
|
||||||
foreach ($machine->getConstructeurs()->toArray() as $existing) {
|
foreach ($machine->getConstructeurLinks()->toArray() as $existing) {
|
||||||
$machine->removeConstructeur($existing);
|
$this->em->remove($existing);
|
||||||
}
|
}
|
||||||
foreach ($constructeurIds as $cId) {
|
foreach ($constructeurIds as $cId) {
|
||||||
$c = $this->constructeurs->find($cId);
|
$c = $this->constructeurs->find($cId);
|
||||||
if (!$c) {
|
if (!$c) {
|
||||||
$this->mcpError('not_found', "Constructeur not found: {$cId}");
|
$this->mcpError('not_found', "Constructeur not found: {$cId}");
|
||||||
}
|
}
|
||||||
$machine->addConstructeur($c);
|
$link = new MachineConstructeurLink();
|
||||||
|
$link->setMachine($machine);
|
||||||
|
$link->setConstructeur($c);
|
||||||
|
$this->em->persist($link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace App\Mcp\Tool\Piece;
|
namespace App\Mcp\Tool\Piece;
|
||||||
|
|
||||||
use App\Entity\Piece;
|
use App\Entity\Piece;
|
||||||
|
use App\Entity\PieceConstructeurLink;
|
||||||
use App\Mcp\Tool\McpToolHelper;
|
use App\Mcp\Tool\McpToolHelper;
|
||||||
use App\Repository\ConstructeurRepository;
|
use App\Repository\ConstructeurRepository;
|
||||||
use App\Repository\ModelTypeRepository;
|
use App\Repository\ModelTypeRepository;
|
||||||
@@ -67,7 +68,10 @@ class CreatePieceTool
|
|||||||
if (!$c) {
|
if (!$c) {
|
||||||
$this->mcpError('not_found', "Constructeur not found: {$cId}");
|
$this->mcpError('not_found', "Constructeur not found: {$cId}");
|
||||||
}
|
}
|
||||||
$piece->addConstructeur($c);
|
$link = new PieceConstructeurLink();
|
||||||
|
$link->setPiece($piece);
|
||||||
|
$link->setConstructeur($c);
|
||||||
|
$this->em->persist($link);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->em->persist($piece);
|
$this->em->persist($piece);
|
||||||
|
|||||||
@@ -30,10 +30,11 @@ class GetPieceTool
|
|||||||
}
|
}
|
||||||
|
|
||||||
$constructeurs = [];
|
$constructeurs = [];
|
||||||
foreach ($piece->getConstructeurs() as $c) {
|
foreach ($piece->getConstructeurLinks() as $link) {
|
||||||
$constructeurs[] = [
|
$constructeurs[] = [
|
||||||
'id' => $c->getId(),
|
'id' => $link->getConstructeur()->getId(),
|
||||||
'name' => $c->getName(),
|
'name' => $link->getConstructeur()->getName(),
|
||||||
|
'supplierReference' => $link->getSupplierReference(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Mcp\Tool\Piece;
|
namespace App\Mcp\Tool\Piece;
|
||||||
|
|
||||||
|
use App\Entity\PieceConstructeurLink;
|
||||||
use App\Mcp\Tool\McpToolHelper;
|
use App\Mcp\Tool\McpToolHelper;
|
||||||
use App\Repository\ConstructeurRepository;
|
use App\Repository\ConstructeurRepository;
|
||||||
use App\Repository\ModelTypeRepository;
|
use App\Repository\ModelTypeRepository;
|
||||||
@@ -75,15 +76,18 @@ class UpdatePieceTool
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $constructeurIds) {
|
if (null !== $constructeurIds) {
|
||||||
foreach ($piece->getConstructeurs()->toArray() as $existing) {
|
foreach ($piece->getConstructeurLinks()->toArray() as $existing) {
|
||||||
$piece->removeConstructeur($existing);
|
$this->em->remove($existing);
|
||||||
}
|
}
|
||||||
foreach ($constructeurIds as $cId) {
|
foreach ($constructeurIds as $cId) {
|
||||||
$c = $this->constructeurs->find($cId);
|
$c = $this->constructeurs->find($cId);
|
||||||
if (!$c) {
|
if (!$c) {
|
||||||
$this->mcpError('not_found', "Constructeur not found: {$cId}");
|
$this->mcpError('not_found', "Constructeur not found: {$cId}");
|
||||||
}
|
}
|
||||||
$piece->addConstructeur($c);
|
$link = new PieceConstructeurLink();
|
||||||
|
$link->setPiece($piece);
|
||||||
|
$link->setConstructeur($c);
|
||||||
|
$this->em->persist($link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace App\Mcp\Tool\Product;
|
namespace App\Mcp\Tool\Product;
|
||||||
|
|
||||||
use App\Entity\Product;
|
use App\Entity\Product;
|
||||||
|
use App\Entity\ProductConstructeurLink;
|
||||||
use App\Mcp\Tool\McpToolHelper;
|
use App\Mcp\Tool\McpToolHelper;
|
||||||
use App\Repository\ConstructeurRepository;
|
use App\Repository\ConstructeurRepository;
|
||||||
use App\Repository\ModelTypeRepository;
|
use App\Repository\ModelTypeRepository;
|
||||||
@@ -63,7 +64,10 @@ class CreateProductTool
|
|||||||
if (!$c) {
|
if (!$c) {
|
||||||
$this->mcpError('not_found', "Constructeur not found: {$cId}");
|
$this->mcpError('not_found', "Constructeur not found: {$cId}");
|
||||||
}
|
}
|
||||||
$product->addConstructeur($c);
|
$link = new ProductConstructeurLink();
|
||||||
|
$link->setProduct($product);
|
||||||
|
$link->setConstructeur($c);
|
||||||
|
$this->em->persist($link);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->em->persist($product);
|
$this->em->persist($product);
|
||||||
|
|||||||
@@ -30,10 +30,11 @@ class GetProductTool
|
|||||||
}
|
}
|
||||||
|
|
||||||
$constructeurs = [];
|
$constructeurs = [];
|
||||||
foreach ($product->getConstructeurs() as $c) {
|
foreach ($product->getConstructeurLinks() as $link) {
|
||||||
$constructeurs[] = [
|
$constructeurs[] = [
|
||||||
'id' => $c->getId(),
|
'id' => $link->getConstructeur()->getId(),
|
||||||
'name' => $c->getName(),
|
'name' => $link->getConstructeur()->getName(),
|
||||||
|
'supplierReference' => $link->getSupplierReference(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Mcp\Tool\Product;
|
namespace App\Mcp\Tool\Product;
|
||||||
|
|
||||||
|
use App\Entity\ProductConstructeurLink;
|
||||||
use App\Mcp\Tool\McpToolHelper;
|
use App\Mcp\Tool\McpToolHelper;
|
||||||
use App\Repository\ConstructeurRepository;
|
use App\Repository\ConstructeurRepository;
|
||||||
use App\Repository\ModelTypeRepository;
|
use App\Repository\ModelTypeRepository;
|
||||||
@@ -71,15 +72,18 @@ class UpdateProductTool
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $constructeurIds) {
|
if (null !== $constructeurIds) {
|
||||||
foreach ($product->getConstructeurs()->toArray() as $existing) {
|
foreach ($product->getConstructeurLinks()->toArray() as $existing) {
|
||||||
$product->removeConstructeur($existing);
|
$this->em->remove($existing);
|
||||||
}
|
}
|
||||||
foreach ($constructeurIds as $cId) {
|
foreach ($constructeurIds as $cId) {
|
||||||
$c = $this->constructeurs->find($cId);
|
$c = $this->constructeurs->find($cId);
|
||||||
if (!$c) {
|
if (!$c) {
|
||||||
$this->mcpError('not_found', "Constructeur not found: {$cId}");
|
$this->mcpError('not_found', "Constructeur not found: {$cId}");
|
||||||
}
|
}
|
||||||
$product->addConstructeur($c);
|
$link = new ProductConstructeurLink();
|
||||||
|
$link->setProduct($product);
|
||||||
|
$link->setConstructeur($c);
|
||||||
|
$this->em->persist($link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user