/**
  * For all route annotations using FOM\ManagerBundle\Configuration\Route, this adds the configured prefix.
  *
  * @inheritdoc
  */
 protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot)
 {
     parent::configureRoute($route, $class, $method, $annot);
     if (is_a($annot, 'FOM\\ManagerBundle\\Configuration\\Route')) {
         $route->setPattern($this->prefix . $route->getPattern());
     }
 }
Пример #2
0
 /**
  * Configures the CSRF token options
  *
  * @param Route             $route  A route instance
  * @param \ReflectionClass  $class  A ReflectionClass instance
  * @param \ReflectionMethod $method A ReflectionClass method
  * @param mixed             $annot  The annotation class instance
  *
  * @throws \LogicException When the service option is specified on a method
  */
 protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot)
 {
     parent::configureRoute($route, $class, $method, $annot);
     /** @var \Fantoine\CsrfRouteBundle\Annotation\CsrfToken */
     $annotation = $this->reader->getMethodAnnotation($method, '\\Fantoine\\CsrfRouteBundle\\Annotation\\CsrfToken');
     if (null !== $annotation) {
         // Store the CsrfToken options on Route options
         $route->setOption(CsrfTokenManager::OPTION_NAME, $annotation->toOption());
     }
 }
 /**
  * Configures the _controller default parameter and eventually the _method
  * requirement of a given Route instance.
  *
  * @param Route $route A Route instance
  * @param ReflectionClass $class A ReflectionClass instance
  * @param ReflectionMethod $method A ReflectionClass method
  */
 protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot)
 {
     parent::configureRoute($route, $class, $method, $annot);
     // Symfony 2.1.x
     if (!method_exists($route, 'getPath')) {
         $pattern = $route->getPattern();
         if (!empty($pattern) && '/' === $pattern[0] && (isset($pattern[1]) && '.' === $pattern[1] || isset($pattern[1]))) {
             $r = new \ReflectionProperty('Symfony\\Component\\Routing\\Route', 'pattern');
             $r->setAccessible(true);
             $r->setValue($route, substr($pattern, 1));
         }
     } else {
         $path = $route->getPath();
         if (!empty($path) && '/' === $path[0] && (isset($path[1]) && '.' === $path[1] || !isset($path[1]))) {
             $r = new \ReflectionProperty('Symfony\\Component\\Routing\\Route', 'path');
             $r->setAccessible(true);
             $r->setValue($route, substr($path, 1));
         }
     }
 }