2
votes

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)
1

1 Answers

3
votes

You can use Sub Request within your "anything" controller and route to the specified controllers. See the cookbook: How to make sub-requests:

switch ($action) {
  case 'a':
    $subRequest = Request::create($route, 'GET', array('usage' => self::$usage));
    $response = $app->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
    break;
  case 'b': ...
  default : ...
}