Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Adding event handlers to extension modules
#1
I was reading the vtlib docs and came accross this code:

Code:
<?xml version="1.0" encoding=”utf-8”?>
<module>
<type>extension</type>
<name>MODULENAME</name>
<label>MODULE LABEL</label>
<parent>Tools</parent>
<version>1.0</version>
<dependencies>
<vtiger_version>5.1.0</vtiger_version>
</dependencies>
<tables>
<table>
<name>TABLE-NAME</name>
<sql><![CDATA[CREATE_TABLE_SQL]]></sql>
</table>
</tables>
<events>
<event>
<eventname>EVENT_NAME</eventname>
<classname>EVENT_HANDLER_CLASS</classname>
<filename>EVENT_HANDLER_CLASS_FILE</filename>
<condition><![CDATA[modulename in ['MODULENAME']]]></condition>
</event>
</events>
</module>

Where I see you can add event handlers in the manifest file of an extension module. But we could just as easily do it in the vtlib_handler class method of the main file right? So in modules/MyModuleName/MyModuleName.php I would create:

PHP Code:
    function vtlib_handler($modulename$event_type) {
        if(
$event_type == 'module.postinstall') {
            
// TODO Handle post installation actions
        
} else if($event_type == 'module.disabled') {
            
// TODO Handle actions when this module is disabled.
        
} else if($event_type == 'module.enabled') {
            
// TODO Handle actions when this module is enabled.
        
} else if($event_type == 'module.preuninstall') {
            
// TODO Handle actions when this module is about to be deleted.
        
} else if($event_type == 'module.preupdate') {
            
// TODO Handle actions before this module is updated.
        
} else if($event_type == 'module.postupdate') {
            
// TODO Handle actions after this module is updated.
        
}
    } 

Where I would do the event handler creation in the postinstall?
Reply


Messages In This Thread
Adding event handlers to extension modules - Guido1982 - 12-13-2016, 10:19 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)