All checks were successful
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>
110 lines
3.3 KiB
PHP
110 lines
3.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Entity;
|
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
|
|
use ApiPlatform\Metadata\ApiFilter;
|
|
use ApiPlatform\Metadata\ApiResource;
|
|
use ApiPlatform\Metadata\Delete;
|
|
use ApiPlatform\Metadata\Get;
|
|
use ApiPlatform\Metadata\GetCollection;
|
|
use ApiPlatform\Metadata\Patch;
|
|
use ApiPlatform\Metadata\Post;
|
|
use ApiPlatform\Metadata\Put;
|
|
use App\Entity\Trait\CuidEntityTrait;
|
|
use App\Repository\ConstructeurTelephoneRepository;
|
|
use DateTimeImmutable;
|
|
use Doctrine\DBAL\Types\Types;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Component\Serializer\Attribute\Groups;
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
|
|
#[ORM\Entity(repositoryClass: ConstructeurTelephoneRepository::class)]
|
|
#[ORM\Table(name: 'constructeur_telephone')]
|
|
#[ORM\Index(name: 'idx_constructeur_telephone_constructeur', columns: ['constructeurid'])]
|
|
#[ORM\HasLifecycleCallbacks]
|
|
#[ApiResource(
|
|
description: 'Numéro de téléphone rattaché à un fournisseur. Un fournisseur peut en avoir plusieurs (standard, mobile, comptabilité…).',
|
|
operations: [
|
|
new Get(security: "is_granted('ROLE_VIEWER')"),
|
|
new GetCollection(security: "is_granted('ROLE_VIEWER')"),
|
|
new Post(security: "is_granted('ROLE_GESTIONNAIRE')"),
|
|
new Put(security: "is_granted('ROLE_GESTIONNAIRE')"),
|
|
new Patch(security: "is_granted('ROLE_GESTIONNAIRE')"),
|
|
new Delete(security: "is_granted('ROLE_GESTIONNAIRE')"),
|
|
]
|
|
)]
|
|
#[ApiFilter(SearchFilter::class, properties: ['constructeur' => 'exact'])]
|
|
class ConstructeurTelephone
|
|
{
|
|
use CuidEntityTrait;
|
|
|
|
#[ORM\Id]
|
|
#[ORM\Column(type: Types::STRING, length: 36)]
|
|
#[Groups(['constructeur:read'])]
|
|
private ?string $id = null;
|
|
|
|
#[ORM\ManyToOne(targetEntity: Constructeur::class, inversedBy: 'telephones')]
|
|
#[ORM\JoinColumn(name: 'constructeurId', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')]
|
|
private ?Constructeur $constructeur = null;
|
|
|
|
#[ORM\Column(type: Types::STRING, length: 50)]
|
|
#[Assert\NotBlank(message: 'Le numéro de téléphone est obligatoire.')]
|
|
#[Groups(['constructeur:read', 'constructeur:write'])]
|
|
private ?string $numero = null;
|
|
|
|
#[ORM\Column(type: Types::STRING, length: 100, nullable: true)]
|
|
#[Groups(['constructeur:read', 'constructeur:write'])]
|
|
private ?string $label = null;
|
|
|
|
#[ORM\Column(type: Types::DATETIME_IMMUTABLE, name: 'createdAt')]
|
|
private DateTimeImmutable $createdAt;
|
|
|
|
#[ORM\Column(type: Types::DATETIME_IMMUTABLE, name: 'updatedAt')]
|
|
private DateTimeImmutable $updatedAt;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->createdAt = new DateTimeImmutable();
|
|
$this->updatedAt = new DateTimeImmutable();
|
|
}
|
|
|
|
public function getConstructeur(): ?Constructeur
|
|
{
|
|
return $this->constructeur;
|
|
}
|
|
|
|
public function setConstructeur(?Constructeur $constructeur): static
|
|
{
|
|
$this->constructeur = $constructeur;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getNumero(): ?string
|
|
{
|
|
return $this->numero;
|
|
}
|
|
|
|
public function setNumero(string $numero): static
|
|
{
|
|
$this->numero = $numero;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getLabel(): ?string
|
|
{
|
|
return $this->label;
|
|
}
|
|
|
|
public function setLabel(?string $label): static
|
|
{
|
|
$this->label = $label;
|
|
|
|
return $this;
|
|
}
|
|
}
|