_trigger_normalize_comment_context
- Versions
- 6 – 7
_trigger_normalize_comment_context($type, $comment)
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.
Code
modules/trigger/trigger.module, line 264
<?php
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));
}
}
?>Login or register to post comments 