1
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
這表明我們如何通過其他服務來控制,但如何通過一個簡單的變量?