mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-07-11 22:22:16 +00:00
Moved regex/match functionality to LoadableRoute.
This commit is contained in:
@@ -51,4 +51,19 @@ interface ILoadableRoute extends IRoute
|
|||||||
*/
|
*/
|
||||||
public function setName($name);
|
public function setName($name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get regular expression match used for matching route (if defined).
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getMatch();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add regular expression match for the entire route.
|
||||||
|
*
|
||||||
|
* @param string $regex
|
||||||
|
* @return static
|
||||||
|
*/
|
||||||
|
public function setMatch($regex);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -113,21 +113,6 @@ interface IRoute
|
|||||||
|
|
||||||
public function getDefaultNamespace();
|
public function getDefaultNamespace();
|
||||||
|
|
||||||
/**
|
|
||||||
* Get regular expression match used for matching route (if defined).
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getMatch();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add regular expression match for the entire route.
|
|
||||||
*
|
|
||||||
* @param string $regex
|
|
||||||
* @return static
|
|
||||||
*/
|
|
||||||
public function setMatch($regex);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get parameter names.
|
* Get parameter names.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use Pecee\SimpleRouter\Exceptions\HttpException;
|
|||||||
abstract class LoadableRoute extends Route implements ILoadableRoute
|
abstract class LoadableRoute extends Route implements ILoadableRoute
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $url;
|
protected $url;
|
||||||
|
|
||||||
@@ -17,6 +17,8 @@ abstract class LoadableRoute extends Route implements ILoadableRoute
|
|||||||
*/
|
*/
|
||||||
protected $name;
|
protected $name;
|
||||||
|
|
||||||
|
protected $regex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads and renders middlewares-classes
|
* Loads and renders middlewares-classes
|
||||||
*
|
*
|
||||||
@@ -171,6 +173,29 @@ abstract class LoadableRoute extends Route implements ILoadableRoute
|
|||||||
return (strtolower($this->name) === strtolower($name));
|
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.
|
* Sets the router name, which makes it easier to obtain the url or router at a later point.
|
||||||
* Alias for LoadableRoute::setName().
|
* Alias for LoadableRoute::setName().
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ abstract class Route implements IRoute
|
|||||||
|
|
||||||
/* Default options */
|
/* Default options */
|
||||||
protected $namespace;
|
protected $namespace;
|
||||||
protected $regex;
|
|
||||||
protected $requestMethods = [];
|
protected $requestMethods = [];
|
||||||
protected $where = [];
|
protected $where = [];
|
||||||
protected $parameters = [];
|
protected $parameters = [];
|
||||||
@@ -313,29 +312,6 @@ abstract class Route implements IRoute
|
|||||||
return ($this->namespace === null) ? $this->defaultNamespace : $this->namespace;
|
return ($this->namespace === null) ? $this->defaultNamespace : $this->namespace;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Export route settings to array so they can be merged with another route.
|
* Export route settings to array so they can be merged with another route.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user