Projet

Général

Profil

Révision 950416da

Ajouté par Assos Assos il y a plus de 5 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/rules/rules.api.php
2 2

  
3 3
/**
4 4
 * @file
5
 * Documentation for hooks provided by the Rules API.
6
 *
5 7
 * This file contains no working PHP code; it exists to provide additional
6 8
 * documentation for doxygen as well as to document hooks in the standard
7 9
 * Drupal manner.
8 10
 */
9 11

  
10

  
11 12
/**
12 13
 * @defgroup rules Rules module integrations.
13 14
 *
14 15
 * Module integrations with the rules module.
15 16
 *
16 17
 * The Rules developer documentation describes how modules can integrate with
17
 * rules: http://drupal.org/node/298486.
18
 * rules: https://www.drupal.org/node/298486.
18 19
 */
19 20

  
20 21
/**
......
34 35
 * handlers may be provided by implementing RulesActionHandlerInterface. See
35 36
 * the interface for details.
36 37
 *
37
 * @return
38
 * @return array
38 39
 *   An array of information about the module's provided rules actions.
39 40
 *   The array contains a sub-array for each action, with the action name as
40 41
 *   the key. Actions names may only contain lowercase alpha-numeric characters
......
66 67
 *   - 'access callback': (optional) A callback which has to return whether the
67 68
 *     currently logged in user is allowed to configure this action. See
68 69
 *     rules_node_integration_access() for an example callback.
69
 *  Each 'parameter' array may contain the following properties:
70
 *   Each 'parameter' array may contain the following properties:
70 71
 *   - label: The label of the parameter. Start capitalized. Required.
71 72
 *   - type: The rules data type of the parameter, which is to be passed to the
72 73
 *     action. All types declared in hook_rules_data_info() may be specified, as
......
114 115
 *     to clean inserted replacements; e.g. this is used by the token evaluator.
115 116
 *   - wrapped: (optional) Set this to TRUE in case the data should be passed
116 117
 *     wrapped. This only applies to wrapped data types, e.g. entities.
117
 *  Each 'provides' array may contain the following properties:
118
 *   Each 'provides' array may contain the following properties:
118 119
 *   - label: The label of the variable. Start capitalized. Required.
119 120
 *   - type: The rules data type of the variable. All types declared in
120 121
 *     hook_rules_data_info() may be specified. Types may be parametrized e.g.
......
122 123
 *   - save: (optional) If this is set to TRUE, the provided variable is saved
123 124
 *     by rules when the rules evaluation ends. Only possible for savable data
124 125
 *     types. Defaults to FALSE.
126
 *   The module has to provide an implementation for each action, being a
127
 *   function named as specified in the 'base' key or for the execution callback.
128
 *   All other possible callbacks are optional.
129
 *   Supported action callbacks by rules are defined and documented in the
130
 *   RulesPluginImplInterface. However any module may extend the action plugin
131
 *   based upon a defined interface using hook_rules_plugin_info(). All methods
132
 *   defined in those interfaces can be overridden by the action implementation.
133
 *   The callback implementations for those interfaces may reside in any file
134
 *   specified in hook_rules_file_info().
125 135
 *
126
 *  The module has to provide an implementation for each action, being a
127
 *  function named as specified in the 'base' key or for the execution callback.
128
 *  All other possible callbacks are optional.
129
 *  Supported action callbacks by rules are defined and documented in the
130
 *  RulesPluginImplInterface. However any module may extend the action plugin
131
 *  based upon a defined interface using hook_rules_plugin_info(). All methods
132
 *  defined in those interfaces can be overridden by the action implementation.
133
 *  The callback implementations for those interfaces may reside in any file
134
 *  specified in hook_rules_file_info().
135
 *
136
 *  @see hook_rules_file_info()
137
 *  @see rules_action_execution_callback()
138
 *  @see hook_rules_plugin_info()
139
 *  @see RulesPluginImplInterface
136
 * @see hook_rules_file_info()
137
 * @see rules_action_execution_callback()
138
 * @see hook_rules_plugin_info()
139
 * @see RulesPluginImplInterface
140 140
 */
