public function LegacyUrlMatcher::matchRequest

@api

Overrides RequestMatcherInterface::matchRequest

File

drupal/core/lib/Drupal/Core/LegacyUrlMatcher.php, line 102
Definition of Drupal\Core\LegacyUrlMatcher.

Class

LegacyUrlMatcher
UrlMatcher matches URL based on a set of routes.

Namespace

Drupal\Core

Code

public function matchRequest(Request $request) {
  if ($router_item = $this
    ->matchDrupalItem($request->attributes
    ->get('system_path'))) {
    $ret = $this
      ->convertDrupalItem($router_item);

    // Stash the router item in the attributes while we're transitioning.
    $ret['drupal_menu_item'] = $router_item;

    // Most legacy controllers (aka page callbacks) are in a separate file,
    // so we have to include that.
    if ($router_item['include_file']) {
      require_once DRUPAL_ROOT . '/' . $router_item['include_file'];
    }

    // Flag this as a legacy request.  We need to use this for subrequest
    // handling so that we can treat older page callbacks and new routes
    // differently.
    // @todo Remove this line as soon as possible.
    $ret['_legacy'] = TRUE;
    return $ret;
  }

  // This matcher doesn't differentiate by method, so don't bother with those
  // exceptions.
  throw new ResourceNotFoundException();
}