<?php
namespace App\Security\Authorization\Voter;
use App\Entity\Grid;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
class GridVoter extends AbstractVoter
{
public const READ = 'read';
public const WRITE = 'write';
/**
* @param string $attribute
* @param mixed $subject
*
* @return bool
*/
protected function supports($attribute, $subject): bool
{
if (!\in_array($attribute, [self::READ, self::WRITE], true)) {
return false;
}
if (!$subject instanceof Grid) {
return false;
}
return true;
}
/**
* @param string $attribute
* @param mixed $subject
* @param TokenInterface $token
*
* @return bool
*/
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
{
return $this->voteByDbname($attribute, $subject, $token);
}
}