2015-08-17 17:00:26 -07:00
< ? php
/*
* This file is part of the Symfony package .
*
* ( c ) Fabien Potencier < fabien @ symfony . com >
*
* For the full copyright and license information , please view the LICENSE
* file that was distributed with this source code .
*/
namespace Symfony\Component\Routing\Annotation ;
/**
* Annotation class for @ Route () .
*
* @ Annotation
* @ Target ({ " CLASS " , " METHOD " })
*
* @ author Fabien Potencier < fabien @ symfony . com >
*/
class Route
{
private $path ;
private $name ;
private $requirements = array ();
private $options = array ();
private $defaults = array ();
private $host ;
private $methods = array ();
private $schemes = array ();
private $condition ;
/**
2017-02-02 16:28:38 -08:00
* @ param array $data An array of key / value parameters
2015-08-17 17:00:26 -07:00
*
* @ throws \BadMethodCallException
*/
public function __construct ( array $data )
{
if ( isset ( $data [ 'value' ])) {
$data [ 'path' ] = $data [ 'value' ];
unset ( $data [ 'value' ]);
}
foreach ( $data as $key => $value ) {
$method = 'set' . str_replace ( '_' , '' , $key );
if ( ! method_exists ( $this , $method )) {
2018-11-23 12:29:20 +00:00
throw new \BadMethodCallException ( sprintf ( 'Unknown property "%s" on annotation "%s".' , $key , \get_class ( $this )));
2015-08-17 17:00:26 -07:00
}
$this -> $method ( $value );
}
}
public function setPath ( $path )
{
$this -> path = $path ;
}
public function getPath ()
{
return $this -> path ;
}
public function setHost ( $pattern )
{
$this -> host = $pattern ;
}
public function getHost ()
{
return $this -> host ;
}
public function setName ( $name )
{
$this -> name = $name ;
}
public function getName ()
{
return $this -> name ;
}
public function setRequirements ( $requirements )
{
$this -> requirements = $requirements ;
}
public function getRequirements ()
{
return $this -> requirements ;
}
public function setOptions ( $options )
{
$this -> options = $options ;
}
public function getOptions ()
{
return $this -> options ;
}
public function setDefaults ( $defaults )
{
$this -> defaults = $defaults ;
}
public function getDefaults ()
{
return $this -> defaults ;
}
public function setSchemes ( $schemes )
{
2018-11-23 12:29:20 +00:00
$this -> schemes = \is_array ( $schemes ) ? $schemes : array ( $schemes );
2015-08-17 17:00:26 -07:00
}
public function getSchemes ()
{
return $this -> schemes ;
}
public function setMethods ( $methods )
{
2018-11-23 12:29:20 +00:00
$this -> methods = \is_array ( $methods ) ? $methods : array ( $methods );
2015-08-17 17:00:26 -07:00
}
public function getMethods ()
{
return $this -> methods ;
}
public function setCondition ( $condition )
{
$this -> condition = $condition ;
}
public function getCondition ()
{
return $this -> condition ;
}
}