2

I would want a route which matches "anything". From the "anything" value I want to lookup if a page with the given path exists in the database. If it does, this route needs to be handled, otherwise the next matching route should be handled.

Is there an easy way for this or am I missing the point of routes?

  • Tried asserting a route, but I couldn't find a way to assert it with a Closure
  • Searched for a way to "return false" in a Route match so it handles the next Route
  • is there a way to add a callback to a Route to see if it really matches (in addition to the regex pattern)
4

1 回答 1

3

您可以在“任何”控制器中使用 Sub Request 并路由到指定的控制器。请参阅食谱:如何提出子请求

switch ($action) {
  case 'a':
    $subRequest = Request::create($route, 'GET', array('usage' => self::$usage));
    $response = $app->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
    break;
  case 'b': ...
  default : ...
}
于 2013-10-21T14:17:49.980 回答