src/EventListener/BeforeRequestListener.php line 32

Open in your IDE?
  1. <?php
  2. namespace App\EventListener;
  3. use App\AclPermission\AclPermissionManager;
  4. use App\Doctrine\HotelFilter;
  5. use App\Service\HotelHelper;
  6. use App\Service\SubdomainHelper;
  7. use Doctrine\ORM\EntityManager;
  8. use Symfony\Component\HttpKernel\Event\RequestEvent;
  9. use Symfony\Component\Security\Core\Security;
  10. /**
  11.  * See https://github.com/doctrine-extensions/DoctrineExtensions/blob/v3.3.1/src/SoftDeleteable/SoftDeleteableListener.php
  12.  */
  13. class BeforeRequestListener
  14. {
  15.     private EntityManager $em;
  16.     private Security $security;
  17.     private HotelHelper $hotelHelper;
  18.     private SubdomainHelper $subdomainHelper;
  19.     private AclPermissionManager $aclPermissionManager;
  20.     public function __construct(EntityManager $emSecurity $securityHotelHelper $hotelHelperSubdomainHelper $subdomainHelperAclPermissionManager $aclPermissionManager)
  21.     {
  22.         $this->em $em;
  23.         $this->security $security;
  24.         $this->hotelHelper $hotelHelper;
  25.         $this->subdomainHelper $subdomainHelper;
  26.         $this->aclPermissionManager $aclPermissionManager;
  27.     }
  28.     public function onKernelRequest(RequestEvent $event): void
  29.     {
  30.         /**
  31.          * To disable the filter anytime use this:
  32.          * $this->get('doctrine')->getManager()->getFilters()->disable('softdeletable');
  33.          *
  34.          * To disable for one specific class use this:
  35.          * $this->get('doctrine')->getManager()->getFilters()->getFilter('softdeletable')->disableForEntity(ClassName::class);
  36.          * To enable it again use this:
  37.          * $this->get('doctrine')->getManager()->getFilters()->getFilter('softdeletable')->enableForEntity(ClassName::class);
  38.          */
  39.         $filters $this->em->getFilters();
  40.         $softDeletableFilter $filters->enable('softdeletable');
  41. //        /** @var HotelFilter $hotelFilter */
  42. //        $hotelFilter = $filters->enable('hotelfilter');
  43. //        $hotelFilter
  44. //            ->setSecurity($this->security)
  45. //            ->setHotelHelper($this->hotelHelper)
  46. //            ->setSubdomainHelper($this->subdomainHelper)
  47. //            ->setAclPermissionManager($this->aclPermissionManager)
  48. //            ->setRequest($event->getRequest())
  49. //        ;
  50.     }
  51. }