<?php
/** @noinspection PhpUnused */
namespace App\Listener\Admin;
use Agediss\RabbitMQ\Entity\AMQPMessageBody;
use App\Entity\Client;
use App\Entity\Motif;
use App\Entity\Plateforme;
use App\Entity\Pole;
use App\Entity\Societe;
use App\Entity\SousTraitant;
use App\Entity\Transporteur;
use Doctrine\Common\Annotations\AnnotationReader;
use EasyCorp\Bundle\EasyAdminBundle\Event\AfterEntityDeletedEvent;
use EasyCorp\Bundle\EasyAdminBundle\Event\AfterEntityPersistedEvent;
use EasyCorp\Bundle\EasyAdminBundle\Event\AfterEntityUpdatedEvent;
use EasyCorp\Bundle\EasyAdminBundle\Event\BeforeEntityPersistedEvent;
use http\Exception\RuntimeException;
use Psr\Log\LoggerInterface;
use ReflectionClass;
use Swagger\Logger;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\DataCollector\DumpDataCollector;
use Symfony\Component\HttpKernel\Profiler\Profiler;
class RequireListener implements EventSubscriberInterface
{
/**
* @var ContainerInterface
*/
private $container;
/**
* @var LoggerInterface
*/
private $logger;
public function __construct(ContainerInterface $container, LoggerInterface $logger)
{
$this->container = $container;
$this->logger = $logger;
}
public static function getSubscribedEvents(): array
{
return [
BeforeEntityPersistedEvent::class => ['CheckRequireFields'],
];
}
public function CheckRequireFields(BeforeEntityPersistedEvent $event): void
{
$entity = $event->getEntityInstance();
$reflextionClass = new ReflectionClass($entity);
$reader = new AnnotationReader();
foreach ($reflextionClass->getProperties() as $property) {
$annotation = $reader->getPropertyAnnotation($property, 'ORM');
$this->logger->info(json_encode($annotation));
}
}
}