[Routing] added 'defaults' support in Annotation class loader
This commit is contained in:
parent
130494066d
commit
b753ea45b2
@ -22,6 +22,7 @@ class Route
|
|||||||
protected $name;
|
protected $name;
|
||||||
protected $requirements;
|
protected $requirements;
|
||||||
protected $options;
|
protected $options;
|
||||||
|
protected $defaults;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@ -32,6 +33,7 @@ class Route
|
|||||||
{
|
{
|
||||||
$this->requirements = array();
|
$this->requirements = array();
|
||||||
$this->options = array();
|
$this->options = array();
|
||||||
|
$this->defaults = array();
|
||||||
|
|
||||||
if (isset($data['value'])) {
|
if (isset($data['value'])) {
|
||||||
$data['pattern'] = $data['value'];
|
$data['pattern'] = $data['value'];
|
||||||
@ -86,4 +88,14 @@ class Route
|
|||||||
{
|
{
|
||||||
return $this->options;
|
return $this->options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setDefaults($defaults)
|
||||||
|
{
|
||||||
|
$this->defaults = $defaults;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDefaults()
|
||||||
|
{
|
||||||
|
return $this->defaults;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,6 +87,7 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
|||||||
'pattern' => '',
|
'pattern' => '',
|
||||||
'requirements' => array(),
|
'requirements' => array(),
|
||||||
'options' => array(),
|
'options' => array(),
|
||||||
|
'defaults' => array(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($annot = $this->reader->getClassAnnotation($class, $annotClass)) {
|
if ($annot = $this->reader->getClassAnnotation($class, $annotClass)) {
|
||||||
@ -101,6 +102,10 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
|||||||
if (null !== $annot->getOptions()) {
|
if (null !== $annot->getOptions()) {
|
||||||
$globals['options'] = $annot->getOptions();
|
$globals['options'] = $annot->getOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (null !== $annot->getDefaults()) {
|
||||||
|
$globals['defaults'] = $annot->getDefaults();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->reader->setDefaultAnnotationNamespace('Symfony\\Component\\Routing\\Annotation\\');
|
$this->reader->setDefaultAnnotationNamespace('Symfony\\Component\\Routing\\Annotation\\');
|
||||||
@ -111,7 +116,7 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
|||||||
$annot->setName($this->getDefaultRouteName($class, $method));
|
$annot->setName($this->getDefaultRouteName($class, $method));
|
||||||
}
|
}
|
||||||
|
|
||||||
$defaults = $this->getRouteDefaults($class, $method, $annot);
|
$defaults = array_merge($globals['defaults'], $annot->getDefaults(), $this->getRouteDefaults($class, $method, $annot));
|
||||||
$requirements = array_merge($globals['requirements'], $annot->getRequirements());
|
$requirements = array_merge($globals['requirements'], $annot->getRequirements());
|
||||||
$options = array_merge($globals['options'], $annot->getOptions());
|
$options = array_merge($globals['options'], $annot->getOptions());
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user