Преглед изворни кода

[Routing] updated to changes

Johannes Schmitt пре 14 година
родитељ
комит
73b92db612

+ 0 - 46
src/Symfony/Component/Routing/Annotation/Routes.php

@@ -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;
-    }
-}

+ 2 - 15
src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php

@@ -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);
             }
         }