. */ declare(strict_types=1); namespace App\Security\Voter; use App\Entity\Parts\Part; use App\Entity\UserSystem\User; /** * A Voter that votes on Part entities. * * See parts permissions for valid operations. */ class PartVoter extends ExtendedVoter { final public const READ = 'read'; protected function supports($attribute, $subject): bool { if (is_a($subject, Part::class, true)) { return $this->resolver->isValidOperation('parts', $attribute); } //Allow class name as subject return false; } protected function voteOnUser(string $attribute, $subject, User $user): bool { //Null concealing operator means, that no return $this->resolver->inherit($user, 'parts', $attribute) ?? false; } }