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().
18 * @Target({"CLASS", "METHOD"})
20 * @author Fabien Potencier <fabien@symfony.com>
26 private $requirements = array();
27 private $options = array();
28 private $defaults = array();
30 private $methods = array();
31 private $schemes = array();
35 * @param array $data An array of key/value parameters
37 * @throws \BadMethodCallException
39 public function __construct(array $data)
41 if (isset($data['value'])) {
42 $data['path'] = $data['value'];
43 unset($data['value']);
46 foreach ($data as $key => $value) {
47 $method = 'set'.str_replace('_', '', $key);
48 if (!method_exists($this, $method)) {
49 throw new \BadMethodCallException(sprintf('Unknown property "%s" on annotation "%s".', $key, get_class($this)));
51 $this->$method($value);
55 public function setPath($path)
60 public function getPath()
65 public function setHost($pattern)
67 $this->host = $pattern;
70 public function getHost()
75 public function setName($name)
80 public function getName()
85 public function setRequirements($requirements)
87 $this->requirements = $requirements;
90 public function getRequirements()
92 return $this->requirements;
95 public function setOptions($options)
97 $this->options = $options;
100 public function getOptions()
102 return $this->options;
105 public function setDefaults($defaults)
107 $this->defaults = $defaults;
110 public function getDefaults()
112 return $this->defaults;
115 public function setSchemes($schemes)
117 $this->schemes = is_array($schemes) ? $schemes : array($schemes);
120 public function getSchemes()
122 return $this->schemes;
125 public function setMethods($methods)
127 $this->methods = is_array($methods) ? $methods : array($methods);
130 public function getMethods()
132 return $this->methods;
135 public function setCondition($condition)
137 $this->condition = $condition;
140 public function getCondition()
142 return $this->condition;