use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\UnsupportedMediaTypeHttpException;
-use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
/**
* Filters routes based on the HTTP Content-type header.
*/
-class ContentTypeHeaderMatcher implements RouteFilterInterface {
+class ContentTypeHeaderMatcher implements FilterInterface {
/**
* {@inheritdoc}
*/
public function filter(RouteCollection $collection, Request $request) {
// The Content-type header does not make sense on GET requests, because GET
- // requests do not carry any content. Nothing to filter in this case.
- if ($request->isMethod('GET')) {
+ // requests do not carry any content. Nothing to filter in this case. Same
+ // for all other safe methods.
+ if ($request->isMethodSafe(FALSE)) {
return $collection;
}
}
}
- /**
- * {@inheritdoc}
- */
- public function applies(Route $route) {
- return TRUE;
- }
-
}