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();
37 * @param array $data An array of key/value parameters
39 * @throws \BadMethodCallException
41 public function __construct(array $data)
43 if (isset($data['value'])) {
44 $data['path'] = $data['value'];
45 unset($data['value']);
48 foreach ($data as $key => $value) {
49 $method = 'set'.str_replace('_', '', $key);
50 if (!method_exists($this, $method)) {
51 throw new \BadMethodCallException(sprintf('Unknown property "%s" on annotation "%s".', $key, get_class($this)));
53 $this->$method($value);
57 public function setPath($path)
62 public function getPath()
67 public function setHost($pattern)
69 $this->host = $pattern;
72 public function getHost()
77 public function setName($name)
82 public function getName()
87 public function setRequirements($requirements)
89 $this->requirements = $requirements;
92 public function getRequirements()
94 return $this->requirements;
97 public function setOptions($options)
99 $this->options = $options;
102 public function getOptions()
104 return $this->options;
107 public function setDefaults($defaults)
109 $this->defaults = $defaults;
112 public function getDefaults()
114 return $this->defaults;
117 public function setSchemes($schemes)
119 $this->schemes = is_array($schemes) ? $schemes : array($schemes);
122 public function getSchemes()
124 return $this->schemes;
127 public function setMethods($methods)
129 $this->methods = is_array($methods) ? $methods : array($methods);
132 public function getMethods()
134 return $this->methods;
137 public function setCondition($condition)
139 $this->condition = $condition;
142 public function getCondition()
144 return $this->condition;