- Extract shared ID generation + timestamps into CuidEntityTrait used by all entities - Create AbstractAuditSubscriber to deduplicate audit logic across 7 subscribers - Merge per-entity history controllers into single EntityHistoryController - Delete redundant ComposantHistory/MachineHistory/PieceHistory/ProductHistoryController - Add OpenApiDecorator for API documentation customization - Disable failOnDeprecation in PHPUnit (vendor API Platform deprecation) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
34 lines
831 B
PHP
34 lines
831 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\EventSubscriber;
|
|
|
|
use App\Entity\Constructeur;
|
|
use Doctrine\Bundle\DoctrineBundle\Attribute\AsDoctrineListener;
|
|
use Doctrine\ORM\Events;
|
|
|
|
#[AsDoctrineListener(event: Events::onFlush)]
|
|
final class ConstructeurAuditSubscriber extends AbstractAuditSubscriber
|
|
{
|
|
protected function supports(object $entity): bool
|
|
{
|
|
return $entity instanceof Constructeur;
|
|
}
|
|
|
|
protected function entityType(): string
|
|
{
|
|
return 'constructeur';
|
|
}
|
|
|
|
protected function snapshotEntity(object $entity): array
|
|
{
|
|
return [
|
|
'id' => $entity->getId(),
|
|
'name' => $this->safeGet($entity, 'getName'),
|
|
'email' => $this->safeGet($entity, 'getEmail'),
|
|
'phone' => $this->safeGet($entity, 'getPhone'),
|
|
];
|
|
}
|
|
}
|