Calls a routine on the current route and returns its result
public routineCall ( string $type, string $method, Respect\Rest\Routines\Routinable $routine, array &$params ) : mixed | ||
$type | string | The name of the routine (accept, when, etc) |
$method | string | The method name (GET, HEAD, POST, etc) |
$routine | Respect\Rest\Routines\Routinable | Some routine instance |
$params | array | Params from the routine |
return | mixed | Whatever the routine returns |
public function matchRoutines(Request $request, &$params = array()) { foreach ($this->routines as $routine) { if ($routine instanceof ProxyableWhen && !$request->routineCall('when', $request->method, $routine, $params)) { return false; } } return true; }
/** Checks if this route matches a request */ public function match(Request $request, &$params = array()) { if ($request->method !== $this->method && $this->method !== 'ANY' || 0 === stripos($request->method, '__')) { return false; } foreach ($this->routines as $routine) { if ($routine instanceof ProxyableWhen && !$request->routineCall('when', $request->method, $routine, $params)) { return false; } } $matchUri = preg_replace('#(\\.\\w+)*$#', '', $request->uri); if (!preg_match($this->regexForMatch, $matchUri, $params)) { return false; } if (count($params) > 1 && false !== stripos(end($params), '/')) { $lastParam = array_pop($params); $params = array_merge($params, explode('/', $lastParam)); } return true; }