<?php
namespace App\EventSubscriber;
use App\Entity\Chantier;
use App\Entity\CommercialNotification;
use App\Entity\User;
use App\Service\Notification;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\Entity;
use EasyCorp\Bundle\EasyAdminBundle\Event\AfterEntityUpdatedEvent;
use EasyCorp\Bundle\EasyAdminBundle\Event\BeforeCrudActionEvent;
use EasyCorp\Bundle\EasyAdminBundle\Event\BeforeEntityPersistedEvent;
use EasyCorp\Bundle\EasyAdminBundle\Event\BeforeEntityUpdatedEvent;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
class EasyAdminChantierSubscriber implements EventSubscriberInterface
{
private $entityManager;
private $container;
private $notification;
private $status;
public function __construct(
EntityManagerInterface $entityManager,
ContainerInterface $container,
Notification $notification
){
$this->entityManager = $entityManager;
$this->container = $container;
$this->notification = $notification;
}
public static function getSubscribedEvents()
{
return [
BeforeEntityPersistedEvent::class => ['add'],
BeforeEntityUpdatedEvent::class => ['update'],
AfterEntityUpdatedEvent::class => ['after'],
BeforeCrudActionEvent::class => ['before']
];
}
public function update(BeforeEntityUpdatedEvent $event)
{
$entity = $event->getEntityInstance();
if (!$entity instanceof Chantier) {
return;
}
}
public function before(BeforeCrudActionEvent $event)
{
$instance = $event->getAdminContext()->getEntity()->getInstance();
if (!$instance instanceof Chantier) {
return;
}
$this->status = $instance->getStatus();
}
public function after(AfterEntityUpdatedEvent $event)
{
$entity = $event->getEntityInstance();
if (!$entity instanceof Chantier) {
return;
}
}
public function add(BeforeEntityPersistedEvent $event)
{
$entity = $event->getEntityInstance();
if (!$entity instanceof Chantier) {
return;
}
}
}