. */ namespace App\Security\Voter; use App\Entity\Parts\PartLot; use App\Entity\UserSystem\User; class PartLotVoter extends ExtendedVoter { /** @var string[] When this permsission are encountered, they are checked on part */ protected const PART_PERMS = ['show_history', 'revert_element']; protected function voteOnUser($attribute, $subject, User $user): bool { if (in_array($attribute, self::PART_PERMS, true)) { return $this->resolver->inherit($user, 'parts', $attribute) ?? false; } return $this->resolver->inherit($user, 'parts_lots', $attribute) ?? false; } protected function supports($attribute, $subject) { if (is_a($subject, PartLot::class, true)) { return in_array($attribute, array_merge( self::PART_PERMS, $this->resolver->listOperationsForPermission('parts_lots') ), true); } return false; } }