Added Request::isPostBack helper method

This commit is contained in:
Simon Sessingø
2021-03-28 04:05:09 +02:00
parent 9e19cbfb71
commit e5eb966780
2 changed files with 15 additions and 4 deletions
+4 -3
View File
@@ -658,6 +658,7 @@ SimpleRouter::group(['prefix' => '/admin'], function () {
## Partial groups ## 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 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. 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:** **Example:**
```php ```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
}); });
+10
View File
@@ -363,6 +363,16 @@ class Request
return (strtolower($this->getHeader('http-x-requested-with')) === 'xmlhttprequest'); 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 * Get accept formats
* @return array * @return array