[Routing] updated to changes

This commit is contained in:
Johannes Schmitt 2011-04-29 17:44:56 +02:00
parent 7e26575bbd
commit 73b92db612
2 changed files with 2 additions and 61 deletions

View File

@ -1,46 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Routing\Annotation;
/**
* Annotation class for @Routes().
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class Routes
{
private $routes;
/**
* Constructor.
*
* @param array $data An array of key/value parameters.
*/
public function __construct(array $data)
{
if (!isset($data['value']) || !is_array($data['value'])) {
throw new \LogicException('A @Routes annotation must have an array of @Route annotation as argument.');
}
$this->routes = $data['value'];
}
public function setRoutes($routes)
{
$this->routes = $routes;
}
public function getRoutes()
{
return $this->routes;
}
}

View File

@ -59,7 +59,6 @@ abstract class AnnotationClassLoader implements LoaderInterface
{
protected $reader;
protected $routeAnnotationClass = 'Symfony\\Component\\Routing\\Annotation\\Route';
protected $routesAnnotationClass = 'Symfony\\Component\\Routing\\Annotation\\Routes';
/**
* Constructor.
@ -81,16 +80,6 @@ abstract class AnnotationClassLoader implements LoaderInterface
$this->routeAnnotationClass = $class;
}
/**
* Sets the annotation class to read routes properties from.
*
* @param string $class A fully-qualified class name
*/
public function setRoutesAnnotationClass($class)
{
$this->routesAnnotationClass = $class;
}
/**
* Loads from annotations from a class.
*
@ -137,12 +126,10 @@ abstract class AnnotationClassLoader implements LoaderInterface
$collection->addResource(new FileResource($class->getFileName()));
foreach ($class->getMethods() as $method) {
if ($annots = $this->reader->getMethodAnnotation($method, $this->routesAnnotationClass)) {
foreach ($annots->getRoutes() as $annot) {
foreach ($this->reader->getMethodAnnotations($method) as $annot) {
if ($annot instanceof $this->routeAnnotationClass) {
$this->addRoute($collection, $annot, $globals, $class, $method);
}
} elseif ($annot = $this->reader->getMethodAnnotation($method, $this->routeAnnotationClass)) {
$this->addRoute($collection, $annot, $globals, $class, $method);
}
}