Skip to content

Commit

Permalink
[Routing] added 'defaults' support in Annotation class loader
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Sep 7, 2010
1 parent 1304940 commit b753ea4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/Symfony/Component/Routing/Annotation/Route.php
Expand Up @@ -22,6 +22,7 @@ class Route
protected $name;
protected $requirements;
protected $options;
protected $defaults;

/**
* Constructor.
Expand All @@ -32,6 +33,7 @@ public function __construct(array $data)
{
$this->requirements = array();
$this->options = array();
$this->defaults = array();

if (isset($data['value'])) {
$data['pattern'] = $data['value'];
Expand Down Expand Up @@ -86,4 +88,14 @@ public function getOptions()
{
return $this->options;
}

public function setDefaults($defaults)
{
$this->defaults = $defaults;
}

public function getDefaults()
{
return $this->defaults;
}
}
Expand Up @@ -87,6 +87,7 @@ class_exists($annotClass = 'Symfony\\Component\\Routing\\Annotation\\Route');
'pattern' => '',
'requirements' => array(),
'options' => array(),
'defaults' => array(),
);

if ($annot = $this->reader->getClassAnnotation($class, $annotClass)) {
Expand All @@ -101,6 +102,10 @@ class_exists($annotClass = 'Symfony\\Component\\Routing\\Annotation\\Route');
if (null !== $annot->getOptions()) {
$globals['options'] = $annot->getOptions();
}

if (null !== $annot->getDefaults()) {
$globals['defaults'] = $annot->getDefaults();
}
}

$this->reader->setDefaultAnnotationNamespace('Symfony\\Component\\Routing\\Annotation\\');
Expand All @@ -111,7 +116,7 @@ class_exists($annotClass = 'Symfony\\Component\\Routing\\Annotation\\Route');
$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());
$options = array_merge($globals['options'], $annot->getOptions());

Expand Down

0 comments on commit b753ea4

Please sign in to comment.