Skip to content

Commit e30e981

Browse files
committed
docs: add docs
1 parent 624e7b3 commit e30e981

3 files changed

Lines changed: 32 additions & 0 deletions

File tree

user_guide_src/source/changelogs/v4.3.0.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ Others
323323
- **Config:** Added ``Config\Session`` class to handle session configuration.
324324
- **Debug:** Kint has been updated to 5.0.1.
325325
- **Request:** Added new ``$request->getRawInputVar()`` method to return a specified variable from raw stream. See :ref:`Retrieving Raw data <incomingrequest-retrieving-raw-data>`.
326+
- **Request:** Added new ``$request->is()`` method to to query the request type.
327+
See :ref:`Determining Request Type <incomingrequest-is>`.
326328

327329
Message Changes
328330
***************

user_guide_src/source/incoming/incomingrequest.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,20 @@ be checked with the ``isAJAX()`` and ``isCLI()`` methods:
4040
which in some cases is not sent by default in XHR requests via JavaScript (i.e., fetch).
4141
See the :doc:`AJAX Requests </general/ajax>` section on how to avoid this problem.
4242

43+
.. _incomingrequest-is:
44+
45+
is()
46+
====
47+
48+
.. versionadded:: 4.3.0
49+
50+
Since v4.3.0, you can use the ``is()`` method. It returns boolean.
51+
52+
.. literalinclude:: incomingrequest/040.php
53+
54+
getMethod()
55+
===========
56+
4357
You can check the HTTP method that this request represents with the ``getMethod()`` method:
4458

4559
.. literalinclude:: incomingrequest/005.php
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
// Checks HTTP methods. Returns boolean.
4+
$request->is('get');
5+
$request->is('post');
6+
$request->is('put');
7+
$request->is('delete');
8+
$request->is('head');
9+
$request->is('patch');
10+
$request->is('options');
11+
12+
// Checks if it is an AJAX request.
13+
$request->is('ajax');
14+
15+
// Checks if it is a JSON request.
16+
$request->is('json');

0 commit comments

Comments
 (0)