Security/PermisoVoter.php
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
    {
        if(is_null($subject)){
            return true;
        }

        switch($attribute){
            case self::MENU:
                /** @var Menu $subject */
                if(isset($this->permisos[$attribute][Permiso::LIBRE]) && in_array($subject->getSlug(), $this->permisos[$attribute][Permiso::LIBRE])){
                    return true;
                }
                if(!isset($this->permisos[$attribute][Permiso::RESTRICT])){
                    return false;
                }
                return in_array($subject->getSlug(), $this->permisos[$attribute][Permiso::RESTRICT]);
            case self::PERMISO:
                if(!isset($this->permisos[$attribute])){
                    return false;
                }
                return in_array($subject, $this->permisos[$attribute]);
        }

        $user = $token->getUser();
        if (!is_object($user)) {
            // the user must be logged in; if not, deny access
            return false;
        }

        if(is_null($this->perfil_id)){
            return false;
        }

        throw new \LogicException('El código no es reconocido!');
    }
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
    {
        if(is_null($subject)){
            return true;
        }

        switch($attribute){
            case self::MENU:
                /** @var Menu $subject */
                if(isset($this->permisos[$attribute][Permiso::LIBRE]) && in_array($subject->getSlug(), $this->permisos[$attribute][Permiso::LIBRE])){
                    return true;
                }
                if(!isset($this->permisos[$attribute][Permiso::RESTRICT])){
                    return false;
                }
                return in_array($subject->getSlug(), $this->permisos[$attribute][Permiso::RESTRICT]);
            case self::PERMISO:
                if(!isset($this->permisos[$attribute])){
                    return false;
                }
                return in_array($subject, $this->permisos[$attribute]);
        }

        $user = $token->getUser();
        if (!is_object($user)) {
            // the user must be logged in; if not, deny access
            return false;
        }

        if(is_null($this->perfil_id)){
            return false;
        }

        throw new \LogicException('El código no es reconocido!');
    }
Perform a single access check operation on a given attribute, subject and token.

@param string $attribute
@param mixed $subject
@param TokenInterface $token

@return bool