How to get current bundle in Symfony 2?

后端 未结 4 1022
盖世英雄少女心
盖世英雄少女心 2021-02-03 11:09

How can I detect in which bundle am I?

for exemple, when I\'m in web.com/participants/list, I want to read \"participants\".

4条回答
  •  故里飘歌
    2021-02-03 12:04

    You can get the bundle name in the controller simply like that:

    // Display "SybioCoreBundle"
    echo $this->getRequest()->attributes->get('_template')->get('bundle');
    

    And inside a Twig template:

    {{ app.request.get('_template').get('bundle') }}
    

提交回复
热议问题