You are here

function crumbs_InjectedAPI_hookCrumbsPlugins::monoPlugin in Crumbs, the Breadcrumbs suite 7

Same name and namespace in other branches
  1. 7.2 lib/InjectedAPI/hookCrumbsPlugins.php \crumbs_InjectedAPI_hookCrumbsPlugins::monoPlugin()

Register a "Multi" plugin. That is, a plugin that defines more than one rule.

Parameters

$key: Rule key, relative to module name.

$plugin: Plugin object. Needs to implement crumbs_MultiPlugin. Or NULL, to have the plugin object automatically created based on a class name guessed from the $key parameter and the module name.

File

lib/InjectedAPI/hookCrumbsPlugins.php, line 43

Class

crumbs_InjectedAPI_hookCrumbsPlugins
API object to be used as an argument for hook_crumbs_plugins() This is a sandbox class, currently not used..

Code

function monoPlugin($key = NULL, $plugin = NULL) {
  if (!isset($key)) {
    $class = $this->module . '_CrumbsMonoPlugin';
    $plugin = new $class();
    $key = $this->module;
  }
  elseif (!isset($plugin)) {
    $class = $this->module . '_CrumbsMonoPlugin_' . $key;
    $plugin = new $class();
    $key = $this->module . '.' . $key;
  }
  else {
    $class = get_class($plugin);
    $key = $this->module . '.' . $key;
  }
  if (!$plugin instanceof crumbs_MonoPlugin) {
    throw new Exception("{$class} must implement class_MonoPlugin.");
  }
  $this->plugins[$key] = $plugin;
  if (method_exists($plugin, 'disabledByDefault')) {
    $disabled_by_default = $plugin
      ->disabledByDefault();
    if ($disabled_by_default === TRUE) {
      $this->disabledKeys[$key] = $key;
    }
    elseif ($disabled_by_default !== FALSE && $disabled_by_default !== NULL) {
      throw new Exception("{$class}::disabledByDefault() must return TRUE, FALSE or NULL.");
    }
  }
}