Exemple #1
0
 /**
  * @param crumbs_PluginInterface $plugin
  * @param string $plugin_key
  */
 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) {
         $result = $plugin->describe($this->injectedAPI_multi);
         if (is_array($result)) {
             foreach ($result as $key_suffix => $title) {
                 $this->addRule($key_suffix, $title);
             }
         }
     }
 }
Exemple #2
0
 /**
  * @param crumbs_PluginInterface $plugin
  * @param string $plugin_key
  */
 function invoke($plugin, $plugin_key)
 {
     $this->pluginKey = $plugin_key;
     $basic_methods = array();
     $route_methods = array();
     $rf_class = new ReflectionClass($plugin);
     foreach ($rf_class->getMethods() as $rf_method) {
         $method = $rf_method->name;
         $pos = strpos($method, '__');
         if (FALSE !== $pos && 0 !== $pos) {
             $method_base = substr($method, 0, $pos);
             if (in_array($method_base, array('findParent', 'findTitle'))) {
                 $method_suffix = substr($method, $pos + 2);
                 $route = crumbs_Util::routeFromMethodSuffix($method_suffix);
                 $route_methods[$method_base][$route] = $method;
             }
         } else {
             if (in_array($method, array('findParent', 'findTitle', 'decorateBreadcrumb'))) {
                 if (!isset($this->pluginRoutes[$plugin_key])) {
                     $basic_methods[$method] = $method;
                 } else {
                     $route = $this->pluginRoutes[$plugin_key];
                     if (!isset($route_methods[$method][$route])) {
                         $route_methods[$method][$route] = $method;
                     }
                 }
             }
         }
     }
     if ($plugin instanceof crumbs_MonoPlugin) {
         $this->collectedInfo['basicMethods'][$plugin_key] = $basic_methods;
         $this->collectedInfo['routeMethods'][$plugin_key] = $route_methods;
         $result = $plugin->describe($this->injectedAPI_mono);
         if (is_string($result)) {
             $this->setTitle($result);
         }
     } elseif ($plugin instanceof crumbs_MultiPlugin) {
         $this->collectedInfo['basicMethods']["{$plugin_key}.*"] = $basic_methods;
         $this->collectedInfo['routeMethods']["{$plugin_key}.*"] = $route_methods;
         $result = $plugin->describe($this->injectedAPI_multi);
         if (is_array($result)) {
             foreach ($result as $key_suffix => $title) {
                 $this->addRule($key_suffix, $title);
             }
         }
     }
 }