Skip to content

Commit f7fcf28

Browse files
authored
Merge pull request #7137 from kenjis/fix-docs-request-getMethod
docs: use Request::is() instead of getMethod()
2 parents 1c7b272 + 4e39c33 commit f7fcf28

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

user_guide_src/source/libraries/security.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,22 @@ Do one of the following:
4444

4545
E.g.::
4646

47-
if (strtolower($this->request->getMethod()) !== 'post') {
47+
if (! $this->request->is('post')) {
4848
return $this->response->setStatusCode(405)->setBody('Method Not Allowed');
4949
}
5050

51+
.. note:: The :ref:`$this->request->is() <incomingrequest-is>` method can be used since v4.3.0.
52+
In previous versions, you need to use
53+
``if (strtolower($this->request->getMethod()) !== 'post')``.
54+
5155
When Auto-Routing is Enabled
5256
----------------------------
5357

5458
1. Check the request method in the controller method before processing.
5559

5660
E.g.::
5761

58-
if (strtolower($this->request->getMethod()) !== 'post') {
62+
if (! $this->request->is('post')) {
5963
return $this->response->setStatusCode(405)->setBody('Method Not Allowed');
6064
}
6165

user_guide_src/source/libraries/validation.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ this code and save it to your **app/Controllers/** folder:
121121

122122
.. literalinclude:: validation/001.php
123123

124+
.. note:: The :ref:`$this->request->is() <incomingrequest-is>` method can be used since v4.3.0.
125+
In previous versions, you need to use
126+
``if (strtolower($this->request->getMethod()) !== 'post')``.
127+
124128
The Routes
125129
==========
126130

user_guide_src/source/libraries/validation/001.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Form extends BaseController
1010

1111
public function index()
1212
{
13-
if (strtolower($this->request->getMethod()) !== 'post') {
13+
if (! $this->request->is('post')) {
1414
return view('signup');
1515
}
1616

0 commit comments

Comments
 (0)