vendor/dachcom-digital/toolbox/src/ToolboxBundle/EventListener/PermissionListener.php line 26

Open in your IDE?
  1. <?php
  2. namespace ToolboxBundle\EventListener;
  3. use Symfony\Component\Console\ConsoleEvents;
  4. use Symfony\Component\Console\Event\ConsoleCommandEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. use ToolboxBundle\Manager\PermissionManagerInterface;
  7. class PermissionListener implements EventSubscriberInterface
  8. {
  9.     protected PermissionManagerInterface $permissionManager;
  10.     public function __construct(PermissionManagerInterface $permissionManager)
  11.     {
  12.         $this->permissionManager $permissionManager;
  13.     }
  14.     public static function getSubscribedEvents(): array
  15.     {
  16.         return [
  17.             ConsoleEvents::COMMAND => 'onConsoleCommand'
  18.         ];
  19.     }
  20.     public function onConsoleCommand(ConsoleCommandEvent $event): void
  21.     {
  22.         $command $event->getCommand();
  23.         if ($command === null) {
  24.             return;
  25.         }
  26.         if ($command->getName() !== 'cache:clear') {
  27.             return;
  28.         }
  29.         $this->permissionManager->synchroniseEditablePermissions();
  30.     }
  31. }