Moved regex/match functionality to LoadableRoute.

This commit is contained in:
Simon Sessingø
2016-11-28 04:45:46 +01:00
parent b694a7c0c9
commit 5c89ae2aaf
4 changed files with 41 additions and 40 deletions
+26 -1
View File
@@ -8,7 +8,7 @@ use Pecee\SimpleRouter\Exceptions\HttpException;
abstract class LoadableRoute extends Route implements ILoadableRoute
{
/**
* @var
* @var string
*/
protected $url;
@@ -17,6 +17,8 @@ abstract class LoadableRoute extends Route implements ILoadableRoute
*/
protected $name;
protected $regex;
/**
* Loads and renders middlewares-classes
*
@@ -171,6 +173,29 @@ abstract class LoadableRoute extends Route implements ILoadableRoute
return (strtolower($this->name) === strtolower($name));
}
/**
* Add regular expression match for the entire route.
*
* @param string $regex
* @return static
*/
public function setMatch($regex)
{
$this->regex = $regex;
return $this;
}
/**
* Get regular expression match used for matching route (if defined).
*
* @return string
*/
public function getMatch()
{
return $this->regex;
}
/**
* Sets the router name, which makes it easier to obtain the url or router at a later point.
* Alias for LoadableRoute::setName().