4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Routing\Annotation
;
15 * Annotation class for @Route().
19 * @author Fabien Potencier <fabien@symfony.com>
25 private $requirements;
35 * @param array $data An array of key/value parameters.
37 * @throws \BadMethodCallException
39 public function __construct(array $data)
41 $this->requirements
= array();
42 $this->options
= array();
43 $this->defaults
= array();
44 $this->methods
= array();
45 $this->schemes
= array();
47 if (isset($data['value'])) {
48 $data['path'] = $data['value'];
49 unset($data['value']);
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)));
57 $this->$method($value);
62 * @deprecated Deprecated in 2.2, to be removed in 3.0. Use setPath instead.
64 public function setPattern($pattern)
66 $this->path
= $pattern;
70 * @deprecated Deprecated in 2.2, to be removed in 3.0. Use getPath instead.
72 public function getPattern()
77 public function setPath($path)
82 public function getPath()
87 public function setHost($pattern)
89 $this->host
= $pattern;
92 public function getHost()
97 public function setName($name)
102 public function getName()
107 public function setRequirements($requirements)
109 $this->requirements
= $requirements;
112 public function getRequirements()
114 return $this->requirements
;
117 public function setOptions($options)
119 $this->options
= $options;
122 public function getOptions()
124 return $this->options
;
127 public function setDefaults($defaults)
129 $this->defaults
= $defaults;
132 public function getDefaults()
134 return $this->defaults
;
137 public function setSchemes($schemes)
139 $this->schemes
= is_array($schemes) ? $schemes : array($schemes);
142 public function getSchemes()
144 return $this->schemes
;
147 public function setMethods($methods)
149 $this->methods
= is_array($methods) ? $methods : array($methods);
152 public function getMethods()
154 return $this->methods
;