1 | <?php |
||
17 | class JsValidatorFactory |
||
18 | { |
||
19 | const ASTERISK = '__asterisk__'; |
||
20 | |||
21 | /** |
||
22 | * The application instance. |
||
23 | * |
||
24 | * @var \Illuminate\Container\Container |
||
25 | */ |
||
26 | protected $app; |
||
27 | |||
28 | /** |
||
29 | * Configuration options. |
||
30 | * |
||
31 | * @var array |
||
32 | */ |
||
33 | protected $options; |
||
34 | |||
35 | /** |
||
36 | * Create a new Validator factory instance. |
||
37 | 84 | * |
|
38 | * @param \Illuminate\Container\Container $app |
||
39 | 84 | * @param array $options |
|
40 | 84 | */ |
|
41 | 84 | public function __construct($app, array $options = []) |
|
46 | |||
47 | 84 | /** |
|
48 | * @param $options |
||
49 | 84 | * @return void |
|
50 | 84 | */ |
|
51 | 84 | protected function setOptions($options) |
|
59 | |||
60 | /** |
||
61 | * Creates JsValidator instance based on rules and message arrays. |
||
62 | * |
||
63 | * @param array $rules |
||
64 | * @param array $messages |
||
65 | 48 | * @param array $customAttributes |
|
66 | * @param null|string $selector |
||
67 | 48 | * @return \Proengsoft\JsValidation\Javascript\JavascriptValidator |
|
68 | */ |
||
69 | 48 | public function make(array $rules, array $messages = [], array $customAttributes = [], $selector = null) |
|
75 | |||
76 | /** |
||
77 | * Get the validator instance for the request. |
||
78 | * |
||
79 | * @param array $rules |
||
80 | 72 | * @param array $messages |
|
81 | * @param array $customAttributes |
||
82 | 72 | * @return \Illuminate\Validation\Validator |
|
83 | */ |
||
84 | 72 | protected function getValidatorInstance(array $rules, array $messages = [], array $customAttributes = []) |
|
94 | |||
95 | /** |
||
96 | * Gets fake data when validator has wildcard rules. |
||
97 | 72 | * |
|
98 | * @param array $rules |
||
99 | * @param array $customAttributes |
||
100 | 48 | * @return array |
|
101 | 72 | */ |
|
102 | protected function getValidationData(array $rules, array $customAttributes = []) |
||
120 | |||
121 | /** |
||
122 | 24 | * Creates JsValidator instance based on FormRequest. |
|
123 | * |
||
124 | 24 | * @param $formRequest |
|
125 | 12 | * @param null|string $selector |
|
126 | * @return \Proengsoft\JsValidation\Javascript\JavascriptValidator |
||
127 | * |
||
128 | 24 | * @throws \Illuminate\Contracts\Container\BindingResolutionException |
|
129 | */ |
||
130 | 24 | public function formRequest($formRequest, $selector = null) |
|
142 | |||
143 | /** |
||
144 | * Create form request validator. |
||
145 | 12 | * |
|
146 | * @param FormRequest $formRequest |
||
147 | 12 | * @param string $selector |
|
148 | 12 | * @return JavascriptValidator |
|
149 | 12 | */ |
|
150 | 12 | private function newFormRequestValidator($formRequest, $selector) |
|
167 | |||
168 | /** |
||
169 | * Create a form request validator instance. |
||
170 | 12 | * |
|
171 | * @param IlluminateFormRequest $formRequest |
||
172 | 12 | * @param string $selector |
|
173 | 12 | * @return JavascriptValidator |
|
174 | */ |
||
175 | 12 | private function oldFormRequestValidator($formRequest, $selector) |
|
189 | |||
190 | /** |
||
191 | * @param string|array $class |
||
192 | * @return array |
||
193 | 72 | */ |
|
194 | protected function parseFormRequestName($class) |
||
204 | |||
205 | 72 | /** |
|
206 | * Creates and initializes an Form Request instance. |
||
207 | 72 | * |
|
208 | 72 | * @param string $class |
|
209 | 72 | * @return IlluminateFormRequest |
|
210 | * |
||
211 | 72 | * @throws \Illuminate\Contracts\Container\BindingResolutionException |
|
212 | 72 | */ |
|
213 | 72 | protected function createFormRequest($class) |
|
234 | 72 | ||
235 | 12 | /** |
|
236 | * Creates JsValidator instance based on Validator. |
||
237 | * |
||
238 | 72 | * @param \Illuminate\Validation\Validator $validator |
|
239 | * @param null|string $selector |
||
240 | * @return \Proengsoft\JsValidation\Javascript\JavascriptValidator |
||
241 | */ |
||
242 | public function validator(Validator $validator, $selector = null) |
||
246 | |||
247 | /** |
||
248 | * Creates JsValidator instance based on Validator. |
||
249 | * |
||
250 | * @param \Illuminate\Validation\Validator $validator |
||
251 | * @param null|string $selector |
||
252 | * @return \Proengsoft\JsValidation\Javascript\JavascriptValidator |
||
253 | */ |
||
254 | protected function jsValidator(Validator $validator, $selector = null) |
||
269 | |||
270 | /** |
||
271 | * Get and encrypt token from session store. |
||
272 | * |
||
273 | * @return null|string |
||
274 | */ |
||
275 | protected function getSessionToken() |
||
288 | } |
||
289 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: