PluginProbe ʕ •ᴥ•ʔ
Kirki – Freeform Page Builder, Website Builder & Customizer / trunk
Kirki – Freeform Page Builder, Website Builder & Customizer vtrunk
6.3.0 6.2.5 6.2.4 6.2.3 6.2.2 6.2.1 6.2.0 6.1.1 6.1.0 6.0.14 6.0.13 6.0.12 6.0.11 6.0.10 6.0.9 6.0.8 6.0.7 6.0.6 6.0.5 6.0.4 6.0.3 6.0.2 6.0.1 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.19 4.0.20 4.0.21 4.0.22 4.0.23 4.0.24 4.1 4.2.0 5.0.0 5.1.0 5.1.1 5.2.0 5.2.1 5.2.2 5.2.3 6.0.0 trunk 3.0.40 3.0.41 3.0.42 3.0.43 3.0.44 3.0.45 3.1.0 3.1.1 3.1.2
kirki / app / Http / Requests / Collection / CollectionStoreRequest.php
kirki / app / Http / Requests / Collection Last commit date
CollectionStoreRequest.php 1 month ago
CollectionStoreRequest.php
76 lines
1 <?php
2
3 namespace Kirki\App\Http\Requests\Collection;
4
5 use Kirki\App\Constants\Collection\CustomFieldTypes;
6 use Kirki\Framework\Http\Request;
7 use Kirki\Framework\Sanitizer;
8
9 use function Kirki\App\ensure_array;
10
11 class CollectionStoreRequest extends Request
12 {
13 /**
14 * Prepare data for validation.
15 */
16 protected function prepare_for_validation()
17 {
18 $data = ensure_array($this->get('data') ?? []);
19
20 $this->merge($data);
21
22 $this->merge([
23 'fields' => ensure_array($this->fields),
24 'basic_fields' => ensure_array($this->basic_fields),
25 ]);
26 }
27
28 /**
29 * Validation rules.
30 */
31 public function rules()
32 {
33 return [
34 'ID' => 'nullable',
35 'post_title' => 'required|string',
36 'post_name' => 'nullable|string',
37 'preset_type' => 'nullable|string',
38
39 'fields' => 'nullable|array',
40 'fields.*.id' => 'required|string',
41 'fields.*.kind' => 'required|string|in:custom',
42 'fields.*.type' => 'required|string|in:' . CustomFieldTypes::join(),
43 'fields.*.title' => 'required|string',
44 'fields.*.help_text' => 'nullable|string',
45 'fields.*.required' => 'required|boolean',
46 'fields.*.templateKey' => 'nullable|string',
47
48 'basic_fields' => 'nullable|array',
49 ];
50 }
51
52 /**
53 * Sanitization filters.
54 */
55 public function filters()
56 {
57 return [
58 'ID' => Sanitizer::INT,
59 'post_title' => Sanitizer::TEXT,
60 'post_name' => Sanitizer::TEXT,
61 'preset_type' => Sanitizer::TEXT,
62
63 'fields' => Sanitizer::ARRAY ,
64 'fields.*.id' => Sanitizer::TEXT,
65 'fields.*.kind' => Sanitizer::TEXT,
66 'fields.*.type' => Sanitizer::TEXT,
67 'fields.*.title' => Sanitizer::TEXT,
68 'fields.*.help_text' => Sanitizer::TEXT,
69 'fields.*.required' => Sanitizer::BOOL,
70 'fields.*.templateKey' => Sanitizer::TEXT,
71
72 'basic_fields' => Sanitizer::ARRAY ,
73 ];
74 }
75 }
76