You are here

function crumbs_PluginOperation_describe::invoke in Crumbs, the Breadcrumbs suite 7

Same name and namespace in other branches
  1. 7.2 lib/PluginOperation/describe.php \crumbs_PluginOperation_describe::invoke()

To be called from _crumbs_load_available_keys()

File

lib/PluginOperation/describe.php, line 25

Class

crumbs_PluginOperation_describe
This class uses the PluginOperation pattern, but it does not implement any of the PluginOperation interfaces. This is because it is not supposed to be used with the PluginEngine, but rather from a custom function (see above).

Code

function invoke($plugin, $plugin_key) {
  $this->pluginKey = $plugin_key;
  if ($plugin instanceof crumbs_MonoPlugin) {
    $result = $plugin
      ->describe($this->injectedAPI_mono);
    if (is_string($result)) {
      $this
        ->setTitle($result);
    }
  }
  elseif ($plugin instanceof crumbs_MultiPlugin) {

    // That's a multi plugin.
    $result = $plugin
      ->describe($this->injectedAPI_multi);
    if (is_array($result)) {
      foreach ($result as $key_suffix => $title) {
        $this
          ->addRule($key_suffix, $title);
      }
    }
  }
}