Skip to content

Commit

Permalink
[Routing] removed call to setDefaultAnnotationNamespace() so this can…
Browse files Browse the repository at this point in the history
… be configure on the injected reader
  • Loading branch information
kriswallsmith authored and fabpot committed Dec 22, 2010
1 parent 8a472b7 commit 32aef96
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php
Expand Up @@ -56,6 +56,7 @@
abstract class AnnotationClassLoader implements LoaderInterface
{
protected $reader;
protected $annotationClass = 'Symfony\\Component\\Routing\\Annotation\\Route';

/**
* Constructor.
Expand All @@ -67,6 +68,16 @@ public function __construct(AnnotationReader $reader)
$this->reader = $reader;
}

/**
* Sets the annotation class to read route properties from.
*
* @param string $annotationClass A fully-qualified class name
*/
public function setAnnotationClass($annotationClass)
{
$this->annotationClass = $annotationClass;
}

/**
* Loads from annotations from a class.
*
Expand All @@ -83,17 +94,15 @@ public function load($class, $type = null)
throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
}

$class = new \ReflectionClass($class);
$annotClass = 'Symfony\\Component\\Routing\\Annotation\\Route';

$globals = array(
'pattern' => '',
'requirements' => array(),
'options' => array(),
'defaults' => array(),
);

if ($annot = $this->reader->getClassAnnotation($class, $annotClass)) {
$class = new \ReflectionClass($class);
if ($annot = $this->reader->getClassAnnotation($class, $this->annotationClass)) {
if (null !== $annot->getPattern()) {
$globals['pattern'] = $annot->getPattern();
}
Expand All @@ -111,10 +120,9 @@ public function load($class, $type = null)
}
}

$this->reader->setDefaultAnnotationNamespace('Symfony\\Component\\Routing\\Annotation\\');
$collection = new RouteCollection();
foreach ($class->getMethods() as $method) {
if ($annot = $this->reader->getMethodAnnotation($method, $annotClass)) {
if ($annot = $this->reader->getMethodAnnotation($method, $this->annotationClass)) {
if (null === $annot->getName()) {
$annot->setName($this->getDefaultRouteName($class, $method));
}
Expand Down

0 comments on commit 32aef96

Please sign in to comment.