|
10 | 10 | /** |
11 | 11 | * A wrapper for {@see BaseRequest} for easier handling of GET and POST parameters. |
12 | 12 | * |
| 13 | + * It contains the following methods: |
| 14 | + * |
| 15 | + * - {@see Request::getGetInt()} - gets the value of a **GET** parameter by its name and tries to |
| 16 | + * convert it to an integer. |
| 17 | + * - {@see Request::getGetFloat()} - gets the value of the **GET** parameter by its name and tries to |
| 18 | + * convert it to a floating-point number. |
| 19 | + * - {@see Request::getGetBool()} - gets the value of the **GET** parameter by its name and tries to |
| 20 | + * convert it to a boolean. |
| 21 | + * - {@see Request::getGetString()} - gets the value of the **GET** parameter by its name and tries to |
| 22 | + * convert it to a string. |
| 23 | + * - {@see Request::getGetArray()} - gets the value of the **GET** parameter by its name and tries to |
| 24 | + * convert it to an array. |
| 25 | + * - {@see Request::getPostInt()} - gets the value of a **POST** parameter by its name and tries to |
| 26 | + * convert it to an integer. |
| 27 | + * - {@see Request::getPostFloat()} - gets the value of the **POST** parameter by its name and tries to |
| 28 | + * convert it to a floating-point number. |
| 29 | + * - {@see Request::getPostBool()} - gets the value of the **POST** parameter by its name and tries to |
| 30 | + * convert it to a boolean. |
| 31 | + * - {@see Request::getPostString()} - gets the value of the **POST** parameter by its name and tries to |
| 32 | + * convert it to a string. |
| 33 | + * - {@see Request::getPostArray()} - gets the value of the **POST** parameter by its name and checks that |
| 34 | + * the value is an array. |
| 35 | + * |
| 36 | + * To use it, you need to replace the `request` component in the configuration: |
| 37 | +
|
| 38 | + * ``` |
| 39 | + * use MSpirkov\Yii2\Web\Request; |
| 40 | + * |
| 41 | + * return [ |
| 42 | + * ... |
| 43 | + * 'components' => [ |
| 44 | + * 'request' => [ |
| 45 | + * 'class' => Request::class, |
| 46 | + * ... |
| 47 | + * ], |
| 48 | + * ... |
| 49 | + * ], |
| 50 | + * ]; |
| 51 | + * ``` |
| 52 | + * |
| 53 | + * Usage example: |
| 54 | + * |
| 55 | + * ``` |
| 56 | + * use yii\web\Controller; |
| 57 | + * |
| 58 | + * class ProductController extends Controller |
| 59 | + * { |
| 60 | + * public function actionDelete(): array |
| 61 | + * { |
| 62 | + * $id = $this->request->getPostInt('id'); |
| 63 | + * |
| 64 | + * // There's some logic here. For example, calling a service class method to delete |
| 65 | + * // a product with the parameter `$id`. |
| 66 | + * } |
| 67 | + * } |
| 68 | + * ``` |
| 69 | + * |
13 | 70 | * @author Maksim Spirkov <spirkov.2001@mail.ru> |
14 | 71 | */ |
15 | 72 | class Request extends BaseRequest |
|
0 commit comments