|
1 <?php |
|
2 |
|
3 /* |
|
4 * This file is part of the Symfony framework. |
|
5 * |
|
6 * (c) Fabien Potencier <fabien@symfony.com> |
|
7 * |
|
8 * This source file is subject to the MIT license that is bundled |
|
9 * with this source code in the file LICENSE. |
|
10 */ |
|
11 |
|
12 namespace Symfony\Bridge\Doctrine\Annotations; |
|
13 |
|
14 use Doctrine\Common\Annotations\Reader; |
|
15 |
|
16 /** |
|
17 * Allows the reader to be used in-place of Doctrine's reader. |
|
18 * |
|
19 * This can be removed once the BC layer is in place. |
|
20 * |
|
21 * @author Johannes M. Schmitt <schmittjoh@gmail.com> |
|
22 */ |
|
23 class IndexedReader implements Reader |
|
24 { |
|
25 private $delegate; |
|
26 |
|
27 public function __construct(Reader $reader) |
|
28 { |
|
29 $this->delegate = $reader; |
|
30 } |
|
31 |
|
32 public function getClassAnnotations(\ReflectionClass $class) |
|
33 { |
|
34 $annotations = array(); |
|
35 foreach ($this->delegate->getClassAnnotations($class) as $annot) { |
|
36 $annotations[get_class($annot)] = $annot; |
|
37 } |
|
38 |
|
39 return $annotations; |
|
40 } |
|
41 |
|
42 public function getClassAnnotation(\ReflectionClass $class, $annotation) |
|
43 { |
|
44 return $this->delegate->getClassAnnotation($class, $annotation); |
|
45 } |
|
46 |
|
47 public function getMethodAnnotations(\ReflectionMethod $method) |
|
48 { |
|
49 $annotations = array(); |
|
50 foreach ($this->delegate->getMethodAnnotations($method) as $annot) { |
|
51 $annotations[get_class($annot)] = $annot; |
|
52 } |
|
53 |
|
54 return $annotations; |
|
55 } |
|
56 |
|
57 public function getMethodAnnotation(\ReflectionMethod $method, $annotation) |
|
58 { |
|
59 return $this->delegate->getMethodAnnotation($method, $annotation); |
|
60 } |
|
61 |
|
62 public function getPropertyAnnotations(\ReflectionProperty $property) |
|
63 { |
|
64 $annotations = array(); |
|
65 foreach ($this->delegate->getPropertyAnnotations($property) as $annot) { |
|
66 $annotations[get_class($annot)] = $annot; |
|
67 } |
|
68 |
|
69 return $annotations; |
|
70 } |
|
71 |
|
72 public function getPropertyAnnotation(\ReflectionProperty $property, $annotation) |
|
73 { |
|
74 return $this->delegate->getPropertyAnnotation($property, $annotation); |
|
75 } |
|
76 } |