From 9e3b1b6baa07ef5e50b0ad6d56261f2c75c4c60d Mon Sep 17 00:00:00 2001 From: Taras Victorovich Date: Tue, 2 Oct 2018 15:40:26 +0300 Subject: [PATCH 1/3] fix for __invoke methods (if there are only in class (Action)) --- src/Pecee/SimpleRouter/Route/Route.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Pecee/SimpleRouter/Route/Route.php b/src/Pecee/SimpleRouter/Route/Route.php index 8dcc520..2183e0f 100644 --- a/src/Pecee/SimpleRouter/Route/Route.php +++ b/src/Pecee/SimpleRouter/Route/Route.php @@ -109,6 +109,10 @@ abstract class Route implements IRoute $router->debug('Loading class %s', $className); $class = $router->getClassLoader()->loadClass($className); + if (count($controller) === 1) { + $controller[1] = '__invoke'; + } + $method = $controller[1]; if (method_exists($class, $method) === false) { From d4a6d504b161f03908479a96c9815407eaae753c Mon Sep 17 00:00:00 2001 From: Matheus Date: Sat, 10 Nov 2018 22:16:45 -0200 Subject: [PATCH 2/3] Set HTTP method before initializing InputHandler This is needed because without it the InputHandler doesn't know which http method is being used, and because of that it can't parse the body of a PUT request --- src/Pecee/Http/Request.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Pecee/Http/Request.php b/src/Pecee/Http/Request.php index cf7cc32..31dc0ae 100644 --- a/src/Pecee/Http/Request.php +++ b/src/Pecee/Http/Request.php @@ -84,7 +84,8 @@ class Request // Check if special IIS header exist, otherwise use default. $this->setUrl(new Url($this->getHeader('unencoded-url', $this->getHeader('request-uri')))); - + + $this->method = strtolower($this->getHeader('request-method')); $this->inputHandler = new InputHandler($this); $this->method = strtolower($this->inputHandler->value('_method', $this->getHeader('request-method'))); } @@ -425,4 +426,4 @@ class Request return $this->data[$name] ?? null; } -} \ No newline at end of file +} From d601e8eca346bdc4abaa7e8efac96bb1a7d45799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sessing=C3=B8?= Date: Sun, 25 Nov 2018 00:44:20 +0100 Subject: [PATCH 3/3] Bugfixes and optimisations. - Fix for __invoke methods (issue: #429) - Fixed not being able to parse body of PUT request. - BaseCsrfVerifier expects the field name to be "csrf-token" (issue: #432) - Minor optimisations --- .idea/encodings.xml | 4 + .idea/php.xml | 2 +- .idea/workspace.xml | 367 ++++++++---------- .../Http/Middleware/BaseCsrfVerifier.php | 2 +- src/Pecee/SimpleRouter/Route/Route.php | 2 +- src/Pecee/SimpleRouter/Router.php | 2 +- 6 files changed, 171 insertions(+), 208 deletions(-) create mode 100644 .idea/encodings.xml diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..15a15b2 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml index b285d9d..02facb2 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -35,13 +35,13 @@ - + diff --git a/.idea/workspace.xml b/.idea/workspace.xml index b49c99b..c262aba 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,12 +5,12 @@ + + - - - + - +