2017-06-13 9 views
1
class HelloController 
{ 
    /** 
    * @Route("/", name="hello") 
    */ 
    public function indexAction($name) 
    { 
     return new Response($name); 
    } 
} 

変数routing 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 

これは、コントローラに別のサービスを渡す方法を私たちに示しているが、単純な変数を渡す方法?

答えて

0

この内部のrouting.yml試してみてください。

defaults: 
     _controller: AppBundle:Hello:index 
     name:  "WhatYouWantToPass" 
関連する問題