after_retrieve
Overview
The after_retrieve
hook executes after a record has been retrieved from the database.
Definition
function after_retrieve($bean, $event, $arguments){}
Arguments
Name | Type | Description |
bean | Object | The bean object |
event | String | The current event |
arguments | Array | Additional information related to the event |
arguments.id | String | ID of the record |
arguments.encode | Boolean | Whether or not to encode |
Considerations
- The
after_retrieve
hook does not fire when a new record is being created. - Calling save on the bean in this hook can cause adverse side effects if not handled correctly and should be avoided. (i.e.
$bean->save()
)
Examples
Creating a Logic Hook using the Extension Framework
./custom/Extension/modules/<module>/Ext/LogicHooks/<file>.php
<?php
$hook_array['after_retrieve'][] = Array(
//Processing index. For sorting the array.
1,
//Label. A string value to identify the hook.
'after_retrieve example',
//The PHP file where your class is located.
'custom/modules/<module>/after_retrieve_class.php',
//The class the method is in.
'after_retrieve_class',
//The method to call.
'after_retrieve_method'
);
?>
./custom/modules/{module}/{module}_hook.php
<?php
class after_retrieve_class
{
function after_retrieve_method($bean, $event, $arguments)
{
//logic
}
}
?>