You need to define an implementation for the getRouteDefaults() method. Most of the
time, this method should define some PHP callable to be called for the route
(a controller in MVC speak).
The @Route annotation can be set on the class (for global parameters),
and on each method.
The @Route annotation main value is the route pattern. The annotation also
recognizes three parameters: requirements, options, and name. The name parameter
is mandatory. Here is an example of how you should be able to use it:
**
* @Route("/Blog")
* /
class Blog
{
**
* @Route("/", name="blog_index")
* /
public function index()
{
}
**
* @Route("/:id", name="blog_post", requirements = {"id" = "\d+"})
* /
public function show()
{
}
}
/** * {@inheritdoc} */ protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method) { $routeName = parent::getDefaultRouteName($class, $method); return preg_replace(['/(bundle|controller)_/', '/action(_\\d+)?$/', '/__/'], ['_', '\\1', '_'], $routeName); }
/** * Makes the default route name more sane by removing common keywords. * * @param ReflectionClass $class A ReflectionClass instance * @param ReflectionMethod $method A ReflectionMethod instance * @return string */ public function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method) { $routeName = parent::getDefaultRouteName($class, $method); return str_replace(array('bundle', 'controller', 'action', '__'), array(null, null, null, '_'), $routeName); }
/** * Makes the default route name more sane by removing common keywords. * * @param \ReflectionClass $class A ReflectionClass instance * @param \ReflectionMethod $method A ReflectionMethod instance * @return string */ protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method) { $routeName = parent::getDefaultRouteName($class, $method); return preg_replace(array('/(module_|controller_?)/', '/__/'), array('_', '_'), $routeName); }
/** * Makes the default route name more sane by removing common keywords. * * @param ReflectionClass $class A ReflectionClass instance * @param ReflectionMethod $method A ReflectionMethod instance * @return string */ public function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method) { $routeName = parent::getDefaultRouteName($class, $method); return preg_replace(array('/(bundle|controller)_/', '/action$/', '/__/'), array('_', null, '_'), $routeName); }
public function __construct(AnnotationReader $reader, ConfigurationAnnotationReader $configReader) { $this->configReader = $configReader; parent::__construct($reader); }
/** * Makes the default route name more sane by removing common keywords. * * @param \ReflectionClass $class A ReflectionClass instance * @param \ReflectionMethod $method A ReflectionMethod instance * * @return string The default route name */ protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method) { return preg_replace(array('/(_controller|controller)/', '/action/', '/__/'), array('_', '', '_'), parent::getDefaultRouteName($class, $method)); }