daa0cb1e28
Auto Tag Develop / tag (push) Successful in 9s
- Nouvelles entites ConstructeurCategorie (referentiel M2M) et ConstructeurTelephone (1-N) - Constructeur : retrait colonne phone, ajout collections telephones/categories, groupes de serialisation constructeur:read/write - Migration : cree les 3 tables, migre la colonne phone existante vers constructeur_telephone, drop phone - Commande app:import-fournisseurs (dry-run par defaut, --force) : non destructive, find-or-create par nom, ne touche jamais un ID existant, ajout-seulement pour telephones/categories - MAJ MCP tools / MachineStructureController / audit subscriber / tests - Frontend : page constructeurs avec telephones multiples + categories (tableau, filtre, formulaire), composable useConstructeurCategories, composant ConstructeurCategorieSelect Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
52 lines
1.6 KiB
PHP
52 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Mcp\Tool\Constructeur;
|
|
|
|
use App\Mcp\Tool\McpToolHelper;
|
|
use App\Repository\ConstructeurRepository;
|
|
use Mcp\Capability\Attribute\McpTool;
|
|
use Mcp\Schema\Result\CallToolResult;
|
|
|
|
#[McpTool(
|
|
name: 'get_constructeur',
|
|
description: 'Get a single constructeur (manufacturer/supplier) by ID with all its details.',
|
|
)]
|
|
class GetConstructeurTool
|
|
{
|
|
use McpToolHelper;
|
|
|
|
public function __construct(
|
|
private readonly ConstructeurRepository $constructeurs,
|
|
) {}
|
|
|
|
public function __invoke(string $constructeurId): CallToolResult
|
|
{
|
|
$constructeur = $this->constructeurs->find($constructeurId);
|
|
|
|
if (!$constructeur) {
|
|
$this->mcpError('not_found', "Constructeur not found: {$constructeurId}");
|
|
}
|
|
|
|
$telephones = array_map(
|
|
static fn ($t): array => ['id' => $t->getId(), 'numero' => $t->getNumero(), 'label' => $t->getLabel()],
|
|
$constructeur->getTelephones()->toArray(),
|
|
);
|
|
$categories = array_values(array_filter(array_map(
|
|
static fn ($c): ?string => $c->getName(),
|
|
$constructeur->getCategories()->toArray(),
|
|
)));
|
|
|
|
return $this->jsonResponse([
|
|
'id' => $constructeur->getId(),
|
|
'name' => $constructeur->getName(),
|
|
'email' => $constructeur->getEmail(),
|
|
'telephones' => array_values($telephones),
|
|
'categories' => $categories,
|
|
'createdAt' => $constructeur->getCreatedAt()->format('Y-m-d H:i:s'),
|
|
'updatedAt' => $constructeur->getUpdatedAt()->format('Y-m-d H:i:s'),
|
|
]);
|
|
}
|
|
}
|