. */ namespace App\Security\Voter; use App\Entity\LabelSystem\LabelProfile; use App\Entity\UserSystem\User; class LabelProfileVoter extends ExtendedVoter { protected const MAPPING = [ 'read' => 'read_profiles', 'create' => 'create_profiles', 'edit' => 'edit_profiles', 'delete' => 'delete_profiles', 'show_history' => 'show_history', 'revert_element' => 'revert_element', ]; protected function voteOnUser($attribute, $subject, User $user): bool { return $this->resolver->inherit($user, 'labels', self::MAPPING[$attribute]) ?? false; } protected function supports($attribute, $subject) { if ($subject instanceof LabelProfile) { if (!isset(self::MAPPING[$attribute])) { return false; } return $this->resolver->isValidOperation('labels', self::MAPPING[$attribute]); } return false; } }