Accessing “dot” namespaced services in Twig view

2019-07-12 19:27发布

I know that I can access registered services by using the dot notation in a Twig template (example app.request.host). However, if I've created my own namespaced service (in this case tagframe.photoservice), when I try to access it, I am given an error that the method "tagframe" doesn't exist on the object "Silex\Application". Is it possible to access services that have been dot namespaced? In other words, a service that I would normally access using $app['tagframe.photoservice'] in the controller?

标签: php twig silex
1条回答
三岁会撩人
2楼-- · 2019-07-12 19:51

Yes, just like accessing array:

{{ app["tagframe.photoservice"].resizePhoto() }}
查看更多
登录 后发表回答