]> git.immae.eu Git - github/wallabag/wallabag.git/blob - vendor/symfony/routing/Symfony/Component/Routing/Annotation/Route.php
abdbea27c69968631332b639f5dcc25b9b6bed69
[github/wallabag/wallabag.git] / vendor / symfony / routing / Symfony / Component / Routing / Annotation / Route.php
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 *
19 * @author Fabien Potencier <fabien@symfony.com>
20 */
21 class Route
22 {
23 private $path;
24 private $name;
25 private $requirements;
26 private $options;
27 private $defaults;
28 private $host;
29 private $methods;
30 private $schemes;
31
32 /**
33 * Constructor.
34 *
35 * @param array $data An array of key/value parameters.
36 *
37 * @throws \BadMethodCallException
38 */
39 public function __construct(array $data)
40 {
41 $this->requirements = array();
42 $this->options = array();
43 $this->defaults = array();
44 $this->methods = array();
45 $this->schemes = array();
46
47 if (isset($data['value'])) {
48 $data['path'] = $data['value'];
49 unset($data['value']);
50 }
51
52 foreach ($data as $key => $value) {
53 $method = 'set'.str_replace('_', '', $key);
54 if (!method_exists($this, $method)) {
55 throw new \BadMethodCallException(sprintf("Unknown property '%s' on annotation '%s'.", $key, get_class($this)));
56 }
57 $this->$method($value);
58 }
59 }
60
61 /**
62 * @deprecated Deprecated in 2.2, to be removed in 3.0. Use setPath instead.
63 */
64 public function setPattern($pattern)
65 {
66 $this->path = $pattern;
67 }
68
69 /**
70 * @deprecated Deprecated in 2.2, to be removed in 3.0. Use getPath instead.
71 */
72 public function getPattern()
73 {
74 return $this->path;
75 }
76
77 public function setPath($path)
78 {
79 $this->path = $path;
80 }
81
82 public function getPath()
83 {
84 return $this->path;
85 }
86
87 public function setHost($pattern)
88 {
89 $this->host = $pattern;
90 }
91
92 public function getHost()
93 {
94 return $this->host;
95 }
96
97 public function setName($name)
98 {
99 $this->name = $name;
100 }
101
102 public function getName()
103 {
104 return $this->name;
105 }
106
107 public function setRequirements($requirements)
108 {
109 $this->requirements = $requirements;
110 }
111
112 public function getRequirements()
113 {
114 return $this->requirements;
115 }
116
117 public function setOptions($options)
118 {
119 $this->options = $options;
120 }
121
122 public function getOptions()
123 {
124 return $this->options;
125 }
126
127 public function setDefaults($defaults)
128 {
129 $this->defaults = $defaults;
130 }
131
132 public function getDefaults()
133 {
134 return $this->defaults;
135 }
136
137 public function setSchemes($schemes)
138 {
139 $this->schemes = is_array($schemes) ? $schemes : array($schemes);
140 }
141
142 public function getSchemes()
143 {
144 return $this->schemes;
145 }
146
147 public function setMethods($methods)
148 {
149 $this->methods = is_array($methods) ? $methods : array($methods);
150 }
151
152 public function getMethods()
153 {
154 return $this->methods;
155 }
156 }