1 | <?php |
||
15 | class JsValidatorFactory |
||
16 | { |
||
17 | /** |
||
18 | * The application instance. |
||
19 | * |
||
20 | * @var \Illuminate\Container\Container |
||
21 | */ |
||
22 | protected $app; |
||
23 | |||
24 | /** |
||
25 | * Configuration options. |
||
26 | * |
||
27 | * @var array |
||
28 | */ |
||
29 | protected $options; |
||
30 | |||
31 | /** |
||
32 | * Create a new Validator factory instance. |
||
33 | * |
||
34 | * @param \Illuminate\Container\Container $app |
||
35 | * @param array $options |
||
36 | */ |
||
37 | 5 | public function __construct($app, array $options = []) |
|
42 | |||
43 | 5 | protected function setOptions($options) |
|
44 | { |
||
45 | 5 | $options['disable_remote_validation'] = empty($options['disable_remote_validation']) ? false : $options['disable_remote_validation']; |
|
46 | 5 | $options['view'] = empty($options['view']) ? 'jsvalidation:bootstrap' : $options['view']; |
|
47 | 5 | $options['form_selector'] = empty($options['form_selector']) ? 'form' : $options['form_selector']; |
|
48 | |||
49 | 5 | $this->options = $options; |
|
50 | 5 | } |
|
51 | |||
52 | /** |
||
53 | * Creates JsValidator instance based on rules and message arrays. |
||
54 | * |
||
55 | * @param array $rules |
||
56 | * @param array $messages |
||
57 | * @param array $customAttributes |
||
58 | * @param null|string $selector |
||
59 | * |
||
60 | * @return JavascriptValidator |
||
61 | */ |
||
62 | 2 | public function make(array $rules, array $messages = array(), array $customAttributes = array(), $selector = null) |
|
68 | |||
69 | /** |
||
70 | * Get the validator instance for the request. |
||
71 | * |
||
72 | * @param array $rules |
||
73 | * @param array $messages |
||
74 | * @param array $customAttributes |
||
75 | * @return Validator |
||
76 | */ |
||
77 | 4 | protected function getValidatorInstance(array $rules, array $messages = array(), array $customAttributes = array()) |
|
86 | |||
87 | /** |
||
88 | * Creates JsValidator instance based on FormRequest. |
||
89 | * |
||
90 | * @param $formRequest |
||
91 | * @param null $selector |
||
92 | * |
||
93 | * @return JavascriptValidator |
||
94 | * @throws FormRequestArgumentException |
||
95 | */ |
||
96 | 2 | public function formRequest($formRequest, $selector = null) |
|
108 | |||
109 | /** |
||
110 | * Creates and initializes an Form Request instance. |
||
111 | * |
||
112 | * @param string $class |
||
113 | * @return FormRequest |
||
114 | */ |
||
115 | 1 | protected function createFormRequest($class) |
|
140 | |||
141 | /** |
||
142 | * Creates JsValidator instance based on Validator. |
||
143 | * |
||
144 | * @param \Illuminate\Validation\Validator $validator |
||
145 | * @param string|null $selector |
||
146 | * |
||
147 | * @return JavascriptValidator |
||
148 | */ |
||
149 | 4 | public function validator(Validator $validator, $selector = null) |
|
153 | |||
154 | /** |
||
155 | * Creates JsValidator instance based on Validator. |
||
156 | * |
||
157 | * @param \Illuminate\Validation\Validator $validator |
||
158 | * @param string|null $selector |
||
159 | * |
||
160 | * @return JavascriptValidator |
||
161 | */ |
||
162 | 4 | protected function jsValidator(Validator $validator, $selector = null) |
|
178 | |||
179 | /** |
||
180 | * Get and encrypt token from session store. |
||
181 | * |
||
182 | * @return null|string |
||
183 | */ |
||
184 | 4 | protected function getSessionToken() |
|
197 | } |
||
198 |