141 141
function hook_rules_action_info() {
142 142
  return array(
......
167 167
 * will be treated as grouping in the given category (e.g. group "paypal" in
168 168
 * category "commerce payment").
169 169
 *
170
 * @return
170
 * @return array
171 171
 *   An array of information about the module's provided categories.
172 172
 *   The array contains a sub-array for each category, with the category name as
173 173
 *   the key. Names may only contain lowercase alpha-numeric characters
......
176 176
 *   - label: The label of the category. Start capitalized. Required.
177 177
 *   - weight: (optional) A weight for sorting the category. Defaults to 0.
178 178
 *   - equals group: (optional) For BC, categories may be defined that equal
179
 *     a previsouly used 'group'.
179
 *     a previously used 'group'.
180 180
 *   - icon: (optional) The file path of an icon to use, relative to the module
181 181
 *     or specified icon path. The icon should be a transparent SVG containing
182
 *     no colors (only #fff). See https://drupal.org/node/2090265 for
183
 *     instructions on how to create a suiting icon.
182
 *     no colors (only #fff). See https://www.drupal.org/node/2090265 for
183
 *     instructions on how to create a suitable icon.
184 184
 *     Note that the icon is currently not used by Rules, however other UIs
185 185
 *     building upon Rules (like fluxkraft) do, and future releases of Rules
186 186
 *     might do as well. Consequently, the definition of an icon is optional.
187 187
 *     However, if both an icon font and icon is given, the icon is preferred.
188 188
 *   - icon path: (optional) The base path for the icon. Defaults to the
189 189
 *     providing module's directory.
190
 *   - icon font class: (optional) An icon font class referring to a suiting
190
 *   - icon font class: (optional) An icon font class referring to a suitable
191 191
 *     icon. Icon font class names should map to the ones as defined by Font
192 192
 *     Awesome, while themes might want to choose to provide another icon font.
193 193
 *     See http://fortawesome.github.io/Font-Awesome/cheatsheet/.
......
221 221
 * plugin method callbacks in any file without having to care about file
222 222
 * inclusion.
223 223
 *
224
 * @return
224
 * @return array
225 225
 *   An array of file names without the file ending which defaults to '.inc'.
226 226
 */
227 227
function hook_rules_file_info() {
......
259 259
 *   The callback gets arguments passed as described as parameter in
260 260
 *   hook_rules_action_info() as well as an array containing the action's
261 261
 *   configuration settings.
262
 * @return
263
 *   The action may return an array containg parameter or provided variables
262
 *
263
 * @return array
264
 *   The action may return an array containing parameter or provided variables
264 265
 *   with their names as key. This is used update the value of a parameter or to
265
 *   provdide the value for a provided variable.
266
 *   provide the value for a provided variable.
266 267
 *   Apart from that any parameters which have the key 'save' set to TRUE will
267 268
 *   be remembered to be saved by rules unless the action returns FALSE.
268 269
 *   Conditions have to return a boolean value in any case.
......
321 322
 * handlers may be provided by implementing RulesEventHandlerInterface. See
322 323
 * the interface for details.
323 324
 *
324
 * @return
325
 * @return array
325 326
 *   An array of information about the module's provided rules events. The array
326 327
 *   contains a sub-array for each event, with the event name as the key. The
327 328
 *   name may only contain lower case alpha-numeric characters and underscores
......
360 361
 *     - handler: (optional) A handler to load the actual variable value. This
361 362
 *       is useful for lazy loading variables. The handler gets all so far
362 363
 *       available variables passed in the order as defined. Also see
363
 *       http://drupal.org/node/884554.
364
 *       https://www.drupal.org/node/884554.
364 365
 *       Note that for lazy-loading entities just the entity id may be passed
365 366
 *       as variable value, so a handler is not necessary in that case.
366 367
 *
367
 *  @see rules_invoke_event()
368
 * @see rules_invoke_event()
368 369
 */
369 370
function hook_rules_event_info() {
370 371
  $items = array(
......
413 414
 * module.
414 415
 * For a list of data types defined by rules see rules_rules_core_data_info().
415 416
 *
416
 *
417
 * @return
417
 * @return array
418 418
 *   An array of information about the module's provided data types. The array
419 419
 *   contains a sub-array for each data type, with the data type name as the
420 420
 *   key. The name may only contain lower case alpha-numeric characters and
......
446 446
 *     makes use of the class for wrapping the data of the given type. However
447 447
 *     note that if data is already wrapped when it is passed to Rules, the
448 448
 *     existing wrappers will be kept.
449
 *     For modules implementing identifiable data types being non-entites the
449
 *     For modules implementing identifiable data types being non-entities the
450 450
 *     class RulesIdentifiableDataWrapper is provided, which can be used as base
451 451
 *     for a custom wrapper class. See RulesIdentifiableDataWrapper for details.
452 452
 *   - property info: (optional) May be used for non-entity data structures to
......
470 470
 *   - cleaning callback: (optional) A callback that input evaluators may use
471 471
 *     to clean inserted replacements; e.g. this is used by the token evaluator.
472 472
 *
473
 *  @see entity_metadata_wrapper()
474
 *  @see hook_rules_data_info_alter()
475
 *  @see rules_rules_core_data_info()
473
 * @see entity_metadata_wrapper()
474
 * @see hook_rules_data_info_alter()
475
 * @see rules_rules_core_data_info()
476 476
 */
477 477
function hook_rules_data_info() {
478 478
  return array(
......
497 497
 * A rules configuration may consist of elements being instances of any rules
498 498
 * plugin. This hook can be used to define new or to extend rules plugins.
499 499
 *
500
 * @return
500
 * @return array
501 501
 *   An array of information about the module's provided rules plugins. The
502 502
 *   array contains a sub-array for each plugin, with the plugin name as the
503 503
 *   key. The name may only contain lower case alpha-numeric characters,
......
543 543
 *     of the 'or' plugin. Note that only uppercase values are allowed, as
544 544
 *     lower case values are treated as action or condition exports.
545 545
 *
546
 *  @see class RulesPlugin
547
 *  @see hook_rules_plugin_info_alter()
546
 * @see RulesPlugin
547
 * @see hook_rules_plugin_info_alter()
548 548
 */
549 549
function hook_rules_plugin_info() {
550 550
  return array(
......
583 583
 * and help() could be overridden in order to control access permissions or to
584 584
 * provide some usage help.
585 585
 *
586
 * @return
586
 * @return array
587 587
 *   An array of information about the module's provided input evaluators. The
588 588
 *   array contains a sub-array for each evaluator, with the evaluator name as
589 589
 *   the key. The name may only contain lower case alpha-numeric characters and
......
597 597
 *     used. Defaults to 'text'. Multiple data types may be specified using an
598 598
 *     array.
599 599
 *
600
 *  @see class RulesDataInputEvaluator
601
 *  @see hook_rules_evaluator_info_alter()
600
 * @see RulesDataInputEvaluator
601
 * @see hook_rules_evaluator_info_alter()
602 602
 */
603 603
function hook_rules_evaluator_info() {
604 604
  return array(
......
606 606
      'class' => 'RulesTokenEvaluator',
607 607
      'type' => array('text', 'uri'),
608 608
      'weight' => 0,
609
     ),
609
    ),
610 610
  );
611 611
}
612 612

  
......
621 621
 * access() could be overridden in order to provide a configuration form or
622 622
 * to control access permissions.
623 623
 *
624
 * @return
624
 * @return array
625 625
 *   An array of information about the module's provided data processors. The
626 626
 *   array contains a sub-array for each processor, with the processor name as
627 627
 *   the key. The name may only contain lower case alpha-numeric characters and
......
636 636
 *     used. Defaults to 'text'. Multiple data types may be specified using an
637 637
 *     array.
638 638
 *
639
 *  @see class RulesDataProcessor
640
 *  @see hook_rules_data_processor_info_alter()
639
 * @see RulesDataProcessor
640
 * @see hook_rules_data_processor_info_alter()
641 641
 */
642 642
function hook_rules_data_processor_info() {
643 643
  return array(
......
645 645
      'class' => 'RulesDateOffsetProcessor',
646 646
      'type' => 'date',
647 647
      'weight' => -2,
648
     ),
648
    ),
649 649
  );
650 650
}
651 651

  
......
658 658
 * @param $actions
659 659
 *   The items of all modules as returned from hook_rules_action_info().
660 660
 *
661
 * @see hook_rules_action_info().
661
 * @see hook_rules_action_info()
662 662
 */
663 663
function hook_rules_action_info_alter(&$actions) {
664
  // The rules action is more powerful, so hide the core action
664
  // The rules action is more powerful, so hide the core action.
665 665
  unset($actions['rules_core_node_assign_owner_action']);
666 666
  // We prefer handling saving by rules - not by the user.
667 667
  unset($actions['rules_core_node_save_action']);
......
691 691
 * @param $events
692 692
 *   The items of all modules as returned from hook_rules_event_info().
693 693
 *
694
 * @see hook_rules_event_info().
694
 * @see hook_rules_event_info()
695 695
 */
696 696
function hook_rules_event_info_alter(&$events) {
697 697
  // Change events.
......
763 763
 * This hook is invoked during rules configuration loading, which is handled
764 764
 * by entity_load(), via classes RulesEntityController and EntityCRUDController.
765 765
 *
766
 * @param $configs
766
 * @param array $configs
767 767
 *   An array of rules configurations being loaded, keyed by id.
768 768
 */
769 769
function hook_rules_config_load($configs) {
......
857 857
 * should be placed into the file MODULENAME.rules_defaults.inc, which gets
858 858
 * automatically included when the hook is invoked.
859 859
 *
860
 * @return
860
 * @return array
861 861
 *   An array of rules configurations with the configuration names as keys.
862 862
 *
863 863
 * @see hook_default_rules_configuration_alter()
......
866 866
function hook_default_rules_configuration() {
867 867
  $rule = rules_reaction_rule();
868 868
  $rule->label = 'example default rule';
869
  // Add rules tags.
870
  $rule->tags = array('Admin', 'Tag2');
869 871
  $rule->active = FALSE;
870 872
  $rule->event('node_update')
871 873
       ->condition(rules_condition('data_is', array('data:select' => 'node:status', 'value' => TRUE))->negate())
......
873 875
       ->action('drupal_message', array('message' => 'A node has been updated.'));
874 876

  
875 877
  $configs['rules_test_default_1'] = $rule;
878

  
876 879
  return $configs;
877 880
}
878 881

  
......
900 903
 * This hook is invoked by the entity module after default rules configurations
901 904
 * have been rebuilt; i.e. defaults have been saved to the database.
902 905
 *
903
 * @param $rules_configs
906
 * @param array $rules_configs
904 907
 *   The array of default rules configurations which have been inserted or
905 908
 *   updated, keyed by name.
906
 * @param $originals
909
 * @param array $originals
907 910
 *   An array of original rules configurations keyed by name; i.e. the rules
908 911
 *   configurations before the current defaults have been applied. For inserted
909 912
 *   rules configurations no original is available.
......
982 985
 * @param $element
983 986
 *   The element array of a configured condition or action which is to be
984 987
 *   upgraded.
985
 * @return
988
 *
989
 * @return string
986 990
 *   The name of the action or condition which should be used.
987 991
 */
988 992
function hook_rules_action_base_upgrade_map_name($element) {
......
990 994
}
991 995

  
992 996
/**
993
 * D6 to D7 upgrade procedure hook for mapping action or condition configuration.
997
 * D6 to D7 upgrade process hook for mapping action or condition configuration.
994 998
 *
995 999
 * During upgrading Drupal 6 rule configurations to Drupal 7 Rules is taking
996 1000
 * care of upgrading the configuration of all known parameters, which only works
997 1001
 * if the parameter name has not changed.
998 1002
 * If something changed, this callback can be used to properly apply the
999
 * configruation of the Drupal 6 action ($element) to the Drupal 7 version
1003
 * configuration of the Drupal 6 action ($element) to the Drupal 7 version
1000 1004
 * ($target).
1001 1005
 *
1002 1006
 * This is no real hook, but a callback that is invoked for each Drupal 6
......
1018 1022
}
1019 1023

  
1020 1024
/**
1021
 * D6 to D7 upgrade procedure hook for mapping action or condition configuration.
1025
 * D6 to D7 upgrade process hook for mapping action or condition configuration.
1022 1026
 *
1023 1027
 * A alter hook that is called after the action/condition specific callback for
1024 1028
 * each element of a configuration that is upgraded.
......
1068 1072
 * a given user has access to perform a given operation on a Rules
1069 1073
 * configuration.
1070 1074
 *
1071
 * @param $op
1075
 * @param string $op
1072 1076
 *   The operation being performed. One of 'view', 'create', 'update' or
1073 1077
 *   'delete'.
1074 1078
 * @param $rules_config
......
1077 1081
 * @param $account
1078 1082
 *   (optional) The user to check for. If no account is passed, access is
1079 1083
 *   determined for the current user.
1080
 * @return boolean
1084
 *
1085
 * @return bool|null
1081 1086
 *   Return TRUE to grant access, FALSE to explicitly deny access. Return NULL
1082 1087
 *   or nothing to not affect the operation.
1083 1088
 *   Access is granted as soon as a module grants access and no one denies

Formats disponibles : Unified diff