You are here

private function crumbs_InjectedAPI_Collection_PluginCollection::analyzePluginMethods in Crumbs, the Breadcrumbs suite 7.2

Parameters

string $plugin_key:

crumbs_PluginInterface $plugin:

Return value

string[][] Format: $['findParent']['node/%'] = 'findParent__node_x' Any legacy methods.

1 call to crumbs_InjectedAPI_Collection_PluginCollection::analyzePluginMethods()
crumbs_InjectedAPI_Collection_PluginCollection::addPlugin in lib/InjectedAPI/Collection/PluginCollection.php

File

lib/InjectedAPI/Collection/PluginCollection.php, line 133

Class

crumbs_InjectedAPI_Collection_PluginCollection

Code

private function analyzePluginMethods($plugin_key, crumbs_PluginInterface $plugin) {
  $reflectionObject = new ReflectionObject($plugin);
  $legacyMethods = array();
  $wildcardKey = $plugin instanceof crumbs_MultiPlugin ? $plugin_key . '.*' : $plugin_key;
  foreach ($reflectionObject
    ->getMethods() as $method) {
    switch ($method->name) {
      case 'decorateBreadcrumb':
        $this->routelessPluginMethods['decorateBreadcrumb'][$plugin_key] = true;
        $this->pluginRoutelessMethods[$wildcardKey]['decorateBreadcrumb'] = true;
        break;
      case 'findParent':
      case 'findTitle':
        $this->routelessPluginMethods[$method->name][$plugin_key] = true;
        $this->pluginRoutelessMethods[$wildcardKey][$method->name] = true;
        break;
      default:
        if (0 === strpos($method->name, 'findParent__')) {
          $baseMethodName = 'findParent';
          $methodSuffix = substr($method->name, 12);
        }
        elseif (0 === strpos($method->name, 'findTitle__')) {
          $baseMethodName = 'findTitle';
          $methodSuffix = substr($method->name, 11);
        }
        else {
          break;
        }
        $route = crumbs_Util::routeFromMethodSuffix($methodSuffix);
        $this->routePluginMethods[$baseMethodName][$route][$plugin_key] = true;
        $this->pluginRouteMethods[$wildcardKey][$baseMethodName][$route] = true;
        $legacyMethods[$baseMethodName][$route] = $method->name;
    }
  }
  return $legacyMethods;
}