class HelloController
{
/**
* @Route("/", name="hello")
*/
public function indexAction($name)
{
return new Response($name);
}
}
我想在不使用路由的情况下将变量 $name 传递给 indexAction。
在文档中我发现:
services:
# ...
# explicitly configure the service
AppBundle\Controller\HelloController:
public: true
tags:
# add multiple tags to control
- name: controller.service_arguments
action: indexAction
argument: logger
# pass this specific service id
id: monolog.logger.doctrine
这向我们展示了如何将另一个服务传递给控制器,但是如何传递一个简单的变量呢?