示例#1
0
 /** Calls a routine on the current route and returns its result */
 public function routineCall($type, $method, AbstractRoutine $routine, &$routeParamsValues)
 {
     $reflection = $this->route->getReflection($method);
     $callbackParameters = array();
     if ($routine instanceof ParamSynced) {
         foreach ($routine->getParameters() as $parameter) {
             $callbackParameters[] = $this->extractRouteParam($reflection, $parameter, $routeParamsValues);
         }
     } else {
         $callbackParameters = $routeParamsValues;
     }
     return $routine->{$type}($this, $callbackParameters);
 }
示例#2
0
 public function appendRoute(AbstractRoute $route)
 {
     $this->routes[] = $route;
     foreach ($this->globalRoutines as $routine) {
         $route->appendRoutine($routine);
     }
     usort($this->routes, function ($a, $b) {
         $a = $a->getPath();
         $b = $b->getPath();
         if (0 === stripos($a, $b)) {
             return 1;
         } elseif (0 === stripos($b, $a)) {
             return -1;
         } elseif (substr_count($a, '/') < substr_count($b, '/')) {
             return 1;
         }
         return substr_count($a, AbstractRoute::PARAM_IDENTIFIER) < substr_count($b, AbstractRoute::PARAM_IDENTIFIER) ? -1 : 1;
     });
 }
 public function __construct($class, $callback)
 {
     $this->class = $class;
     $this->callback = $callback;
     parent::__construct('ANY', '^$');
 }
示例#4
0
文件: Router.php 项目: nickl-/Rest
 /** Returns true if the passed route matches the passed request */
 protected function matchRoute(Request $request, AbstractRoute $route, &$params = array())
 {
     $request->route = $route;
     return $route->match($request, $params);
 }
 public function __construct($method, $pattern, $instance)
 {
     $this->instance = $instance;
     $this->class = get_class($instance);
     parent::__construct($method, $pattern);
 }
示例#6
0
文件: Factory.php 项目: nickl-/Rest
 public function __construct($method, $pattern, $class, $factory)
 {
     $this->factory = $factory;
     $this->class = $class;
     parent::__construct($method, $pattern);
 }
示例#7
0
 /**
  * @param string $method  The HTTP method (GET, POST, etc)
  * @param string $pattern The URI pattern for this route (like /users/*)
  * @param string $class   The class name
  * @param array  $params  Constructor params for the class
  *
  * @see Respect\Rest\Routes\ClassName::$class
  * @see Respect\Rest\Routes\ClassName::$constructorParams
  */
 public function __construct($method, $pattern, $class, array $params = array())
 {
     $this->class = $class;
     $this->constructorParams = $params;
     parent::__construct($method, $pattern);
 }
示例#8
0
文件: Callback.php 项目: nickl-/Rest
 public function __construct($method, $pattern, $callback)
 {
     $this->callback = $callback;
     parent::__construct($method, $pattern);
 }
 public function __construct($method, $pattern, $value)
 {
     $this->value = $value;
     parent::__construct($method, $pattern);
     $this->reflection = new ReflectionMethod($this, 'returnValue');
 }
示例#10
0
 /**
  * @param string   $method    The HTTP method (GET, POST, etc)
  * @param string   $pattern   The URI pattern for this route
  * @param callable $callback  The callback this route holds
  * @param array    $arguments Additional arguments for this callback
  */
 public function __construct($method, $pattern, $callback, array $arguments = array())
 {
     $this->callback = $callback;
     $this->arguments = $arguments;
     parent::__construct($method, $pattern);
 }
示例#11
0
 public function __construct($method, $pattern, $instance)
 {
     $this->instance = $instance;
     parent::__construct($method, $pattern);
 }