Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Security] Document "pass controller object argument by name" behavior for IsGranted attribute #19589

Open
Labels
@PrOF-kk

Description

@PrOF-kk

This code fragment correctly passes aTask object to the TaskVoter "by name":

// TaskController.php#[Route('/{task}', name:'task_details', methods: ['GET'])]/*                                   ↓↓↓↓                       */#[IsGranted(TaskVoter::ACCESS_TASK,'task','No task found',404)]publicfunctiontaskDetails(Task$task):Response{// ...}// TaskVoter.phpprotectedfunctionvoteOnAttribute(string$attribute,$subject,TokenInterface$token):bool{if (TaskVoter::ACCESS_TASK ===$attribute &&$subjectinstanceof Task) {return$this->canAccessTask($subject,$token->getUser());    }}

This is pretty handy, although I cannot find documentation about it anywhere. I'd expect it in(Security->Add Code to Deny Access) Securing Controllers and Other Code.
It is used throughoutVoters->Setup: Checking for Access in a Controller.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp