2017-02-02 1 views
1

Ich habe ein Problem mit Symfony. Ich versuche, die Fabrik für den Controller zu verwenden, aber es funktioniert nicht.Symfony3.2 Cotrolller Fabrik

#services.yml  
services: 
      app.foo_controller_factory: 
      class: Foo\Controller\DefaultControllerFactory 
      arguments: 
       container: '@service_container' 
      app.foo_controller: 
      class: Foo\Controller\DefaultController 
      factory_class: '@app.foo_controller_factory' 
      factory_method: create_service 

#/routing.yml 
foo_bar: 
    path: /foo 
    defaults: { _controller: app.foo_controller:indexAction } 

Das Problem ist, weil Anwendung nie Trog DefaultControllerFactory geht.

Was könnte die Lösung sein?

+0

Wechseln Sie in den Entwicklungsmodus zu ändern. Die Fehlermeldungen geben Ihnen einen Hinweis. – Cerad

+2

Es ist eigentlich ein bisschen interessant. factory_class und factory method wurden in S3 entfernt, aber anstatt einen Fehler zu erzeugen, erstellt das Framework den Controller, ohne die Factory zu verwenden. In jedem Fall, ersetzen Sie die Factory mit Factory: ['@ app.foo_controller_factory', 'create_service'] http://symfony.com/doc/current/service_container/factories.html – Cerad

+0

Vielen Dank @Cerad !!! Ihr Vorschlag hat geholfen. – finder

Antwort

1

hatte ich services.yml

#services.yml 
services: 
    app.foo_controller_factory: 
    class: Foo\BarBundle\Controller\DefaultControllerFactory 
    arguments: 
     container: '@service_container' 
    app.foo_controller: 
    class: Foo\BarBundle\Controller\DefaultController 
    factory: 'app.foo_controller_factory:createService'