2011-08-18 19:56:29 -05:00
|
|
|
<?php namespace Laravel\Routing;
|
2011-07-31 14:48:17 -05:00
|
|
|
|
2011-06-08 23:45:08 -05:00
|
|
|
class Route {
|
|
|
|
|
|
2011-06-18 12:00:52 -05:00
|
|
|
/**
|
|
|
|
|
* The route key, including request method and URI.
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
public $key;
|
|
|
|
|
|
2011-06-08 23:45:08 -05:00
|
|
|
/**
|
|
|
|
|
* The route callback or array.
|
|
|
|
|
*
|
|
|
|
|
* @var mixed
|
|
|
|
|
*/
|
2011-06-18 12:00:52 -05:00
|
|
|
public $callback;
|
2011-06-08 23:45:08 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The parameters that will passed to the route function.
|
|
|
|
|
*
|
|
|
|
|
* @var array
|
|
|
|
|
*/
|
|
|
|
|
public $parameters;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new Route instance.
|
|
|
|
|
*
|
2011-06-18 12:00:52 -05:00
|
|
|
* @param string $key
|
|
|
|
|
* @param mixed $callback
|
|
|
|
|
* @param array $parameters
|
2011-06-08 23:45:08 -05:00
|
|
|
* @return void
|
|
|
|
|
*/
|
2011-06-18 12:00:52 -05:00
|
|
|
public function __construct($key, $callback, $parameters = array())
|
2011-06-08 23:45:08 -05:00
|
|
|
{
|
2011-06-18 12:00:52 -05:00
|
|
|
$this->key = $key;
|
|
|
|
|
$this->callback = $callback;
|
2011-06-08 23:45:08 -05:00
|
|
|
$this->parameters = $parameters;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2011-08-25 22:53:05 -05:00
|
|
|
* Get all of the "before" filters defined for the route.
|
2011-06-08 23:45:08 -05:00
|
|
|
*
|
2011-08-25 22:53:05 -05:00
|
|
|
* @return array
|
2011-06-08 23:45:08 -05:00
|
|
|
*/
|
2011-08-25 22:53:05 -05:00
|
|
|
public function before()
|
2011-06-08 23:45:08 -05:00
|
|
|
{
|
2011-08-25 22:53:05 -05:00
|
|
|
return $this->filters('before');
|
|
|
|
|
}
|
2011-06-08 23:45:08 -05:00
|
|
|
|
2011-08-25 22:53:05 -05:00
|
|
|
/**
|
|
|
|
|
* Get all of the "after" filters defined for the route.
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function after()
|
|
|
|
|
{
|
|
|
|
|
return $this->filters('after');
|
2011-06-08 23:45:08 -05:00
|
|
|
}
|
|
|
|
|
|
2011-08-05 09:18:40 -05:00
|
|
|
/**
|
2011-08-25 22:53:05 -05:00
|
|
|
* Get an array of filters defined for the route.
|
2011-08-05 09:18:40 -05:00
|
|
|
*
|
2011-08-25 22:53:05 -05:00
|
|
|
* <code>
|
|
|
|
|
* // Get all of the "before" filters defined for the route.
|
|
|
|
|
* $filters = $route->filters('before');
|
|
|
|
|
* </code>
|
2011-08-05 09:20:26 -05:00
|
|
|
*
|
2011-08-25 22:53:05 -05:00
|
|
|
* @param string $name
|
|
|
|
|
* @return array
|
2011-08-05 09:18:40 -05:00
|
|
|
*/
|
2011-08-25 22:53:05 -05:00
|
|
|
private function filters($name)
|
2011-08-05 09:18:40 -05:00
|
|
|
{
|
2011-08-25 22:53:05 -05:00
|
|
|
return (is_array($this->callback) and isset($this->callback[$name])) ? explode(', ', $this->callback[$name]) : array();
|
2011-08-05 09:18:40 -05:00
|
|
|
}
|
|
|
|
|
|
2011-06-08 23:45:08 -05:00
|
|
|
}
|