This is an experimental feature, so there could be unexpected issues when using this feature.
Event basics
In order to define a listener, assuming $this is the CodeIgniter content, simply call:$eventName
may be written as an array of segments or as a string with a .
separating each.
For example, these two $eventName
values are identical:
['location', 'view', 'output', 'main', 'index']
"location.view.output.main.index"
$eventCallback
, meanwhile, should accept a single $event
array parameter with data elements that will vary based on the event the listener is listening on.
Putting this all together, one could, for example, append “Hello World!” to the end of the main/index
view as follows:
Available events
location.view.data.VIEW
This event allows a listener to manipulate the data that is to be sent to a view. The event array made available to the callback listener includes a data array, passed by reference, which can be manipulated in order to modify, append or remove data before it is passed to the view to be rendered. Input Segments:$SECTION
- The view section, such as main or admin.$VIEW
- The view name, such as personnel_character or characters_bio.
data
- The data object that will be sent to the view.
location.view.output.VIEW
This event allows a listener to manipulate the output of a view once it has been rendered. The event array made available to the callback includes an output string, passed by reference, which can be manipulated in order to modify the output rendered by the view, or to even replace it all together. The event array also includes a data array of the data that was used to render the view. Input Segments:$SECTION
- The view section, such as main or admin.$VIEW
- The view name, such as personnel_character or characters_bio.
data
- The data object that was sent to the view to get the output.output
- The string that was produced after data was sent to the view.
template.render.data.ROUTERMETHOD
This event allows a listener to manipulate the data that is to be sent to a template. The event array made available to the callback listener includes a data array, passed by reference, which can be manipulated in order to modify, append or remove data before it is passed to the template to be rendered. Input Segments:$ROUTERCLASS
- The controller class as resolved by the router.$ROUTERMETHOD
- The controller method as resolved by the router.
data
- The data object that will be sent to the view.
template.render.output.ROUTERMETHOD
This event allows a listener to manipulate the output of a template once it has been rendered. The event array made available to the callback includes an output string, passed by reference, which can be manipulated in order to modify the output rendered by the template, or to even replace it all together. The event array also includes a data array of the data that was used to render the template. Input Segments:$ROUTERCLASS
- The controller class as resolved by the router.$ROUTERMETHOD
- The controller method as resolved by the router.
data
- The data object that was sent to the template to get the output.output
- The string that was produced after data was sent to the template.
db.insert.prepare.ROUTERCLASS.$ROUTERMETHOD
This event allows a listener to manipulate the data to be inserted into a database table before it is inserted. The event array made available to the callback listener includes a data array, passed by reference, which can be manipulated in order to modify, append or remove data before it is inserted into the table. The event array also includes a table string for cases where the listener is defined over the entirety of the db.insert.prepare namespace. Input Segments:$TABLE
- The name of the table into which the data will be written.$ROUTERCLASS
- The controller class as resolved by the router.$ROUTERMETHOD
- The controller method as resolved by the router.
data
- The data to be inserted into the table.table
- The name of the table.
db.update.prepare.ROUTERCLASS.$ROUTERMETHOD
This event allows a listener to manipulate the data to be updated for an existing record in a database table. The event array made available to the callback listener includes a data array, passed by reference, which can be manipulated in order to modify, append or remove data before it is update in the table. The event array also has where and limit entries, passed by reference, which can be manipulated to adjust the scope of the update. Finally, the event array also includes a table string for cases where the listener is defined over the entirety of the db.insert.prepare namespace. Input Segments:$TABLE
- The name of the table into which the data will be written.$ROUTERCLASS
- The controller class as resolved by the router.$ROUTERMETHOD
- The controller method as resolved by the router.
data
- The data to be inserted into the table.table
- The name of the table.where
- The where constraint defined in the update call.limit
- The limit constraint defined in the update call.
db.delete.prepare.ROUTERCLASS.$ROUTERMETHOD
This event allows a listener to manipulate the delete operation executed on a table. The event array made available to the callback listener includes an abort boolean where, if set true, will prevent the delete operation from being executed. Additionally, the event array also has where, limit and resetData entries, passed by reference, which can be manipulated to adjust the scope of the update. Finally, the event array also includes a table string for cases where the listener is defined over the entirety of the db.delete.prepare namespace. Input Segments:$TABLE
- The name of the table into which the data will be written.$ROUTERCLASS
- The controller class as resolved by the router.$ROUTERMETHOD
- The controller method as resolved by the router.
abort
- A boolean where, if set true, will prevent the delete operation from occuring.table
- The name of the table.where
- The where constraint defined in the delete call.limit
- The limit constraint defined in the delete call.resetData
- The reset_data parameter defined in the delete call.