Mick
Mick

Reputation: 31959

Redirect using @Route annotations

Is there a way to redirect using annotations?

/**
 * Delete user
 *
 *
 * @Route("/deleteUser/{user_id}", name="delete_user_from_id")
 * @Template()
 */
public function deleteUserAction($user_id)
{
 //....
 return $this->redirect($this->generateUrl('acme_demo_homepage'));
}

Can we use annotations instead to avoid this extra line? Something like @redirect?

Upvotes: 2

Views: 2214

Answers (1)

guillaumepotier
guillaumepotier

Reputation: 7448

Nope, it is not possible.

Have a look into FrameworkExtraBundle. A redirect must be triggered in a controller (often after some logic ;) )

Upvotes: 1

Related Questions