예제 #1
0
 public function on($name)
 {
     if (strpos($name, '|') !== false) {
         throw new Exception("on() labels may not contain the '|' (pipe) character");
     }
     $parents = isset($this->message->meta['.selective.parents']) ? $this->message->meta['.selective.parents'] : array();
     if (sizeof($parents) === 0 && sizeof($this->openStack) > 0) {
         $parents = explode("|", $this->openStack[sizeof($this->openStack) - 1]);
     }
     if (sizeof($parents) > 0 && $parents[sizeof($parents) - 1] == $name) {
         $parents = array_slice($parents, 0, -1);
     }
     $filter = $this->_getFilter($name, $parents);
     if ($filter['enabled']) {
         array_push($parents, $name);
         return $this->message->meta(array('.selective.parents' => $parents));
     } else {
         return Insight_Helper::getNullMessage();
     }
 }
예제 #2
0
 public static function plugin($name)
 {
     $instance = self::getInstance();
     if (!$instance->getEnabled()) {
         return Insight_Helper::getNullMessage();
     }
     if (!isset($instance->plugins[$name])) {
         $info = $instance->config->getPluginInfo($name);
         $instance->plugins[$name] = $instance->getApi($info['api']);
     }
     return $instance->plugins[$name];
 }
예제 #3
-1
 public function __call($name, $arguments)
 {
     if (self::$blocks > 0) {
         return Insight_Helper::getNullMessage();
     }
     if ($this->apiOnce) {
         if (!method_exists($this->apiOnce, $name)) {
             throw new Exception('Method "' . $name . '" does not exist in class: ' . get_class($this->apiOnce));
         }
         $api = $this->apiOnce;
         $this->apiOnce = false;
         $oldmsg = $api->setMessage($this);
         $retval = call_user_func_array(array($api, $name), $arguments);
         $api->setMessage($oldmsg);
         return $retval;
     } else {
         if ($this->api && method_exists($this->api, $name)) {
             $oldmsg = $this->api->setMessage($this);
             $retval = call_user_func_array(array($this->api, $name), $arguments);
             $this->api->setMessage($oldmsg);
             return $retval;
         }
     }
     if ($name == 'once') {
         $message = clone $this;
         $message->once = $arguments[0];
         return $message;
     } else {
         if ($name == 'to') {
             $message = clone $this;
             $message->to = $arguments[0];
             return $message;
         } else {
             if ($name == 'is') {
                 if (is_bool($arguments[0])) {
                     return $arguments[0];
                 }
                 throw new Exception('non-boolean is() comparison not supported');
             } else {
                 if ($name == 'api') {
                     $message = clone $this;
                     $api = $arguments[0];
                     if (is_string($api)) {
                         $api = $this->helper->getApi($api);
                     }
                     if (isset($arguments[1]) && $arguments[1] === true) {
                         $message->apiOnce = $api;
                     } else {
                         $message->api = $api;
                     }
                     if (method_exists($api, 'setRequest')) {
                         $api->setRequest($this->helper->getRequest());
                     }
                     return $message;
                 } else {
                     if ($name == 'meta') {
                         $message = clone $this;
                         foreach ($arguments[0] as $name => $value) {
                             if ($value === null) {
                                 unset($message->meta[$name]);
                             } else {
                                 if (isset($message->meta[$name])) {
                                     $message->meta[$name] = Insight_Util::array_merge($message->meta[$name], $value);
                                 } else {
                                     $message->meta[$name] = $value;
                                 }
                             }
                         }
                         return $message;
                     } else {
                         if ($name == 'open') {
                             return $this;
                         } else {
                             if ($name == 'close') {
                                 return $this;
                             }
                         }
                     }
                 }
             }
         }
     }
     throw new Exception("Unknown method: " . $name);
 }