예제 #1
0
파일: Guard.php 프로젝트: hexing-w/wechat
 /**
  * Add a listener.
  *
  * @param string          $target
  * @param string|callable $type
  * @param callable        $callback
  *
  * @return Guard
  *
  * @throws InvalidArgumentException
  */
 public function on($target, $type, $callback = null)
 {
     if (is_null($callback)) {
         $callback = $type;
         $type = '*';
     }
     if (!is_callable($callback)) {
         throw new InvalidArgumentException('The linstener is not callable.');
     }
     $type = strtolower($type);
     $listeners = $this->listeners->get("{$target}.{$type}") ?: [];
     array_push($listeners, $callback);
     $this->listeners->set("{$target}.{$type}", $listeners);
     return $this;
 }
예제 #2
0
파일: Server.php 프로젝트: stingbo/masapi
 /**
  * 魔术调用
  *
  * @param string $method
  * @param array  $args
  *
  * @return mixed
  */
 public function __call($method, $args)
 {
     if (in_array($method, $this->events, true)) {
         $callback = array_shift($args);
         is_callable($callback) && $this->listeners->set($method, $callback);
         return;
     }
 }
예제 #3
0
 /**
  * Override parent set() method.
  *
  * @param string $attribute
  * @param mixed  $value
  */
 public function set($attribute, $value = null)
 {
     parent::set($this->getRealKey($attribute), $value);
 }
예제 #4
0
 /**
  * Override parent set() method.
  *
  * @param string $attribute
  * @param mixed  $value
  */
 public function set($attribute, $value = null)
 {
     if ($alias = array_search($attribute, $this->aliases, true)) {
         $attribute = $alias;
     }
     return parent::set($attribute, $value);
 }