<?php
namespace App\EventListener;
use App\AclPermission\AclPermissionManager;
use App\Doctrine\HotelFilter;
use App\Service\HotelHelper;
use App\Service\SubdomainHelper;
use Doctrine\ORM\EntityManager;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\Security\Core\Security;
/**
* See https://github.com/doctrine-extensions/DoctrineExtensions/blob/v3.3.1/src/SoftDeleteable/SoftDeleteableListener.php
*/
class BeforeRequestListener
{
private EntityManager $em;
private Security $security;
private HotelHelper $hotelHelper;
private SubdomainHelper $subdomainHelper;
private AclPermissionManager $aclPermissionManager;
public function __construct(EntityManager $em, Security $security, HotelHelper $hotelHelper, SubdomainHelper $subdomainHelper, AclPermissionManager $aclPermissionManager)
{
$this->em = $em;
$this->security = $security;
$this->hotelHelper = $hotelHelper;
$this->subdomainHelper = $subdomainHelper;
$this->aclPermissionManager = $aclPermissionManager;
}
public function onKernelRequest(RequestEvent $event): void
{
/**
* To disable the filter anytime use this:
* $this->get('doctrine')->getManager()->getFilters()->disable('softdeletable');
*
* To disable for one specific class use this:
* $this->get('doctrine')->getManager()->getFilters()->getFilter('softdeletable')->disableForEntity(ClassName::class);
* To enable it again use this:
* $this->get('doctrine')->getManager()->getFilters()->getFilter('softdeletable')->enableForEntity(ClassName::class);
*/
$filters = $this->em->getFilters();
$softDeletableFilter = $filters->enable('softdeletable');
// /** @var HotelFilter $hotelFilter */
// $hotelFilter = $filters->enable('hotelfilter');
// $hotelFilter
// ->setSecurity($this->security)
// ->setHotelHelper($this->hotelHelper)
// ->setSubdomainHelper($this->subdomainHelper)
// ->setAclPermissionManager($this->aclPermissionManager)
// ->setRequest($event->getRequest())
// ;
}
}