A component that needs to get notifications of Plesk events should register its implementation of the EventListener interface. Read the Registering Implementation of Interface section for implementation details.
To add a handler, say my_events_extension.php, it should be put to the <plesk_root_dir>/admin/plib/registry/EventListener directory (< stands for the full path to the directory where Plesk is installed).plesk_root_dir>
The source of my_events_extension.php can look as follows:
<?php
global $ClientsCount;
class MyEvent extends EventListener {
function handleEvent($object_type, $object_id, $action, $old_values, $new_values)
{
if ($object_type=='client')
{
$ClientsCount+=1;
}
}
}
$MyEventInstance= new MyEvent;
return $MyEventInstance;
?>
The handleEvent method of the MyHandlerInstance is called by the core once per business logic event. The sample code counts events made by Plesk clients. You can write your own code of function handleEvent that interacts with internal or external applications.
For detailed info on types of objects and events managed by the handlers, refer to the Event Handlers section of the Plesk Modules API Reference.