Laravel injection v1 #5
This commit is contained in:
+27
-8
@@ -1,14 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace BBRouter;
|
||||
|
||||
/**
|
||||
* ROTA
|
||||
/*
|
||||
*
|
||||
*/
|
||||
class Route{
|
||||
|
||||
class Route {
|
||||
/*
|
||||
* HTTP VERB
|
||||
*/
|
||||
|
||||
public $_verb = Array();
|
||||
/*
|
||||
* Execution Source
|
||||
@@ -88,7 +90,6 @@ class Route{
|
||||
// Informational 1xx
|
||||
100 => 'Continue',
|
||||
101 => 'Switching Protocols',
|
||||
|
||||
// Successful 2xx
|
||||
200 => 'OK',
|
||||
201 => 'Created',
|
||||
@@ -97,7 +98,6 @@ class Route{
|
||||
204 => 'No Content',
|
||||
205 => 'Reset Content',
|
||||
206 => 'Partial Content',
|
||||
|
||||
// Redirection 3xx
|
||||
300 => 'Multiple Choices',
|
||||
301 => 'Moved Permanently',
|
||||
@@ -107,7 +107,6 @@ class Route{
|
||||
305 => 'Use Proxy',
|
||||
306 => '(Unused)',
|
||||
307 => 'Temporary Redirect',
|
||||
|
||||
// Client Error 4xx
|
||||
400 => 'Bad Request',
|
||||
401 => 'Unauthorized',
|
||||
@@ -127,7 +126,6 @@ class Route{
|
||||
415 => 'Unsupported Media Type',
|
||||
416 => 'Requested Range Not Satisfiable',
|
||||
417 => 'Expectation Failed',
|
||||
|
||||
// Server Error 5xx
|
||||
500 => 'Internal Server Error',
|
||||
501 => 'Not Implemented',
|
||||
@@ -149,8 +147,26 @@ class Route{
|
||||
if (is_string($callback)) {
|
||||
$segments = explode('@', $callback);
|
||||
$class = new $segments[0]();
|
||||
|
||||
$r = new \ReflectionMethod($segments[0], $segments[1]);
|
||||
|
||||
if (sizeof($r->getParameters()) > 0 && $r->getParameters()[0]->getClass() != NULL) {
|
||||
$element;
|
||||
$element = $r->getParameters()[0]->getClass()->name;
|
||||
$element = new $element;
|
||||
$element->load($this->_params['id']);
|
||||
$this->_params['id'] = $element;
|
||||
}
|
||||
$class->{$segments[1]}(...array_values($this->_params));
|
||||
} else {
|
||||
$r = new \ReflectionFunction($callback);
|
||||
if(sizeof($r->getParameters()) > 0 && $r->getParameters()[0]->getClass() != NULL){
|
||||
$element;
|
||||
$element = $r->getParameters()[0]->getClass()->name;
|
||||
$element = new $element;
|
||||
$element->load($this->_params['id']);
|
||||
$this->_params['id'] = $element;
|
||||
}
|
||||
call_user_func_array($callback, $this->_params);
|
||||
}
|
||||
}
|
||||
@@ -201,6 +217,7 @@ class Route{
|
||||
$this->_block = true;
|
||||
return $this;
|
||||
}
|
||||
|
||||
function not_block() {
|
||||
$this->_block = false;
|
||||
return $this;
|
||||
@@ -210,6 +227,7 @@ class Route{
|
||||
$this->_ignore = true;
|
||||
return $this;
|
||||
}
|
||||
|
||||
function not_ignore() {
|
||||
$this->_ignore = false;
|
||||
return $this;
|
||||
@@ -228,7 +246,6 @@ class Route{
|
||||
$this->_before[$name] = $function;
|
||||
}
|
||||
|
||||
|
||||
function set_weight($weigth = 0) {
|
||||
$this->_weight = $weigth;
|
||||
return $this;
|
||||
@@ -261,4 +278,6 @@ class Route{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user