Add a base class for partial matchers.
parent
329fde3f41
commit
0e4b90e09b
|
@ -4,19 +4,12 @@ namespace Drupal\Core\Routing;
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\Routing\RouteCollection;
|
use Symfony\Component\Routing\RouteCollection;
|
||||||
|
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class filters routes based on their HTTP Method.
|
* This class filters routes based on their HTTP Method.
|
||||||
*/
|
*/
|
||||||
class HttpMethodMatcher implements PartialMatcherInterface {
|
class HttpMethodMatcher extends PartialMatcher {
|
||||||
|
|
||||||
protected $routes;
|
|
||||||
|
|
||||||
public function setCollection(RouteCollection $routes) {
|
|
||||||
$this->routes = $routes;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matches a request against multiple routes.
|
* Matches a request against multiple routes.
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\Core\Routing;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\Routing\RouteCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility base class for partial matchers.
|
||||||
|
*/
|
||||||
|
abstract class PartialMatcher implements PartialMatcherInterface {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The RouteCollection this matcher should match against.
|
||||||
|
*
|
||||||
|
* @var RouteCollection
|
||||||
|
*/
|
||||||
|
protected $routes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the route collection this matcher should use.
|
||||||
|
*
|
||||||
|
* @param RouteCollection $collection
|
||||||
|
* The collection against which to match.
|
||||||
|
*
|
||||||
|
* @return PartialMatcherInterface
|
||||||
|
* The current matcher.
|
||||||
|
*/
|
||||||
|
public function setCollection(RouteCollection $collection) {
|
||||||
|
$this->routes = $collection;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue