abstract class AnnotationClassLoader

AnnotationClassLoader loads routing information from a PHP class and its methods.

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 path. The annotation also recognizes several parameters: requirements, options, defaults, schemes, methods, host, 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() { } }

@author Fabien Potencier <fabien@symfony.com>

Hierarchy

  • class \Symfony\Component\Routing\Loader\AnnotationClassLoader implements \Symfony\Component\Config\Loader\LoaderInterface

Expanded class hierarchy of AnnotationClassLoader

File

drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Loader/AnnotationClassLoader.php, line 58

Namespace

Symfony\Component\Routing\Loader
View source

Members

Namesort descending Modifiers Type Description Overrides
AnnotationClassLoader::$defaultRouteIndex protected property
AnnotationClassLoader::$reader protected property
AnnotationClassLoader::$routeAnnotationClass protected property
AnnotationClassLoader::addRoute protected function
AnnotationClassLoader::configureRoute abstract protected function
AnnotationClassLoader::getDefaultRouteName protected function Gets the default route name for a class method.
AnnotationClassLoader::getResolver public function
AnnotationClassLoader::load public function Loads from annotations from a class.
AnnotationClassLoader::setResolver public function
AnnotationClassLoader::setRouteAnnotationClass public function Sets the annotation class to read route properties from.
AnnotationClassLoader::supports public function
AnnotationClassLoader::__construct public function Constructor.