function _rules_import_get_plugin

Determines the plugin to be used for importing a child element.

Parameters

string $key: The key to look for, e.g. 'OR' or 'DO'.

string $default: The default to return if no special plugin can be found.

1 call to _rules_import_get_plugin()
RulesContainerPlugin::importChildren in includes/rules.core.inc

File

includes/rules.core.inc, line 2932

Code

function _rules_import_get_plugin($key, $default = 'action') {
    $map =& drupal_static(__FUNCTION__);
    if (!isset($map)) {
        $cache = rules_get_cache();
        foreach ($cache['plugin_info'] as $name => $info) {
            if (!empty($info['embeddable'])) {
                $info += array(
                    'import keys' => array(
                        strtoupper($name),
                    ),
                );
                foreach ($info['import keys'] as $k) {
                    $map[$k] = $name;
                }
            }
        }
    }
    // Cut off any leading NOT from the key.
    if (strpos($key, 'NOT ') === 0) {
        $key = substr($key, 4);
    }
    if (isset($map[$key])) {
        return $map[$key];
    }
    return $default;
}