Is it possible to have the same route path but for 2 different actions. I want to use an action when the user is logged in and another when the user isn't logged in.
/**
* @Route("/", name="bundle_index")
* @Template("NameBundle:Default:index.html.twig")
*/
/**
* @Route("/", name="bundle_index_auth")
* @Security("has_role('ROLE_USER')")
* @Template("NameBundle:Default:auth.html.twig")
*/
使用相同的路径使用不同的名称,我认为不是,并且我无法想象在哪种情况下即使我们可以做到(也许如果您对要实现的目标有更好的解释),它也会很有用,但是看一下示例您可以做到您需要在同一操作中进行的所有检查...检查是否已将ROLE_USER授予用户(否则,将用户重定向或抛出与示例相同的访问异常)并相应地呈现正确的模板(与其他任何对象一起显然)需要的操作)。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.