mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 00:37:52 +00:00
[FEATURE] Added option to change route and get information about current
route through the Request object. - Updated documentation to relfect new changes.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
namespace Pecee\Http;
|
||||
|
||||
use Pecee\SimpleRouter\RouterBase;
|
||||
|
||||
class Request {
|
||||
|
||||
protected static $instance;
|
||||
@@ -10,6 +12,7 @@ class Request {
|
||||
protected $host;
|
||||
protected $method;
|
||||
protected $headers;
|
||||
protected $loadedRoute;
|
||||
|
||||
/**
|
||||
* Return new instance
|
||||
@@ -140,4 +143,12 @@ class Request {
|
||||
return isset($this->data[$name]) ? $this->data[$name] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently loaded route.
|
||||
* @return \Pecee\SimpleRouter\RouterEntry
|
||||
*/
|
||||
public function getLoadedRoute() {
|
||||
return $this->loadedRoute;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -77,6 +77,16 @@ abstract class RouterEntry {
|
||||
return null;
|
||||
}
|
||||
|
||||
public function setMethod($method) {
|
||||
$this->callback = sprintf('%s@%s', $this->getClass(), $method);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setClass($class) {
|
||||
$this->callback = sprintf('%s@%s', $class, $this->getMethod());
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $prefix
|
||||
* @return self
|
||||
|
||||
Reference in New Issue
Block a user