public function process($plugin, $key, $callback)
 {
     $callback = is_string($callback) ? array($plugin, $callback) : $callback;
     $callback = Amslib_Plugin::getCallback($callback);
     if (!$this->queryPath || !is_callable($callback)) {
         $callback = $callback instanceof Closure ? "{closure}" : $callback;
         Amslib_Debug::log("QueryPath or callback not valid", $plugin->getName(), $key, $callback);
         return;
     }
     try {
         $results = $this->queryPath->branch()->find($key);
     } catch (Exception $e) {
         Amslib_Debug::log("QueryPath Exception", $e->getMessage());
     }
     foreach ($results as $r) {
         $r = Amslib_QueryPath::toArray($r);
         call_user_func($callback, $r["tag"], $r, $plugin);
     }
 }
Example #2
0
 public function installHandlers($group, $output, $handlerList)
 {
     foreach (Amslib_Array::valid($handlerList) as $h) {
         $c = $h;
         //	"framework" is claimed as a standard name for amslib and is no longer usable
         //	by other plugins, I'm not sure if this is still true, but I should evaluate
         //	whether it causes a problem or not
         if (array_key_exists("plugin", $h) && $h["plugin"] == "framework") {
             $c["plugin"] = false;
         } else {
             if (!array_key_exists("plugin", $c)) {
                 $c["plugin"] = $group;
             }
             if (!array_key_exists("object", $c)) {
                 $c["object"] = false;
             }
         }
         //  set the handler plugin from the callback plugin
         $h["plugin"] = $c["plugin"];
         $callback = Amslib_Plugin::getCallback(array_filter(array($c["plugin"], $c["object"], $c["method"])));
         $params = array($h["plugin"], $callback, $h["input"], $h["record"], $h["global"], $h["failure"]);
         if ($h["type"] == "service") {
             $method = "setHandler";
             array_unshift($params, $output);
         } else {
             $method = "setTerminator";
             array_unshift($params, str_replace("terminator_", "", $h["type"]));
         }
         call_user_func_array(array($this, $method), $params);
     }
 }