<?php
namespace App\Daikin\BaseBundle\Security\Voter;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
class ModuleVoter extends Voter
{
protected ?array $modules;
public function __construct(?array $modules=[])
{
$this->modules = $modules;
}
protected function supports($attribute, $subject): bool
{
return $attribute === 'OWNMODULE';
}
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
{
return is_array($this->modules) && ($this->modules[$subject] ?? false) === true;
// return is_array($this->modules) && in_array($subject, $this->modules);
// dump($this->modules);
// dump([$attribute, $subject]);
// if ($this->container->hasParameter('modules_enabled')){
// return in_array($subject, $this->container->getParameter('modules_enabled'));
// }
// return false;
}
}