选民班在Symfony 4中

时间:2018-12-29 01:29:54

标签: symfony voting

我正在接管某人的代码,对投票一无所知。

这是PhotosController类:

class PhotosController extends Controller
{
    /**
     * @Route("/dashboard/photos/{id}/view", name="dashboard_photos_view")
     * @Security("is_granted('view.photo', photo)")
     * @param Photo $photo
     * @param PhotoRepository $photoRepository
     */
    public function index(Photo $photo, PhotoRepository $photoRepository)
    {
        $obj = $photoRepository->getFileObjectFromS3($photo);
        header("Content-Type: {$obj['ContentType']}");
        echo $obj['Body'];
        exit;
    }

这是选民阶层:

class PhotoVoter extends Voter
{
    const VIEW        = 'view.photo';
    protected function supports($attribute, $subject)
    {
        if (!$subject instanceof Photo) {
            return false;
        }
        if (!in_array($attribute, array(self::VIEW))) {
            return false;
        }
        return true;
    }

    protected function voteOnAttribute($attribute, $subject, TokenInterface    $token)
    {
        return $subject->getUser()->getId() === $token->getUser()->getId();
    }
}

我不明白

  

,照片

用于PhotosController类。在PhpStorm中,当我尝试转到“ is_granted”声明时,我得到“找不到声明”。

0 个答案:

没有答案