function notifications_digest_event_info in Notifications 6.4
Get digest information for an event.
From the event definition (notifications('event types')) we find out
- which event object we'll use for digesting
- which field of that object to use for indexing
I.e. for event type = 'node', event action = 'update' 'digest' => ('node', 'nid')
The result will be an array with the following properties
- type, Event's object type we use for digesting
- field, Event's object field we use for digesting
- value, Object's field value if set, defaults to 0
- object, The object we have used for digesting
2 calls to notifications_digest_event_info()
- NotificationsTemplatesTests::testNotificationsTemplates in tests/
notifications_templates.test - Play with creating, retrieving, deleting a pair subscriptions
- notifications_digest_build_short in notifications_digest/
notifications_digest.module - Digest multiple events in a single message, short format.
File
- notifications_digest/
notifications_digest.module, line 99 - Notifications digest module
Code
function notifications_digest_event_info($event, $module = 'notifications') {
// The event may already have digest information
if (isset($event->digest)) {
return $event->digest;
}
elseif ($digest = $event
->get_type('digest')) {
// Cool, the event type has digesting information
$type = $digest[0];
$field = $digest[1];
// Check object and values, the object may be the event itself
if ($type == 'event') {
$object = $event;
}
else {
$object = $event
->get_object($type);
}
}
else {
// No digest info for this event /action so we use event and action
$type = $event->type;
$field = $event->action;
$object = NULL;
}
$value = $object && $field && isset($object->{$field}) ? $object->{$field} : 0;
return $event->digest = array(
'type' => $type,
'field' => $field,
'value' => $value,
'object' => $object,
'module' => $module,
);
}