/**
  * @param string $routeName
  * @param array   $parameters
  *
  * @return string
  */
 public function getToken($routeName, array $parameters = [])
 {
     $route = $this->csrfRouter->getRouteCollection()->get($routeName);
     if (null !== $route) {
         $this->csrfTokenManager->updateRoute($route, $routeName, $parameters);
         return isset($parameters['_token']) && !empty($parameters['_token']) ? $parameters['_token'] : '';
     }
     return '';
 }
 /**
  * @param FilterControllerEvent $event
  */
 public function onKernelController(FilterControllerEvent $event)
 {
     $request = $event->getRequest();
     // Get route name
     $routeName = $request->attributes->get('_route');
     if (!$routeName) {
         return;
     }
     // Get route
     $route = $this->getRoute($routeName);
     if (null === $route) {
         return;
     }
     // Validate route
     $this->tokenManager->validateRoute($route, $routeName, $request);
 }
 /**
  * @param string $name
  * @param array $parameters
  * @param bool|string $referenceType
  * @return string
  */
 public function generate($name, $parameters = [], $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH)
 {
     // Add Csrf token if required
     if ($this->enabled) {
         $route = $this->getRouteCollection()->get($name);
         if (null !== $route) {
             // Apply token if required
             $this->tokenManager->updateRoute($route, $name, $parameters);
         }
     }
     if (null !== $this->parent) {
         return $this->parent->generate($name, $parameters, $referenceType);
     }
     return parent::generate($name, $parameters, $referenceType);
 }