1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
-
- namespace Sensio\Bundle\FrameworkExtraBundle\Routing;
-
- use Symfony\Component\Routing\Loader\AnnotationClassLoader;
- use Symfony\Component\Routing\Route;
- use Sensio\Bundle\FrameworkExtraBundle\Configuration\AnnotationReader as ConfigurationAnnotationReader;
- use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
-
-
-
-
- class AnnotatedRouteControllerLoader extends AnnotationClassLoader
- {
-
-
- protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot)
- {
-
- $classAnnot = $this->reader->getClassAnnotation($class, $this->routeAnnotationClass);
- if ($classAnnot && $service = $classAnnot->getService()) {
- $route->setDefault('_controller', $service.':'.$method->getName());
- } else {
- $route->setDefault('_controller', $class->getName().'::'.$method->getName());
- }
-
-
- foreach ($this->reader->getMethodAnnotations($method) as $configuration) {
- if ($configuration instanceof Method) {
- $route->setRequirement('_method', implode('|', $configuration->getMethods()));
- }
- }
- }
-
-
-
- protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method)
- {
- $routeName = parent::getDefaultRouteName($class, $method);
-
- return preg_replace(array(
- '/(bundle|controller)_/',
- '/action(_\d+)?$/',
- '/__/'
- ), array(
- '_',
- '\\1',
- '_'
- ), $routeName);
- }
- }
|