src/PHPDish/Bundle/ResourceBundle/Security/EntityVoter.php
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
    {
        $user = $token->getUser();
        $this->hasAuthenticatedUser = $user instanceof UserInterface;
        //没有登录的用户不允许
        if (!$this->hasAuthenticatedUser) {
            return false;
        }
        if ($this->accessDecisionManager->decide($token, ['ROLE_ADMIN'])) {
            return true;
        }
        $result = false;
        switch ($attribute) {
            case static::ACTION_VIEW:
                $result = $this->canView($subject, $user);
                break;
            case static::ACTION_EDIT:
                $result = $this->canEdit($subject, $user);
                break;
        }
        return $result;
    }
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
    {
        $user = $token->getUser();
        $this->hasAuthenticatedUser = $user instanceof UserInterface;
        //没有登录的用户不允许
        if (!$this->hasAuthenticatedUser) {
            return false;
        }
        if ($this->accessDecisionManager->decide($token, ['ROLE_ADMIN'])) {
            return true;
        }
        $result = false;
        switch ($attribute) {
            case static::ACTION_VIEW:
                $result = $this->canView($subject, $user);
                break;
            case static::ACTION_EDIT:
                $result = $this->canEdit($subject, $user);
                break;
        }
        return $result;
    }
{@inheritdoc}