src/Security/Voter/Resource/ProfileVoter.php line 9
<?php
namespace App\Security\Voter\Resource;
use Symfony\Component\Security\Core\Authorization\Voter\Voter,
Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use App\Entity\Admin;
final class ProfileVoter extends Voter
{
const ATTRIBUTE = 'PROFILE';
protected function supports($attribute, $subject): bool
{
if (! $subject instanceof Admin || $attribute !== self::ATTRIBUTE) {
return false;
}
return true;
}
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
{
/** @var Admin */
$admin = $token->getUser();
if ($admin->getUuid() === $subject->getUuid()) {
return true;
}
return false;
}
}