Implements \Symfony\Cmf\Component\Routing\Enhancer\ŖouteEnhancerIterface.
Iterates over all registered converters and allows them to alter the defaults.
array $defaults: The getRouteDefaults array.
\Symfony\Component\HttpFoundation\Request $request: The current request.
array The modified defaults.
Overrides RouteEnhancerInterface::enhance
public function enhance(array $defaults, Request $request) {
// This array will collect the names of all variables which have been
// altered by a converter.
// This serves two purposes:
// 1. It might prevent converters later in the pipeline to process
// a variable again.
// 2. To check if upcasting was successfull after each converter had
// a go. See below.
$converters = array();
$route = $defaults[RouteObjectInterface::ROUTE_OBJECT];
foreach ($this->converters as $converter) {
$converter
->process($defaults, $route, $converters);
}
// Check if all upcasting yielded a result.
// If an upcast value is NULL do a 404.
foreach ($converters as $variable) {
if ($defaults[$variable] === NULL) {
throw new NotFoundHttpException();
}
}
return $defaults;
}