Files
lgp-admin-plus-api/laravel/routing/route.php

77 lines
1.3 KiB
PHP
Raw Normal View History

2011-08-18 19:56:29 -05:00
<?php namespace Laravel\Routing;
2011-06-08 23:45:08 -05:00
class Route {
/**
* 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
*/
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.
*
* @param string $key
* @param mixed $callback
* @param array $parameters
2011-06-08 23:45:08 -05:00
* @return void
*/
public function __construct($key, $callback, $parameters = array())
2011-06-08 23:45:08 -05:00
{
$this->key = $key;
$this->callback = $callback;
2011-06-08 23:45:08 -05:00
$this->parameters = $parameters;
}
/**
* Get all of the "before" filters defined for the route.
2011-06-08 23:45:08 -05:00
*
* @return array
2011-06-08 23:45:08 -05:00
*/
public function before()
2011-06-08 23:45:08 -05:00
{
return $this->filters('before');
}
2011-06-08 23:45:08 -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
}
/**
* Get an array of filters defined for the route.
*
* <code>
* // Get all of the "before" filters defined for the route.
* $filters = $route->filters('before');
* </code>
2011-08-05 09:20:26 -05:00
*
* @param string $name
* @return array
*/
private function filters($name)
{
return (is_array($this->callback) and isset($this->callback[$name])) ? explode(', ', $this->callback[$name]) : array();
}
2011-06-08 23:45:08 -05:00
}