From 1fffba12aae4fb69e26320245344f349632645f9 Mon Sep 17 00:00:00 2001 From: Pete McFarlane Date: Tue, 15 Oct 2013 09:33:57 +0100 Subject: [PATCH 1/4] added a check for _method in request --- src/Toro.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Toro.php b/src/Toro.php index 6e4787d..9d699b8 100644 --- a/src/Toro.php +++ b/src/Toro.php @@ -7,6 +7,9 @@ public static function serve($routes) ToroHook::fire('before_request', compact('routes')); $request_method = strtolower($_SERVER['REQUEST_METHOD']); + if (isset($_GET['_method']) || isset($_POST['_method'])) { + $request_method = isset($_POST['_method']) ? $_POST['_method'] : $_GET['_method']; + } $path_info = '/'; if (!empty($_SERVER['PATH_INFO'])) { $path_info = $_SERVER['PATH_INFO']; From 4591d3a7bf91bae10a42e116495b5289663d390b Mon Sep 17 00:00:00 2001 From: Pete McFarlane Date: Tue, 15 Oct 2013 09:41:18 +0100 Subject: [PATCH 2/4] updated the README --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index c3a3210..ca2fbcf 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,11 @@ From the above, you can see two emergent patterns. JSON/`XMLHTTPRequest` requests. If the `_xhr` method is not implemented, then the given HTTP request method is called as a fallback. +3. If you want to add fallback support for browsers that do not support XMLHTTPRequest, + (or even javascript) but want to implement other `verbs` such as `PUT` or `DELETE` then add a hidden input + to your form with the name `_method` set to your desired verb, e.g. + + ## ToroHook (Callbacks) From a6889d99f97ed3e0bec8bbc79c2d2526fc61d784 Mon Sep 17 00:00:00 2001 From: Pete McFarlane Date: Tue, 15 Oct 2013 09:42:48 +0100 Subject: [PATCH 3/4] updated the README --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ca2fbcf..e7b872f 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,9 @@ From the above, you can see two emergent patterns. (or even javascript) but want to implement other `verbs` such as `PUT` or `DELETE` then add a hidden input to your form with the name `_method` set to your desired verb, e.g. - +```php + +``` ## ToroHook (Callbacks) From 24748121733778ee5c981dc0bdc51f2c24830a1c Mon Sep 17 00:00:00 2001 From: Pete McFarlane Date: Wed, 13 Nov 2013 22:58:15 +0000 Subject: [PATCH 4/4] Fixed indentation --- src/Toro.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Toro.php b/src/Toro.php index 9d699b8..929abb4 100644 --- a/src/Toro.php +++ b/src/Toro.php @@ -7,9 +7,9 @@ public static function serve($routes) ToroHook::fire('before_request', compact('routes')); $request_method = strtolower($_SERVER['REQUEST_METHOD']); - if (isset($_GET['_method']) || isset($_POST['_method'])) { - $request_method = isset($_POST['_method']) ? $_POST['_method'] : $_GET['_method']; - } + if (isset($_GET['_method']) || isset($_POST['_method'])) { + $request_method = isset($_POST['_method']) ? $_POST['_method'] : $_GET['_method']; + } $path_info = '/'; if (!empty($_SERVER['PATH_INFO'])) { $path_info = $_SERVER['PATH_INFO'];