bigandini
bigandini

Reputation: 136

ZF3: SharedEventManager injection in EventManager for ZfcUser

I'm trying to modify the form of zfcuser and found this explanation:

https://github.com/ZF-Commons/ZfcUser/wiki/How-to-modify-the-form-objects-used-by-ZfcUser

However it's not working like expected. After some debugging last night I found the one side which leads me to the attach method of the SharedEventManager:

https://github.com/zendframework/zend-eventmanager/blob/master/src/SharedEventManager.php#L61

And the other side which will execute the trigger out of the ZfcUser Login Form, which lead me to the EventManager:

https://github.com/zendframework/zend-eventmanager/blob/master/src/EventManager.php#L75

I modified the code with debugging like this:

error_log('check sharedEventManager');
if ($sharedEventManager) {
    error_log('sharedEventManager is there');
    $this->sharedManager = $sharedEventManager;
    $this->setIdentifiers($identifiers);
}

I also added debugging before and after the trigger out of ZfcUser\Form\Login: https://github.com/ZF-Commons/ZfcUser/blob/3.x/src/ZfcUser/Form/Login.php#L70

error_log('before zend login form trigger: '.get_class($this));
$this->getEventManager()->trigger('init', $this);
error_log('after zend login form trigger');

The docs say that the SharedEventManager gets injected into the EventManager (https://framework.zend.com/manual/2.4/en/modules/zend.event-manager.event-manager.html), but it looks like that's not heppening. It's only the 2.4 docs but the changelog says: EventManagerInterface::setSharedManager() is removed. Shared managers are now expected to be injected during instantiation. (https://github.com/zendframework/zend-eventmanager/blob/master/CHANGELOG.md)

So where does this SharedEventManager should be get injected? I see the getEventManager Method in https://github.com/ZF-Commons/ZfcUser/blob/3.x/src/ZfcUser/EventManager/EventProvider.php#L47. Which simple created a new EventManager with a new SharedEventManager.

From here I was not able to find where this was instanciated and where the SharedEventManager should be injected into ZfcUsers EventManager. Can you point out how to get the SharedEventManager active in ZfcUser?

Cheers Andi

Upvotes: 1

Views: 216

Answers (0)

Related Questions