Add a base class for partial matchers.

8.0.x
Larry Garfield 2012-07-03 20:42:09 -05:00 committed by effulgentsia
parent 329fde3f41
commit 0e4b90e09b
2 changed files with 37 additions and 9 deletions

View File

@ -4,19 +4,12 @@ namespace Drupal\Core\Routing;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
/**
* This class filters routes based on their HTTP Method.
*/
class HttpMethodMatcher implements PartialMatcherInterface {
protected $routes;
public function setCollection(RouteCollection $routes) {
$this->routes = $routes;
return $this;
}
class HttpMethodMatcher extends PartialMatcher {
/**
* Matches a request against multiple routes.

View File

@ -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;
}
}