[development] About hook_action_info()
icerain
doubaokun at gmail.com
Wed Jul 14 00:37:21 UTC 2010
I add the action to work flow changes. From (creation) to submitted (I
created this status). The action effect on a node. And i got the empty
object.
On Tue, Jul 13, 2010 at 9:46 PM, Vandyk, John K [ENT]
<jvandyk at iastate.edu>wrote:
> That does not look like an implementation of hook_action_info(). For an
> example implementation, see
>
> http://api.drupal.org/api/function/hook_action_info/6
>
> It looks like you are actually writing an action. In that case, the first
> parameter is populated by the native object that the action is working on.
> For example, if you are triggering an unpublish action when a node is
> edited, the object that you are working on is a node, and the trigger system
> will send the node object along to the action call as the first parameter.
>
The problem is that the first parameter is empty.
>
> However, if you want to do something crazy like unpublish a node when a
> comment is submitted, you are acting on a comment object, not a node object.
>
My object is a node.
> If you run an unpublish node action in that case, the trigger system will
> expend a little effort trying to make sure that the unpublish-a-node action
> (which works on nodes) gets a node. See
>
> http://api.drupal.org/api/function/trigger_comment/6
> http://api.drupal.org/api/function/_trigger_normalize_comment_context/6
>
> Since some actions can be called in multiple contexts, you will see them
> doing gyrations like this:
>
> http://api.drupal.org/api/function/system_message_action/6
>
> The short answer is, ask yourself whether your action will ever be used in
> a weird context, and if you might have to pluck the $node from the $context
> or do a node_load() from some information in the context that could lead you
> to the node.
>
> On Jul 13, 2010, at 12:52 AM, icerain wrote:
>
> > When i implement hook_action_info(), i found the first para *$node* is
> empty.
> > My question is
> > function mymodule_myaction_action(&$node, $context = array()) {
> > $node = $context['node']; // should this line be added?
> > ...
> > }
> > Or something else error?
> > --
> > A decathlon Drupal developer & programmer
> > http://blog.eood.cn/
>
>
--
A decathlon Drupal developer & programmer
http://blog.eood.cn/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20100714/c0a3c6a7/attachment.html
More information about the development
mailing list