src/Daikin/BaseBundle/Security/Voter/ModuleVoter.php line 8

Open in your IDE?
  1. <?php
  2. namespace App\Daikin\BaseBundle\Security\Voter;
  3. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  4. use Symfony\Component\Security\Core\Authorization\Voter\Voter;
  5. class ModuleVoter extends Voter
  6. {
  7.     protected ?array $modules;
  8.     public function __construct(?array $modules=[])
  9.     {
  10.         $this->modules $modules;
  11.     }
  12.     protected function supports($attribute$subject): bool
  13.     {
  14.         return $attribute === 'OWNMODULE';
  15.     }
  16.     protected function voteOnAttribute($attribute$subjectTokenInterface $token): bool
  17.     {
  18.         return is_array($this->modules) && ($this->modules[$subject] ?? false) === true;
  19. //        return is_array($this->modules) && in_array($subject, $this->modules);
  20.         //        dump($this->modules);
  21. //        dump([$attribute, $subject]);
  22. //        if ($this->container->hasParameter('modules_enabled')){
  23. //            return in_array($subject, $this->container->getParameter('modules_enabled'));
  24. //        }
  25. //        return false;
  26.     }
  27. }