@Robert:

array(
    'controllers' => array(
        'factories' => array(
            'my_controller' => function (ServiceLocator $sl) {
                return new MyController($sl->get('a_dependency'),
$sl->get('another_dependency'));
            },
        ),
    ),
);

This works also with Zend\Di for development purposes, as I've blogged at
http://ocramius.github.com/blog/zend-framework-2-controllers-and-dependency-injection-with-zend-di/

Marco Pivetta

http://twitter.com/Ocramius

http://marco-pivetta.com



On 18 September 2012 11:40, Robert Basic <[email protected]> wrote:

> On 17 September 2012 17:14, Matthew Weier O'Phinney <[email protected]>
> wrote:
> >
> > I personally have been recommending the first way.
>
> Any example for getting controllers via factories? I've been through
> the docs, code, tests, examples, but fail to figure it out :( I can
> get anything else to work via factories, but not controllers. The only
> way I can get controllers is using the 'controllers' => array(
> 'invokables' => array( ... )) stuff, but that doesn't allow me to
> inject dependencies.
>
> --
> List: [email protected]
> Info: http://framework.zend.com/archives
> Unsubscribe: [email protected]
>
>
>

Reply via email to