Compare commits

...

11 Commits

Author SHA1 Message Date
Simon Sessingø 18a9df56ca Merge pull request #96 from skipperbent/development
Development
2016-04-20 08:10:18 +02:00
Simon Sessingø f7af53a9af - Optimized Input class to ensure that InputFile items are always returned as object as they contain no value. 2016-04-19 14:48:26 +02:00
Simon Sessingø 6b8351f1b8 - Input class no longer tries to search for parameter in FILE or POST if it's not a postback. 2016-04-19 02:08:14 +02:00
Simon Sessingø 6e14ded03f Merge pull request #95 from skipperbent/development
Development
2016-04-16 23:23:56 +02:00
Simon Sessingø eb3ddf2bf7 [OPTIMISATION] Optimized get method in Input class to trim value and return default value if empty. 2016-04-16 21:34:22 +02:00
Simon Sessingø 2afe784f47 [BUGFIX] Fixed middlewaresToLoad logic used before any routes loaded in RouterBase. 2016-04-16 13:08:32 +02:00
Simon Sessingø 899081f8d8 Merge pull request #94 from skipperbent/development
Update README.md
2016-04-16 00:01:22 +02:00
Simon Sessingø 94e98ad5f0 Update README.md 2016-04-16 00:01:12 +02:00
Simon Sessingø e7b9206bc9 Merge pull request #93 from skipperbent/development
Development
2016-04-15 23:21:00 +02:00
Simon Sessingø 8f24256434 Merge pull request #92 from skipperbent/feature-input
Removed old input method from Request class.
2016-04-15 23:20:50 +02:00
Simon Sessingø ec355c90b5 Removed old input method from Request class. 2016-04-15 23:20:16 +02:00
4 changed files with 26 additions and 23 deletions
+1 -1
View File
@@ -384,7 +384,7 @@ Example:
* @return \Pecee\Http\Input\Input
*/
function input() {
return new \Pecee\Http\Input\Input();
return \Pecee\Http\Request::getInstance()->getInput();
}
```
+14 -8
View File
@@ -55,16 +55,18 @@ class Input {
return $element;
}
$element = $this->post->findFirst($index);
if(request()->getMethod() !== 'get') {
if($element !== null) {
return $element;
}
$element = $this->post->findFirst($index);
$element = $this->file->findFirst($index);
if ($element !== null) {
return $element;
}
if($element !== null) {
return $element;
$element = $this->file->findFirst($index);
if ($element !== null) {
return $element;
}
}
return $default;
@@ -85,11 +87,15 @@ class Input {
if($item !== null) {
if($item instanceof InputFile) {
return $item;
}
if (is_array($item->getValue())) {
return ($key !== null && isset($item->getValue()[$key])) ? $item->getValue()[$key] : $item->getValue();
}
return ($item->getValue() === null) ? $default : $item->getValue();
return (trim($item->getValue()) === '') ? $default : $item->getValue();
}
return $default;
+4 -6
View File
@@ -125,13 +125,11 @@ class Request {
}
/**
* Get request input or default value
* @param string $name
* @param string $defaultValue
* @return mixed
* Get input class
* @return Input
*/
public function getInput($name, $defaultValue) {
return (isset($_REQUEST[$name]) ? $_REQUEST[$name] : $defaultValue);
public function getInput() {
return $this->input;
}
public function isFormatAccepted($format) {
+7 -8
View File
@@ -111,13 +111,6 @@ class RouterBase {
$originalUri = $this->request->getUri();
// Load group middlewares
/* @var $middleware RouterEntry */
foreach($this->middlewaresToLoad as $middleware) {
$middleware->loadMiddleware($this->request);
}
// Initialize boot-managers
if(count($this->bootManagers)) {
/* @var $manager RouterBootManager */
@@ -138,6 +131,12 @@ class RouterBase {
// Loop through each route-request
$this->processRoutes($this->routes);
// Load group middlewares
/* @var $route RouterEntry */
foreach($this->middlewaresToLoad as $route) {
$route->loadMiddleware($this->request);
}
$routeNotAllowed = false;
// Make sure routes with longer urls are rendered first
@@ -309,7 +308,7 @@ class RouterBase {
return '';
}
protected function processUrl($route, $method = null, $parameters = null, $getParams = null) {
protected function processUrl(RouterRoute $route, $method = null, $parameters = null, $getParams = null) {
$domain = '';