11<?php
22
3+ /*
4+ * This file is part of the slpcode/form-request-validation.
5+ *
6+ * (c) slpcode <1370808424@qq.com>
7+ *
8+ * This source file is subject to the MIT license that is bundled
9+ * with this source code in the file LICENSE.
10+ */
11+
312namespace Slpcode \FormRequestValidation ;
413
514use Slpcode \FormRequestValidation \Exceptions \ValidationException ;
615use Symfony \Component \HttpFoundation \ParameterBag ;
716
817class FormRequest extends Request
918{
10- protected $ translation_path = __DIR__ . '/lang ' ;
19+ protected $ translation_path = __DIR__ .'/lang ' ;
20+
1121 protected $ translation_locale = 'zh-CN ' ;
1222
1323 /**
14- * 构造初始化
24+ * 构造初始化.
1525 *
1626 * FormRequest constructor.
27+ *
1728 * @param array $attributeData
1829 */
1930 public function __construct ($ attributeData = [])
2031 {
2132 parent ::__construct ($ _GET , $ _POST , $ attributeData , $ _COOKIE , $ _FILES , $ _SERVER );
2233
2334 /**
24- * 判断是否符合传递body数据,例如json形式数据,如果符合则重新赋值$this->request
35+ * 判断是否符合传递body数据,例如json形式数据,如果符合则重新赋值$this->request.
2536 */
2637 if (0 === strpos ($ this ->headers ->get ('CONTENT_TYPE ' ), 'application/x-www-form-urlencoded ' )
2738 && \in_array (strtoupper ($ this ->server ->get ('REQUEST_METHOD ' , 'GET ' )), ['PUT ' , 'DELETE ' , 'PATCH ' ])
@@ -35,10 +46,11 @@ public function __construct($attributeData = [])
3546 }
3647
3748 /**
38- * 设置语言和路径
49+ * 设置语言和路径.
3950 *
4051 * @param string $locale
4152 * @param string $path
53+ *
4254 * @return FormRequest
4355 */
4456 public function setLang ($ locale = 'zh-CN ' , $ path = '' )
@@ -54,7 +66,7 @@ public function setLang($locale = 'zh-CN', $path = '')
5466 }
5567
5668 /**
57- * 获取验证实例
69+ * 获取验证实例.
5870 */
5971 public function getValidator ()
6072 {
@@ -63,6 +75,7 @@ public function getValidator()
6375
6476 /**
6577 * @return FormRequest
78+ *
6679 * @throws \Exception
6780 */
6881 public function check ()
@@ -112,7 +125,7 @@ protected function validationData()
112125 }
113126
114127 /**
115- * 设置验证规则
128+ * 设置验证规则.
116129 *
117130 * @return array
118131 */
@@ -122,7 +135,7 @@ protected function rules()
122135 }
123136
124137 /**
125- * 设置验证错误信息
138+ * 设置验证错误信息.
126139 *
127140 * @return array
128141 */
@@ -132,7 +145,7 @@ protected function messages()
132145 }
133146
134147 /**
135- * 自定义字段名称
148+ * 自定义字段名称.
136149 *
137150 * @return array
138151 */
@@ -148,4 +161,4 @@ protected function extend()
148161 {
149162 return $ this ;
150163 }
151- }
164+ }
0 commit comments