Dru Documentation

Go to front page

/hooks/core.php, string 65 Versions 6 hook_action_info () "Translation" the Pre-image Informs triggers Drupala on new operations. Any unit of Drupala can define any amount of operations (action). Trigger unit is an example the unit which uses these operations. Operation consists of two or three parts: 1. Operation expositions (returned these хуком); 2. Functions which fulfils operation (under the agreement this function name имя_модуля + ' _ ' + описание_действия + ' _action '); 3. Optional exposition of the form of customisations for this operation (the form of customisations function with a name полное_имя_действия + ' _form ' describes). 2 parametres are transmitted function which fulfils operation by call: the object of the same type, as well as value of a unit ' type ' from the array hook_action_info, and the array-context describing, purely, a context in which operation at present is started. For example, trigger unit instal in this array of value with keys ' hook ' and ' op ' (that is for the operation called at handling of event ' insert ' in хуке ' nodeapi ' a context can look as array (' hook ' => ' nodeapi ', ' op ' => ' insert ')). Returned value * the Associative array of expositions of all operations realised in the unit. Keys of this array - names of the functions realising operation, values - expositions of operations. The operation exposition in turn is the associative array with such steams a key-value: o ' type ': (without fail) defines, what type of objects will be transmitted operation. Admissible values: ' node ', ' user ', ' comment ' and ' system ' or any user's type. For example, for nodequeue unit realising sequence нод, the type can be installed equal ' nodequeue ' if operation has to work with sequences нод. o ' description ': the Exposition of operation for users is mandatory). o ' configurable ': (Without fail Boolean value. If it is equal FALSE, additional customisation is not required to operation. If TRUE - customisation is required, in this case it is necessary to define the designer of the form of customisation. The designer of the form of customisation is a function with a name consisting of a name of operation and a suffix ' _form ' (i.e., for operation ' node_assign_owner_action ' it will be ' node_assign_owner_action_form '). The parametre $context is transmitted function; if necessary it is possible to add the form with standard functions _submit and _validate. o ' hooks': (without fail) Array of all operations to whom it is applicable given дейстиве. Keys of the array are names хуков. Trigger unit uses this parametre to filter not resembling operations in the management interface. Defining in the unit the operation supporting all possible хуки, it is possible to instal ' hooks' => array (' any ' => TRUE). Are often used хуки ' user ', ' nodeapi ', ' comment ' and ' taxonomy '. It is possible to use a name of any хука, defined by means of function hook_hook_info (). o ' behaviour ': (optionally) Array describing "behaviour" of operation. The kernel of Drupala supports only one behaviour - ' changes_node_property '. If for operation such behaviour is specified, it means that operation changes properties ноды; in this case on the operation termination нода it will be automatically saved. Declare information about one or more Drupal actions. Any module can define any number of Drupal actions. The trigger module is an example of a module that uses actions. An action consists of two or three parts: (1) an action definition (returned by this hook), (2) a function which does the action (which by convention is named module + ' _ ' + description of what the function does + ' _action '), and an optional form definition function that defines a configuration form (which has the name of the action with ' _form ' appended to it.) The function that is called when the action is triggered is passed two parametres - an object of the same type as the ' type ' value of the hook_action_info array, and a context variable that contains the context under which the action is currently running, sent as an array. For example, the actions module sets the ' hook ' and ' op ' keys of the context array (so, ' hook ' may be ' nodeapi ' and ' op ' may be ' insert '). Return value * An array of action descriptions. Each action description is an associative array, where the key of the item is the action's function, and the following key-value pairs: o ' type ': (required) the type is determined by what object the action acts on. Possible choices are node, user, comment, and system. Or whatever your own custom type is. So, for the nodequeue module, the type might be set to ' nodequeue ' if the action would be performed on a nodequeue. o ' description ': (required) The human-readable name of the action. o ' configurable ': (required) If FALSE, then the action does not require any extra configuration. If TRUE, then you should define a form function with the same name as the key, but with ' _form ' appended to it (i.e., the form for ' node_assign_owner_action ' is ' node_assign_owner_action_form '.) This function will take the $context as the only parametre, and is paired with the usual _submit function, and possibly a _validate function. o ' hooks': (required) An array of all of the operations this action is appropriate for, keyed by hook name. The trigger module uses this to filter out inappropriate actions when presenting the interface for assigning actions to events. If you are writing actions in your own modules and you simply want to declare support for all possible hooks, you can set ' hooks' => array (' any ' => TRUE). Common hooks are ' user ', ' nodeapi ', ' comment ', or ' taxonomy '. Any hook that has been described to Drupal in hook_hook_info () will work is a possiblity. o ' behaviour ': (optional) Human-readable array of behaviour descriptions. The only one we have now is ' changes node property '. You will almost certainly never have to return this in your own implementations of this hook. The linked subjects Хуки Allows units to co-operate with kernel Drupal. ? 1 function calls hook_action_info () ? 1 function calls hook_action_info () actions_list in includes/actions.inc Discovers all operations (actions) by call hook_action_info (). Источник основного материала