Does DI setter injection work with a \Phalcon\Mvc\Collection

Using Phalcon 1.1.0 and trying to get the DI to work on a \Phalcon\Mvc\Collection

$di->set('myservice', function() {
    return $myservice = new myService();
});
$di->set('Data', array(
    'className' => 'Namespace\Model\Data',
    'calls' => array(
        array(
            'method' => 'setMyservice',
            'value' => array('type' => 'service', 'name' => 'myservice')
        ),
    )
));

But the corresponding method in the collection class never gets called. What am I doing wrong?



82.3k

Check this gist out, you have an error on how you're passing the parameters for setMyservice: https://gist.github.com/phalcon/5695689

http://docs.phalconphp.com/en/latest/reference/di.html#setter-injection