From e5eb9667800729bcfadf86cef47cff398e8e9899 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sessing=C3=B8?= Date: Sun, 28 Mar 2021 04:05:09 +0200 Subject: [PATCH] Added Request::isPostBack helper method --- README.md | 9 +++++---- src/Pecee/Http/Request.php | 10 ++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a0e0918..5e2e293 100644 --- a/README.md +++ b/README.md @@ -658,6 +658,7 @@ SimpleRouter::group(['prefix' => '/admin'], function () { ## Partial groups Partial router groups has the same benefits as a normal group, but supports parameters and are only rendered once the url has matched. +Partial groups will render once a part of the url has matched. This can be extremely useful in situations, where you only want special routes to be added, when a certain criteria or logic has been met. @@ -666,11 +667,11 @@ This can be extremely useful in situations, where you only want special routes t **Example:** ```php -SimpleRouter::partialGroup('/admin/{applicationId}', function ($applicationId) { +SimpleRouter::partialGroup('/lang/{language}', function ($language) { - SimpleRouter::get('/', function($applicationId) { + SimpleRouter::get('/', function($language) { - // Matches The "/admin/applicationId" URL + // Matches The "/lang/da" URL }); @@ -1905,4 +1906,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +SOFTWARE. \ No newline at end of file diff --git a/src/Pecee/Http/Request.php b/src/Pecee/Http/Request.php index e1d363a..53912b0 100644 --- a/src/Pecee/Http/Request.php +++ b/src/Pecee/Http/Request.php @@ -363,6 +363,16 @@ class Request return (strtolower($this->getHeader('http-x-requested-with')) === 'xmlhttprequest'); } + /** + * Returns true when request-type is post. + * + * @return bool + */ + public function isPostBack(): bool + { + return ($this->getMethod() === static::REQUEST_TYPE_POST); + } + /** * Get accept formats * @return array