Events in Snapin Plugins.

Exp0logy

New Member
Hi,

Does anyone have the snapin example? does it have examples for listening for events? what modules are required?
Trying to get a Xero plugin written.

Thanks!
 

Exp0logy

New Member
For anyone looking. There's currently event listeners in the clicksend plugin in /plugins/snapin/clicksend :)
 

hadi

Active Member
This is an example for one of events I have used in my own Snapin plugin for sending sms



class PluginSendsms extends SnapinPlugin
{
public $listeners = array(
array("Invoice-Create", "invoiceCreateCallback"),
array("Client-Update", "clientUpdateCallback"),
array("UserPackage-Activate", "userpackageActivateCallback"),
array("Account-Login", "useraccountloginCallback"),
array("Ticket-ReplyByAdmin", "ticketreplybyadminCallback"),
array("Order-NewPackage", "ordernewpackageCallback"),
array("Invoice-Paid", "invoicepaidCallback"),
array("System-ActionCalled", "systemcallback"),
array("Service-AutoSuspend-Suspend", "ServiceAutoSuspendSuspendCallback"),
array("Package-Update", "packageUpdateCallback")


);

/*
/*
/*




public function userpackageActivateCallback($e)
{

if (is_array($e)) {
$event = $e;
} else {
$event = $e->getParams();
}
CE_Lib::log(4, $event);

$package_id = $event['userPackageId'];
$userPackage = new UserPackage($package_id);
$userId = $userPackage->getCustomerId();

..............

}
 

Exp0logy

New Member
This is an example for one of events I have used in my own Snapin plugin for sending sms



class PluginSendsms extends SnapinPlugin
{
public $listeners = array(
array("Invoice-Create", "invoiceCreateCallback"),
array("Client-Update", "clientUpdateCallback"),
array("UserPackage-Activate", "userpackageActivateCallback"),
array("Account-Login", "useraccountloginCallback"),
array("Ticket-ReplyByAdmin", "ticketreplybyadminCallback"),
array("Order-NewPackage", "ordernewpackageCallback"),
array("Invoice-Paid", "invoicepaidCallback"),
array("System-ActionCalled", "systemcallback"),
array("Service-AutoSuspend-Suspend", "ServiceAutoSuspendSuspendCallback"),
array("Package-Update", "packageUpdateCallback")


);

/*
/*
/*




public function userpackageActivateCallback($e)
{

if (is_array($e)) {
$event = $e;
} else {
$event = $e->getParams();
}
CE_Lib::log(4, $event);

$package_id = $event['userPackageId'];
$userPackage = new UserPackage($package_id);
$userId = $userPackage->getCustomerId();

..............

}
Thanks, Going to use this example to complete my Xero plugin.
 
Top