I am new to Zend Framework 2. I have two modules 'A' and 'B'. I trigger an event in LoginController's LoginAction of "A" module. I want to attach LoginController's LoginAction or LoginController's testMe() method.
In "A" module's LoginController's LoginAction, I have written
$this->getEventManager()->trigger('checkme.post', null, array('user_id' => $userData->usydstudentid));
In Module.php of "B" module, in on Bootstrap method, I have given
$loginController = new BControllerLoginController();
$sharedEventManager->attach('AControllerLoginController', 'checkme.post', array($loginController, 'LoginAction'), 100);
In LoginController's LoginAction of "B" module, I can access data but I can not access service manager in order to get module' config. When I try to use
$this->getServiceLocator()->get('Config');
I get error
Call to a member function get() on a non-object
In other words, I want to trigger an event from one controller's method and attach to another controller's method. After listening, getting data from that event, I want to get module's config. Please help in this regard.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…