Implementing middlewares 0.5
This commit is contained in:
@@ -139,6 +139,7 @@ class Route{
|
|||||||
|
|
||||||
//=======================================================
|
//=======================================================
|
||||||
function execute(){
|
function execute(){
|
||||||
|
|
||||||
foreach ($this->_before as $key => $before){
|
foreach ($this->_before as $key => $before){
|
||||||
if(!in_array($key, $this->_middlewares_to_ignore) ){
|
if(!in_array($key, $this->_middlewares_to_ignore) ){
|
||||||
call_user_func($before);
|
call_user_func($before);
|
||||||
@@ -209,7 +210,7 @@ class Route{
|
|||||||
}
|
}
|
||||||
|
|
||||||
function middleware_ignore($name = ''){
|
function middleware_ignore($name = ''){
|
||||||
$this->_middlewares_to_ignore[$name];
|
$this->_middlewares_to_ignore[] = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
function middleware_add($name = '', $function){
|
function middleware_add($name = '', $function){
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class RouteCollection{
|
|||||||
$verb = "CLI";
|
$verb = "CLI";
|
||||||
}else{
|
}else{
|
||||||
$verb = strtoupper( $_SERVER['REQUEST_METHOD'] );
|
$verb = strtoupper( $_SERVER['REQUEST_METHOD'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
if(in_array($verb, self::$_verbs_whitelist)){
|
if(in_array($verb, self::$_verbs_whitelist)){
|
||||||
$this->_verb = $verb;
|
$this->_verb = $verb;
|
||||||
|
|||||||
Reference in New Issue
Block a user