PluginProbe ʕ •ᴥ•ʔ
Kirki – Freeform Page Builder, Website Builder & Customizer / 6.2.5
Kirki – Freeform Page Builder, Website Builder & Customizer v6.2.5
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 / CollectionItem / CollectionItemStoreRequest.php
kirki / app / Http / Requests / CollectionItem Last commit date
CollectionItemBulkActionRequest.php 1 month ago CollectionItemConditionRequest.php 1 month ago CollectionItemSingleActionRequest.php 2 months ago CollectionItemStoreRequest.php 1 month ago
CollectionItemStoreRequest.php
74 lines
1 <?php
2
3 namespace Kirki\App\Http\Requests\CollectionItem;
4
5 use Kirki\App\Constants\PostStatus;
6 use Kirki\Framework\Http\Request;
7 use Kirki\Framework\Sanitizer;
8 use Kirki\Framework\Supports\Arr;
9
10 use function Kirki\App\ensure_array;
11
12 class CollectionItemStoreRequest extends Request
13 {
14 /**
15 * Prepare data for validation.
16 */
17 protected function prepare_for_validation()
18 {
19 $data = $this->get('data');
20
21 if (is_string($data)) {
22 $data = json_decode($data, true);
23 }
24
25 if (is_array($data)) {
26 $this->merge($data);
27 }
28
29 if (empty($data['post_status'])) {
30 $this->merge(['post_status' => PostStatus::DRAFT]);
31 }
32
33 $this->merge([
34 'fields' => ensure_array($this->fields),
35 ]);
36 }
37
38 /**
39 * Validation rules.
40 */
41 public function rules()
42 {
43 return [
44 'ID' => 'nullable|integer',
45 'post_parent' => 'required|integer',
46 'post_title' => 'required|string',
47 'post_name' => 'nullable|string',
48 'fields' => 'nullable|array',
49 'post_status' => 'nullable|string|in:' . Arr::join([
50 PostStatus::DRAFT,
51 PostStatus::PUBLISH,
52 PostStatus::FUTURE,
53 ]),
54 'post_date' => 'nullable',
55 ];
56 }
57
58 /**
59 * Sanitization filters.
60 */
61 public function filters()
62 {
63 return [
64 'ID' => Sanitizer::INT,
65 'post_parent' => Sanitizer::INT,
66 'post_title' => Sanitizer::TEXT,
67 'post_name' => Sanitizer::TEXT,
68 'fields' => Sanitizer::ARRAY ,
69 'post_status' => Sanitizer::TEXT,
70 'post_date' => Sanitizer::DATETIME,
71 ];
72 }
73 }
74