function rules_discover_plugins

Discover plugin implementations.

Class based plugin handlers must be loaded when rules caches are rebuilt, such that they get discovered properly. You have the following options:

  • Put it into a regular module file (discouraged)
  • Put it into your module.rules.inc file
  • Put it in any file and declare it using hook_rules_file_info()
  • Put it in any file and declare it using hook_rules_directory()

In addition to that, the class must be loadable via regular class auto-loading, thus put the file holding the class in your info file or use another class-loader.

Parameters

string $class: The class or interface the plugins must implement. For a plugin to be discovered it must have a static getInfo() method also.

Return value

array An info-hook style array containing info about discovered plugins.

See also

RulesActionHandlerInterface

RulesConditionHandlerInterface

RulesEventHandlerInterface

1 call to rules_discover_plugins()
rules_fetch_data in ./rules.module
Fetches module definitions for the given hook name.

File

./rules.module, line 318

Code

function rules_discover_plugins($class) {
    // Make sure all files possibly holding plugins are included.
    RulesAbstractPlugin::includeFiles();
    $items = array();
    foreach (get_declared_classes() as $plugin_class) {
        if (is_subclass_of($plugin_class, $class) && method_exists($plugin_class, 'getInfo')) {
            $info = call_user_func(array(
                $plugin_class,
                'getInfo',
            ));
            $info['class'] = $plugin_class;
            $info['module'] = _rules_discover_module($plugin_class);
            $items[$info['name']] = $info;
        }
    }
    return $items;
}