We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Applying injection order

Hello! I use phalcon 1.3 for few days. I have such code:

    $di->setShared($componentName, array(
        'className' => $class,
        'properties' => $properties,
        'calls' => array(
            array(
                'method' => 'init',
                'arguments' => array()
            )
        ),
    ));

When method init() is invoked on some object calls, the object has no set properties yet. Can I change this behavior? I need set properties before calling init().



43.9k
edited Mar '14

Hi, maybe you can use the onConstruct() method, that one is available for controllers, I don't know for user components. Otherwise I'm thinking of https://docs.phalcon.io/en/latest/reference/applications.html#application-events and eventsmanager