|
1 <?php |
|
2 |
|
3 /* |
|
4 * This file is part of the Symfony package. |
|
5 * |
|
6 * (c) Fabien Potencier <fabien@symfony.com> |
|
7 * |
|
8 * For the full copyright and license information, please view the LICENSE |
|
9 * file that was distributed with this source code. |
|
10 */ |
|
11 |
|
12 namespace Symfony\Component\Routing\Annotation; |
|
13 |
|
14 /** |
|
15 * Annotation class for @Route(). |
|
16 * |
|
17 * @Annotation |
|
18 * @author Fabien Potencier <fabien@symfony.com> |
|
19 */ |
|
20 class Route |
|
21 { |
|
22 private $pattern; |
|
23 private $name; |
|
24 private $requirements; |
|
25 private $options; |
|
26 private $defaults; |
|
27 |
|
28 /** |
|
29 * Constructor. |
|
30 * |
|
31 * @param array $data An array of key/value parameters. |
|
32 */ |
|
33 public function __construct(array $data) |
|
34 { |
|
35 $this->requirements = array(); |
|
36 $this->options = array(); |
|
37 $this->defaults = array(); |
|
38 |
|
39 if (isset($data['value'])) { |
|
40 $data['pattern'] = $data['value']; |
|
41 unset($data['value']); |
|
42 } |
|
43 |
|
44 foreach ($data as $key => $value) { |
|
45 $method = 'set'.$key; |
|
46 if (!method_exists($this, $method)) { |
|
47 throw new \BadMethodCallException(sprintf("Unknown property '%s' on annotation '%s'.", $key, get_class($this))); |
|
48 } |
|
49 $this->$method($value); |
|
50 } |
|
51 } |
|
52 |
|
53 public function setPattern($pattern) |
|
54 { |
|
55 $this->pattern = $pattern; |
|
56 } |
|
57 |
|
58 public function getPattern() |
|
59 { |
|
60 return $this->pattern; |
|
61 } |
|
62 |
|
63 public function setName($name) |
|
64 { |
|
65 $this->name = $name; |
|
66 } |
|
67 |
|
68 public function getName() |
|
69 { |
|
70 return $this->name; |
|
71 } |
|
72 |
|
73 public function setRequirements($requirements) |
|
74 { |
|
75 $this->requirements = $requirements; |
|
76 } |
|
77 |
|
78 public function getRequirements() |
|
79 { |
|
80 return $this->requirements; |
|
81 } |
|
82 |
|
83 public function setOptions($options) |
|
84 { |
|
85 $this->options = $options; |
|
86 } |
|
87 |
|
88 public function getOptions() |
|
89 { |
|
90 return $this->options; |
|
91 } |
|
92 |
|
93 public function setDefaults($defaults) |
|
94 { |
|
95 $this->defaults = $defaults; |
|
96 } |
|
97 |
|
98 public function getDefaults() |
|
99 { |
|
100 return $this->defaults; |
|
101 } |
|
102 } |