function _trigger_normalize_comment_context in Drupal 6
Same name and namespace in other branches
- 7 modules/trigger/trigger.module \_trigger_normalize_comment_context()
When an action is called in a context that does not match its type, the object that the action expects must be retrieved. For example, when an action that works on nodes is called during the comment hook, the node object is not available since the comment hook doesn't pass it. So here we load the object the action expects.
Parameters
$type: The type of action that is about to be called.
$comment: The comment that was passed via the comment hook.
Return value
The object expected by the action that is about to be called.
1 call to _trigger_normalize_comment_context()
- trigger_comment in modules/
trigger/ trigger.module - Implementation of hook_comment().
File
- modules/
trigger/ trigger.module, line 265 - Enables functions to be stored and executed at a later time when triggered by other modules or by one of Drupal's core API hooks.
Code
function _trigger_normalize_comment_context($type, $comment) {
switch ($type) {
// An action that works with nodes is being called in a comment context.
case 'node':
return node_load(is_array($comment) ? $comment['nid'] : $comment->nid);
// An action that works on users is being called in a comment context.
case 'user':
return user_load(array(
'uid' => is_array($comment) ? $comment['uid'] : $comment->uid,
));
}
}