<?php
namespace Knp\Rad\UrlGenerationBundle\EventListener;
use Knp\Rad\UrlGenerationBundle\Routing\ParameterStack;
use Symfony\Component\HttpKernel\Event\RequestEvent;
class ParameterExtractionListener
{
/**
* @var ParameterStack
*/
private $stack;
public function __construct(ParameterStack $stack)
{
$this->stack = $stack;
}
public function onRequest(RequestEvent $event)
{
$request = $event->getRequest();
$parameters = $request->attributes->get('_route_params', []);
foreach ($parameters as $name => $value) {
$this->stack->set($name, $value);
}
}
}