public function onRequest(GetResponseEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     $currentRoute = $event->getRequest()->get('_route');
     $newRoute = $this->router->getCustomRouteName($currentRoute);
     if ($currentRoute !== $newRoute) {
         $url = $this->router->generate($newRoute, $event->getRequest()->query->getIterator()->getArrayCopy());
         $response = new RedirectResponse($url, 301);
         $event->setResponse($response);
     }
 }
 /**
  * @param string $name
  * @param array $parameters
  * @param bool $relative
  *
  * @return string
  */
 public function getPathLocale($name, $parameters = array(), $relative = false)
 {
     return $this->router->generate($name, $parameters, $relative ? UrlGeneratorInterface::RELATIVE_PATH : UrlGeneratorInterface::ABSOLUTE_PATH);
 }