Run LegacyUrlMatcher through ChainMatcher. That necessitates making ChainMatcher temporarily context-aware.
parent
1bf98066ba
commit
a6d59f6d18
|
@ -57,7 +57,8 @@ class CoreBundle extends Bundle
|
|||
// @todo Replace below lines with the commented out block below it when it's
|
||||
// performant to do so: http://drupal.org/node/1706064.
|
||||
$dispatcher = $container->get('dispatcher');
|
||||
$matcher = new \Drupal\Core\LegacyUrlMatcher();
|
||||
$matcher = new \Drupal\Core\Routing\ChainMatcher();
|
||||
$matcher->add(new \Drupal\Core\LegacyUrlMatcher());
|
||||
$content_negotation = new \Drupal\Core\ContentNegotiation();
|
||||
$dispatcher->addSubscriber(new \Symfony\Component\HttpKernel\EventListener\RouterListener($matcher));
|
||||
$dispatcher->addSubscriber(new \Drupal\Core\EventSubscriber\ViewSubscriber($content_negotation));
|
||||
|
|
|
@ -7,11 +7,16 @@ use Symfony\Component\Routing\Matcher\RequestMatcherInterface;
|
|||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
use Symfony\Component\Routing\Exception\RouteNotFoundException;
|
||||
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
||||
use Symfony\Component\Routing\RequestContextAwareInterface;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* Description of ChainMatcher
|
||||
* Aggregates multiple matchers together in series.
|
||||
*
|
||||
* The RequestContext is entirely unused. It's included only to satisfy the
|
||||
* interface needed for RouterListener. Hopefully we can remove it later.
|
||||
*/
|
||||
class ChainMatcher implements RequestMatcherInterface {
|
||||
class ChainMatcher implements RequestMatcherInterface, RequestContextAwareInterface {
|
||||
|
||||
/**
|
||||
* Array of RequestMatcherInterface objects to be checked in order.
|
||||
|
@ -26,6 +31,54 @@ class ChainMatcher implements RequestMatcherInterface {
|
|||
*/
|
||||
protected $sortedMatchers = array();
|
||||
|
||||
/**
|
||||
* The request context for this matcher.
|
||||
*
|
||||
* This is unused. It's just to satisfy the interface.
|
||||
*
|
||||
* @var Symfony\Component\Routing\RequestContext
|
||||
*/
|
||||
protected $context;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
// We will not actually use this object, but it's needed to conform to
|
||||
// the interface.
|
||||
$this->context = new RequestContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the request context.
|
||||
*
|
||||
* This method is just to satisfy the interface, and is largely vestigial.
|
||||
* The request context object does not contain the information we need, so
|
||||
* we will use the original request object.
|
||||
*
|
||||
* @param Symfony\Component\Routing\RequestContext $context
|
||||
* The context.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function setContext(RequestContext $context) {
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the request context.
|
||||
*
|
||||
* This method is just to satisfy the interface, and is largely vestigial.
|
||||
* The request context object does not contain the information we need, so
|
||||
* we will use the original request object.
|
||||
*
|
||||
* @return Symfony\Component\Routing\RequestContext
|
||||
* The context.
|
||||
*/
|
||||
public function getContext() {
|
||||
return $this->context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Matches a request against all queued matchers.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue