lithium\net\http\Router::parse()

public static method

Accepts an instance of lithium\action\Request (or a subclass) and matches it against each route, in the order that the routes are connected.

If a route match the request, lithium\net\http\Router::_scope will be updated according the scope membership of the route

Parameters

  • object $request

    A request object containing URL and environment data.

Returns

array

Returns an array of parameters specifying how the given request should be routed. The keys returned depend on the Route object that was matched, but typically include 'controller' and 'action' keys.

Source

	public static function parse($request) {
		foreach (static::$_configurations as $name => $value) {
			$original = $request->params;
			$name = is_int($name) ? false : $name;

			if (!$url = static::_parseScope($name, $request)) {
				continue;
			}

			foreach (static::$_configurations[$name] as $route) {
				if (!$match = $route->parse($request, compact('url'))) {
					continue;
				}
				$request = $match;
				if ($route->canContinue() && isset($request->params['args'])) {
					$url = '/' . join('/', $request->params['args']);
					unset($request->params['args']);
					continue;
				}

				static::attach($name, null, isset($request->params) ? $request->params : []);
				static::scope($name);

				return $request;
			}
			$request->params = $original;
		}
	}