Hello everyone,
since two days I have worked and tested the events. The general usage is more or less clear. But now I have a MVC application implemented with the ModuleDefinitionInterface. I decided to use an extended version of this interface and named it ModuleDefinitionAbstract. This works like:
abstract class ModuleDefinitionAbstract implements Phalcon\Mvc\ModuleDefinitionInterface{
...
}
This class uses standard behaviors like standard registering of auto loaders for the module. I implemented in my modules like:
class Init extends Namespace\ModuleDefinitionAbstract{}
Now I would like to use events for the ModuleDefinitionAbstract. But I don't find any idea to do this. Because I would like to have function like module-based configuration loading etc. as standard event. Currently standardly the registerAutoloaders and the registerServices gets called.
I tried already this:
Listener:
class Listener {
protected function _initialize(){
}
protected function _initConfiguration(){
}
protected function _initModuleConfiguration(){
}
protected function _initCustomerConfiguration(){
}
}
and added it to the standard events manager in my bootstrap:
$eventManager = new Phalcon\Events\Manager();
$eventManager->attach('moduleDefinitionAbstract', new Namespace\ModuleDefinitionAbstract\Listener());
$this->getDI()->set('eventsManager', $eventManager);
In the above abstract class I used it like:
abstract class ModuleDefinitionAbstract implements Phalcon\Mvc\ModuleDefinitionInterface{
....
protected function _initConfiguration(){
echo "init conf";
}
}