You are viewing an old version of this page. View the current version.
Compare with Current
View Page History
« Previous
Version 25
Next »
Creating an event handler in Blesta consists of merely filling in a stubbed callback method, or returning an array of callbacks from a plugin's getEvents() method. Blesta offers a number of events that are automatically triggered when needed. The default handlers for these events may be found in the /installdir/components/events/default/ directory. You can paste your event handler code directly into any of the default handler methods, or more preferably, create a plugin to handle the event.
Events
Event | Triggered When | Default Event Handler | Parameters | Returns | Since |
---|
Appcontroller.preAction | A URI is requested | EventsAppControllerCallback::preAction() | void | void | 3.0 |
Appcontroller.structure | A URI is requested without AJAX | EventsAppControllerCallback::structure() | - controller - The controller being requested
- action - The action being requested
- portal - The portal in use ('admin' or 'client')
| array Key/value pairs to be set as variables in the structure view. Special keys include: - head - An array of markup to set in the <head> tag
- body_start - An array of markup to set just after the <body> tag
- body_end - An array of markup to set just before the </body> tag
| 3.3 |
Clients.create | A client is created | EventsClientsCallback::create() | - client - An object representing the client that was created.
| void | 3.1 |
Emails.send | An email template is sent | EventsEmailsCallback::send() | - action - The action that specifies the email group being sent
- options - An array of options passed to Emails::send(), which may include:
- to_client_id - The ID of the client the message was sent to
- from_staff_id - The ID of the staff member the message was sent from
- from - The from address override
- from_name - The from name override
- reply_to - The reply to address override
- tags - A key/value pair of replacement tags for the email.
| array Key/value pairs to merge with tags. | 3.1 |
Emails.sendCustom | A non-template based email is sent | EventsEmailsCallback::sendCustom() | - options - An array of options passed to Emails::send(), which may include:
- to_client_id - The ID of the client the message was sent to
- from_staff_id - The ID of the staff member the message was sent from
- reply_to - The reply to address override
- tags - A key/value pair of replacement tags for the email.
| array Key/value pairs to merge with tags. | 3.1 |
Invoices.add | An invoice is created | EventsInvoicesCallback::add() | - invoice_id - The ID of the invoice created
| void | 3.1 |
Invoices.edit | An invoice is updated | EventsInvoicesCallback::edit() | - invoice_id - The ID of the invoice updated
| void | 3.1 |
Invoices.setClosed | An invoice is closed | EventsInvoicesCallback::setClosed() | - invoice_id - The ID of the invoice closed
| void | 3.1 |
Services.add | A service is added | EventsServicesCallback::add() | - service_id - The ID of the service added
- vars - An array of input data which may include:
- parent_service_id - The ID of the service this service is a child of
- package_group_id - The ID of the package group this service was added from
- pricing_id - The package pricing schedule ID for this service
- client_id - The ID of the client this service belongs to
- module_row - The module row to add the service under
- coupon_id - The ID of the coupon used for this service
- qty - The quanity consumed by this service
- override_price - The price to set for this service, overriding the package pricing value for the selected term
- override_currency - The currency to set for this service, overriding the package pricing value for the selected term
- status - The status of this service
- date_added - The date this service is added
- date_renews - The date the service renews
- date_last_renewed - The date the service last renewed
- date_suspended - The date the service was last suspended
- date_canceled - The date the service was last canceled
- use_module - Whether or not to use the module for this request
- prorate - Whether or not to prorate price changes
- configoptions - An array of key/value pairs of package options where the key is the package option ID and the value is the option value
- (any other service field data passed to the module)
| void | 3.4 |
Services.edit | A service is edited | EventsServicesCallback::edit() | - service_id - The ID of the service edited
- vars - An array of input data which may include:
- parent_service_id - The ID of the service this service is a child of
- package_group_id - The ID of the package group this service was added from
- pricing_id - The package pricing schedule ID for this service
- client_id - The ID of the client this service belongs to
- module_row - The module row to add the service under
- coupon_id - The ID of the coupon used for this service
- qty - The quanity consumed by this service
- override_price - The price to set for this service, overriding the package pricing value for the selected term
- override_currency - The currency to set for this service, overriding the package pricing value for the selected term
- status - The status of this service
- date_added - The date this service is added
- date_renews - The date the service renews
- date_last_renewed - The date the service last renewed
- date_suspended - The date the service was last suspended
- date_canceled - The date the service was last canceled
- use_module - Whether or not to use the module for this request
- prorate - Whether or not to prorate price changes
- configoptions - An array of key/value pairs of package options where the key is the package option ID and the value is the option value
- (any other service field data passed to the module)
| void | 3.4 |
Services.cancel | A service is scheduled to be canceled, or is canceled | EventsServicesCallback::cancel() | - service_id - The ID of the service canceled
- vars - An array of input data which may include:
- date_canceled - The date this service is scheduled to be canceled
- status - The status of the service (i.e. 'canceled')
- use_module - Whether or not to use the module for this request
| void | 3.5 |
Transactions.add | A transaction is created | EventsTransactionsCallback::add() | - transaction_id - The ID of the transaction created
| void | 3.1 |
Transactions.edit | A transaction is updated | EventsTransactionsCallback::edit() | - transaction_id - The ID of the transaction updated
| void | 3.1 |
Users.login | A user logs in | EventsUsersCallback::login() | - user_id - The ID of the user that successfully logged in
| void | 3.1 |
Users.logout | A user logs out | EventsUsersCallback::logout() | - user_id - The ID of the user attempting to log out
| void | 3.1 |
Navigation.getSearchOptions | Staff search options are displayed | EventsNavigationCallback::getSearchOptions() | - options - A key/value pair of search options where each key is the URI to redirect search queries to and the value is the name of the search option. When implemented, the event handler should modify the options parameter using EventObject::setParams().
- base_uri - The base URI for the currently logged in user.
| void | 3.0 |
Working with Events
Each event handler that is invoked when the event is triggered is passed an EventObject. You can modify the parameters or return value of this object and the modified event will be passed along to each subsequent handler, and finally returned to the trigger.
To fetch parameters from the EventObject invoke the getParams() method. Similarly, to set parameters use the setParams() method.
To set the return value from the EventObject invoke the setReturnVal() method. Similarly, to fetch the return value use the getReturnVal() method.
The ID of the coupon used for this service