Register the hook in getHooks().
Open src/Plugin.php and add an entry to the array returned by getHooks():
public static function getHooks()
{
return [
self::$module.'.settings' => [__CLASS__, 'getSettings'],
self::$module.'.deactivate' => [__CLASS__, 'getDeactivate'],
self::$module.'.queue' => [__CLASS__, 'getQueue'],
self::$module.'.{eventSuffix}' => [__CLASS__, 'get{HandlerName}'],
];
}
Use the naming convention: event suffix activate → method getActivate, suspend → getSuspend.
Implement the handler method.
Add the static method immediately after the last handler in the class, before the closing }. Follow this exact skeleton:
For object subjects (service class with getId()/getCustid()):
public static function get{HandlerName}(GenericEvent $event)
{
if (in_array($event['type'], [get_service_define('OPENVZ'), get_service_define('SSD_OPENVZ')])) {
$serviceClass = $event->getSubject();
myadmin_log(self::$module, 'info', self::$name.' {Action Description}', __LINE__, __FILE__, self::$module, $serviceClass->getId(), true, false, $serviceClass->getCustid());
$event->stopPropagation();
}
}
For array subjects (queue-style, subject is $serviceInfo array):
public static function get{HandlerName}(GenericEvent $event)
{
if (in_array($event['type'], [get_service_define('OPENVZ'), get_service_define('SSD_OPENVZ')])) {
$serviceInfo = $event->getSubject();
$settings = get_module_settings(self::$module);
myadmin_log(self::$module, 'info', self::$name.' {Action Description}', __LINE__, __FILE__, self::$module, $serviceInfo[$settings['PREFIX'].'_id'], true, false, $serviceInfo[$settings['PREFIX'].'_custid']);
$event->stopPropagation();
}
}