WiseLoop PHP REST Services 3.3.1
RESTful web service API framework for PHP
|const||ON_REQUEST_EVENT = 1|
|const||ON_DATA_EVENT = 2|
|const||ON_RENDER_EVENT = 3|
|const||ON_ERROR_EVENT = 4|
|$_restService = null|
|$_event = null|
WiseLoop RestTrigger class definition
This class provides means to execute some user actions when specific events happens.
To build a trigger the developer must extend wlRestTrigger class and overwrite the wlRestTrigger::run method.
To hook it up to a REST service, the trigger must be registered along with an event using wlRestService::registerTrigger method.
Returns the event identifier to which the current trigger is hooked.
Returns the REST service that has registered the current trigger.
Sets the event identifier to which the current trigger is hooked.
Sets the REST service that has registered the current trigger.
|$_event = null
Type: int the event identifier to which the current trigger is hooked
|$_restService = null
Type: wlRestService the REST service that has registered the current trigger
|const ON_DATA_EVENT = 2|
ON_DATA_EVENT: occurs after the raw data is computed and retrieved, just before rendering and sendig it to the requester.
This event can be used to hook triggers that can do additional general processing of data before sending. A good example is the wlRestTriggerAddTimestamp trigger that simply adds a time stamp information to the data.
|const ON_ERROR_EVENT = 4|
ON_ERROR_EVENT: occurs when an exception is raised.
This event is used to hook triggers that formats the error message before sending it to the requester. Of course, the trigger can be used to mute any errors raised during the service call but this practice is not recommended. A good example (and it is highly recommended to be used) is wlRestTriggerError trigger that formats nicely the error message along with the error code and displays also the stack trace.
|const ON_RENDER_EVENT = 3|
ON_RENDER_EVENT: occurs after data is rendered with the corresponding output handler.
This event can be used to hook triggers that can do additional general formatting of data before sending. This event is quite seldom used as the main rendering of data is and should be done by the output handler.
|const ON_REQUEST_EVENT = 1|
ON_REQUEST_EVENT: occurs just before calling the service method, when the request is parsed.
This event can be used to hook triggers that can do various authentication procedures like session authentication or to implement an API service key validation.