service method as twig global variable

前端 未结 4 480
有刺的猬
有刺的猬 2020-12-19 01:52

In my symfony2 application, I have a getPorfolioUser method which return a specific user variable.

I am looking forward to be able to call

{%

4条回答
  •  不知归路
    2020-12-19 02:29

    When you look here : http://symfony.com/doc/current/reference/twig_reference.html#app

    You can read this :

    The app variable is available everywhere and gives access to many commonly needed objects and values. It is an instance of GlobalVariables.

    GlobalVariables is Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables

    I never do it but I think one way is to overide this class in order to put your special needs in.

提交回复
热议问题