abstract class AnnotationClassLoader implements LoaderInterface
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()
{
}
}
protected | $reader | ||
protected string | $routeAnnotationClass | ||
protected int | $defaultRouteIndex |
__construct(Reader $reader) | ||
setRouteAnnotationClass(string $class) Sets the annotation class to read route properties from. | ||
load(string $class, string|null $type = null) Loads from annotations from a class. | ||
addRoute(RouteCollection $collection, $annot, $globals, ReflectionClass $class, ReflectionMethod $method) | ||
bool | supports(mixed $resource, string|null $type = null) Returns whether this class supports the given resource. | |
setResolver(LoaderResolverInterface $resolver) Sets the loader resolver. | ||
LoaderResolverInterface | getResolver() Gets the loader resolver. | |
string | getDefaultRouteName(ReflectionClass $class, ReflectionMethod $method) Gets the default route name for a class method. | |
getGlobals(ReflectionClass $class) | ||
createRoute($path, $defaults, $requirements, $options, $host, $schemes, $methods, $condition) | ||
configureRoute(Route $route, ReflectionClass $class, ReflectionMethod $method, $annot) |
Reader | $reader |
Sets the annotation class to read route properties from.
string | $class | A fully-qualified class name |
Loads from annotations from a class.
string | $class | A class name |
string|null | $type | The resource type or null if unknown |
InvalidArgumentException | When route can't be parsed |
RouteCollection | $collection | |
$annot | ||
$globals | ||
ReflectionClass | $class | |
ReflectionMethod | $method |
Returns whether this class supports the given resource.
mixed | $resource | A resource |
string|null | $type | The resource type or null if unknown |
bool | True if this class supports the given resource, false otherwise |
Sets the loader resolver.
LoaderResolverInterface | $resolver |
Gets the loader resolver.
LoaderResolverInterface | A LoaderResolverInterface instance |
Gets the default route name for a class method.
ReflectionClass | $class | |
ReflectionMethod | $method |
string |
ReflectionClass | $class |
$path | ||
$defaults | ||
$requirements | ||
$options | ||
$host | ||
$schemes | ||
$methods | ||
$condition |
Route | $route | |
ReflectionClass | $class | |
ReflectionMethod | $method | |
$annot |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Routing/Loader/AnnotationClassLoader.html