You are here

function hook_menu_position_rule_plugins in Menu Position 8

Same name and namespace in other branches
  1. 6 menu_position.api.php \hook_menu_position_rule_plugins()
  2. 7.2 menu_position.api.php \hook_menu_position_rule_plugins()
  3. 7 menu_position.api.php \hook_menu_position_rule_plugins()

Registers rule plugins with menu_position module.

Modules implementing menu position rule plugins should return an associative array of data. Each key in the array should be the name of plugin implemented by the module. Each key's value should be an associative array with the following optional data:

  • form_callback: (optional) The name of the function to use to add a configurable form elements to the rule definition form. Defaults to "MODULE_menu_position_rule_PLUGIN_form".
  • condition_callback: (optional) The name of the function to use when the rule is being tested. Defaults to "MODULE_menu_position_condition_PLUGIN".
  • file: (optional) The path, relative to the .module file, to an include file containing the form and condition callback function definitions. The hook_menu_position_rule_plugins() implementation must be in a .module file, but the include file will only be loaded if a rule is configured to use the plugin's condition.

Return value

array An associative array containing the information about each plugin.

File

./menu_position.api.php, line 53
Hooks provided by the Menu Position module.

Code

function hook_menu_position_rule_plugins() {
  return [
    // Register the "foo" plugin.
    'foo' => [
      'form_callback' => 'my_module_menu_position_rule_foo_form',
      'condition_callback' => 'my_module_menu_position_condition_foo',
      'file' => 'my_module.foo.inc',
    ],
    // Register the "bar" plugin.
    // Use the defaults for all options.
    'bar' => [],
  ];
}