@@ -15,27 +15,27 @@ |
||
15 | 15 | */ |
16 | 16 | class FormElementLoader extends AbstractLoader |
17 | 17 | { |
18 | - /** |
|
19 | - * @return EEM_Base |
|
20 | - * @throws EE_Error |
|
21 | - * @throws InvalidArgumentException |
|
22 | - * @throws InvalidDataTypeException |
|
23 | - * @throws InvalidInterfaceException |
|
24 | - * @throws ReflectionException |
|
25 | - */ |
|
26 | - protected function getQuery(): EEM_Base |
|
27 | - { |
|
28 | - return EEM_Form_Element::instance(); |
|
29 | - } |
|
18 | + /** |
|
19 | + * @return EEM_Base |
|
20 | + * @throws EE_Error |
|
21 | + * @throws InvalidArgumentException |
|
22 | + * @throws InvalidDataTypeException |
|
23 | + * @throws InvalidInterfaceException |
|
24 | + * @throws ReflectionException |
|
25 | + */ |
|
26 | + protected function getQuery(): EEM_Base |
|
27 | + { |
|
28 | + return EEM_Form_Element::instance(); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * @param array $keys |
|
33 | - * @return array |
|
34 | - */ |
|
35 | - protected function getWhereParams(array $keys): array |
|
36 | - { |
|
37 | - return [ |
|
38 | - 'FIN_UUID' => ['IN', $keys], |
|
39 | - ]; |
|
40 | - } |
|
31 | + /** |
|
32 | + * @param array $keys |
|
33 | + * @return array |
|
34 | + */ |
|
35 | + protected function getWhereParams(array $keys): array |
|
36 | + { |
|
37 | + return [ |
|
38 | + 'FIN_UUID' => ['IN', $keys], |
|
39 | + ]; |
|
40 | + } |
|
41 | 41 | } |
@@ -11,15 +11,15 @@ |
||
11 | 11 | */ |
12 | 12 | interface JsonableInterface |
13 | 13 | { |
14 | - /** |
|
15 | - * @param string $json |
|
16 | - * @return mixed |
|
17 | - */ |
|
18 | - public static function fromJson(string $json); |
|
14 | + /** |
|
15 | + * @param string $json |
|
16 | + * @return mixed |
|
17 | + */ |
|
18 | + public static function fromJson(string $json); |
|
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * @return string |
|
23 | - */ |
|
24 | - public function toJson(): string; |
|
21 | + /** |
|
22 | + * @return string |
|
23 | + */ |
|
24 | + public function toJson(): string; |
|
25 | 25 | } |
@@ -69,7 +69,7 @@ |
||
69 | 69 | { |
70 | 70 | $values = []; |
71 | 71 | foreach ($this->valid_status_options as $value => $description) { |
72 | - $values[ GQLUtils::formatEnumKey($value) ] = compact('value', 'description'); |
|
72 | + $values[GQLUtils::formatEnumKey($value)] = compact('value', 'description'); |
|
73 | 73 | } |
74 | 74 | return $values; |
75 | 75 | } |
@@ -14,74 +14,74 @@ |
||
14 | 14 | */ |
15 | 15 | class FormStatus |
16 | 16 | { |
17 | - /** |
|
18 | - * indicates that element is not archived or trashed |
|
19 | - */ |
|
20 | - public const ACTIVE = 'active'; |
|
17 | + /** |
|
18 | + * indicates that element is not archived or trashed |
|
19 | + */ |
|
20 | + public const ACTIVE = 'active'; |
|
21 | 21 | |
22 | - /** |
|
23 | - * indicates that element is archived and should no longer be displayed on public forms |
|
24 | - * but may still be required due to existing answers when form was completed prior to input being archived |
|
25 | - */ |
|
26 | - public const ARCHIVED = 'archived'; |
|
22 | + /** |
|
23 | + * indicates that element is archived and should no longer be displayed on public forms |
|
24 | + * but may still be required due to existing answers when form was completed prior to input being archived |
|
25 | + */ |
|
26 | + public const ARCHIVED = 'archived'; |
|
27 | 27 | |
28 | - /** |
|
29 | - * indicates that element should be automatically added to newly created forms |
|
30 | - */ |
|
31 | - public const DEFAULT = 'default'; |
|
28 | + /** |
|
29 | + * indicates that element should be automatically added to newly created forms |
|
30 | + */ |
|
31 | + public const DEFAULT = 'default'; |
|
32 | 32 | |
33 | - /** |
|
34 | - * indicates that a copy of the form section will be saved for use in other events but not loaded by default |
|
35 | - */ |
|
36 | - public const SHARED = 'shared'; |
|
33 | + /** |
|
34 | + * indicates that a copy of the form section will be saved for use in other events but not loaded by default |
|
35 | + */ |
|
36 | + public const SHARED = 'shared'; |
|
37 | 37 | |
38 | - /** |
|
39 | - * indicates that element is no longer needed, has no existing answers, and can be moved to the trash |
|
40 | - */ |
|
41 | - public const TRASHED = 'trashed'; |
|
38 | + /** |
|
39 | + * indicates that element is no longer needed, has no existing answers, and can be moved to the trash |
|
40 | + */ |
|
41 | + public const TRASHED = 'trashed'; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @var array |
|
45 | - */ |
|
46 | - private $valid_status_options; |
|
43 | + /** |
|
44 | + * @var array |
|
45 | + */ |
|
46 | + private $valid_status_options; |
|
47 | 47 | |
48 | 48 | |
49 | - public function __construct() |
|
50 | - { |
|
51 | - $this->valid_status_options = apply_filters( |
|
52 | - 'FHEE__EventEspresso_core_services_form_meta_FormStatus__valid_status_options', |
|
53 | - [ |
|
54 | - FormStatus::ACTIVE => esc_html__('Active', 'event_espresso'), |
|
55 | - FormStatus::ARCHIVED => esc_html__('Archived', 'event_espresso'), |
|
56 | - FormStatus::DEFAULT => esc_html__('Default', 'event_espresso'), |
|
57 | - FormStatus::SHARED => esc_html__('Shared', 'event_espresso'), |
|
58 | - FormStatus::TRASHED => esc_html__('Trashed', 'event_espresso'), |
|
59 | - ] |
|
60 | - ); |
|
61 | - } |
|
49 | + public function __construct() |
|
50 | + { |
|
51 | + $this->valid_status_options = apply_filters( |
|
52 | + 'FHEE__EventEspresso_core_services_form_meta_FormStatus__valid_status_options', |
|
53 | + [ |
|
54 | + FormStatus::ACTIVE => esc_html__('Active', 'event_espresso'), |
|
55 | + FormStatus::ARCHIVED => esc_html__('Archived', 'event_espresso'), |
|
56 | + FormStatus::DEFAULT => esc_html__('Default', 'event_espresso'), |
|
57 | + FormStatus::SHARED => esc_html__('Shared', 'event_espresso'), |
|
58 | + FormStatus::TRASHED => esc_html__('Trashed', 'event_espresso'), |
|
59 | + ] |
|
60 | + ); |
|
61 | + } |
|
62 | 62 | |
63 | 63 | |
64 | - /** |
|
65 | - * @return array |
|
66 | - */ |
|
67 | - public function getFormStatusValues(): array |
|
68 | - { |
|
69 | - $values = []; |
|
70 | - foreach ($this->valid_status_options as $value => $description) { |
|
71 | - $values[ GQLUtils::formatEnumKey($value) ] = compact('value', 'description'); |
|
72 | - } |
|
73 | - return $values; |
|
74 | - } |
|
64 | + /** |
|
65 | + * @return array |
|
66 | + */ |
|
67 | + public function getFormStatusValues(): array |
|
68 | + { |
|
69 | + $values = []; |
|
70 | + foreach ($this->valid_status_options as $value => $description) { |
|
71 | + $values[ GQLUtils::formatEnumKey($value) ] = compact('value', 'description'); |
|
72 | + } |
|
73 | + return $values; |
|
74 | + } |
|
75 | 75 | |
76 | 76 | |
77 | - /** |
|
78 | - * @param bool $constants_only |
|
79 | - * @return array |
|
80 | - */ |
|
81 | - public function validStatusOptions(bool $constants_only = false): array |
|
82 | - { |
|
83 | - return $constants_only |
|
84 | - ? array_keys($this->valid_status_options) |
|
85 | - : $this->valid_status_options; |
|
86 | - } |
|
77 | + /** |
|
78 | + * @param bool $constants_only |
|
79 | + * @return array |
|
80 | + */ |
|
81 | + public function validStatusOptions(bool $constants_only = false): array |
|
82 | + { |
|
83 | + return $constants_only |
|
84 | + ? array_keys($this->valid_status_options) |
|
85 | + : $this->valid_status_options; |
|
86 | + } |
|
87 | 87 | } |
@@ -116,7 +116,7 @@ |
||
116 | 116 | { |
117 | 117 | $values = []; |
118 | 118 | foreach ($this->valid_type_options as $value => $description) { |
119 | - $values[ GQLUtils::formatEnumKey($value) ] = compact('value', 'description'); |
|
119 | + $values[GQLUtils::formatEnumKey($value)] = compact('value', 'description'); |
|
120 | 120 | } |
121 | 121 | return $values; |
122 | 122 | } |
@@ -22,124 +22,124 @@ |
||
22 | 22 | */ |
23 | 23 | class InputTypes |
24 | 24 | { |
25 | - /** |
|
26 | - * @var Block |
|
27 | - */ |
|
28 | - private $block; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var Button |
|
32 | - */ |
|
33 | - private $button; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var DateTime |
|
37 | - */ |
|
38 | - private $datetime; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var Input |
|
42 | - */ |
|
43 | - private $input; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var Number |
|
47 | - */ |
|
48 | - private $number; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var Phone |
|
52 | - */ |
|
53 | - private $phone; |
|
54 | - |
|
55 | - /** |
|
56 | - * @var Select |
|
57 | - */ |
|
58 | - private $select; |
|
59 | - |
|
60 | - /** |
|
61 | - * @var Text |
|
62 | - */ |
|
63 | - private $text; |
|
64 | - |
|
65 | - /** |
|
66 | - * @var array |
|
67 | - */ |
|
68 | - private $valid_type_options; |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * InputTypes constructor. |
|
73 | - * |
|
74 | - * @param Block $block |
|
75 | - * @param Button $button |
|
76 | - * @param DateTime $datetime |
|
77 | - * @param Input $input |
|
78 | - * @param Number $number |
|
79 | - * @param Phone $phone |
|
80 | - * @param Select $select |
|
81 | - * @param Text $text |
|
82 | - */ |
|
83 | - public function __construct( |
|
84 | - Block $block, |
|
85 | - Button $button, |
|
86 | - DateTime $datetime, |
|
87 | - Input $input, |
|
88 | - Number $number, |
|
89 | - Phone $phone, |
|
90 | - Select $select, |
|
91 | - Text $text |
|
92 | - ) { |
|
93 | - $this->block = $block; |
|
94 | - $this->button = $button; |
|
95 | - $this->datetime = $datetime; |
|
96 | - $this->input = $input; |
|
97 | - $this->number = $number; |
|
98 | - $this->phone = $phone; |
|
99 | - $this->select = $select; |
|
100 | - $this->text = $text; |
|
101 | - $this->assembleValidTypeOptions(); |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - private function assembleValidTypeOptions() |
|
106 | - { |
|
107 | - $block = $this->block->validTypeOptions(); |
|
108 | - $button = $this->button->validTypeOptions(); |
|
109 | - $datetime = $this->datetime->validTypeOptions(); |
|
110 | - $input = $this->input->validTypeOptions(); |
|
111 | - $number = $this->number->validTypeOptions(); |
|
112 | - $phone = $this->phone->validTypeOptions(); |
|
113 | - $select = $this->select->validTypeOptions(); |
|
114 | - $text = $this->text->validTypeOptions(); |
|
115 | - $this->valid_type_options = apply_filters( |
|
116 | - 'FHEE__EventEspresso_core_services_form_meta_InputTypes__valid_type_options', |
|
117 | - array_merge($block, $button, $datetime, $input, $number, $phone, $select, $text) |
|
118 | - ); |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * @return array |
|
124 | - */ |
|
125 | - public function getInputTypesValues(): array |
|
126 | - { |
|
127 | - $values = []; |
|
128 | - foreach ($this->valid_type_options as $value => $description) { |
|
129 | - $values[ GQLUtils::formatEnumKey($value) ] = compact('value', 'description'); |
|
130 | - } |
|
131 | - return $values; |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * @param bool $constants_only |
|
137 | - * @return array |
|
138 | - */ |
|
139 | - public function validTypeOptions(bool $constants_only = false): array |
|
140 | - { |
|
141 | - return $constants_only |
|
142 | - ? array_keys($this->valid_type_options) |
|
143 | - : $this->valid_type_options; |
|
144 | - } |
|
25 | + /** |
|
26 | + * @var Block |
|
27 | + */ |
|
28 | + private $block; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var Button |
|
32 | + */ |
|
33 | + private $button; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var DateTime |
|
37 | + */ |
|
38 | + private $datetime; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var Input |
|
42 | + */ |
|
43 | + private $input; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var Number |
|
47 | + */ |
|
48 | + private $number; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var Phone |
|
52 | + */ |
|
53 | + private $phone; |
|
54 | + |
|
55 | + /** |
|
56 | + * @var Select |
|
57 | + */ |
|
58 | + private $select; |
|
59 | + |
|
60 | + /** |
|
61 | + * @var Text |
|
62 | + */ |
|
63 | + private $text; |
|
64 | + |
|
65 | + /** |
|
66 | + * @var array |
|
67 | + */ |
|
68 | + private $valid_type_options; |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * InputTypes constructor. |
|
73 | + * |
|
74 | + * @param Block $block |
|
75 | + * @param Button $button |
|
76 | + * @param DateTime $datetime |
|
77 | + * @param Input $input |
|
78 | + * @param Number $number |
|
79 | + * @param Phone $phone |
|
80 | + * @param Select $select |
|
81 | + * @param Text $text |
|
82 | + */ |
|
83 | + public function __construct( |
|
84 | + Block $block, |
|
85 | + Button $button, |
|
86 | + DateTime $datetime, |
|
87 | + Input $input, |
|
88 | + Number $number, |
|
89 | + Phone $phone, |
|
90 | + Select $select, |
|
91 | + Text $text |
|
92 | + ) { |
|
93 | + $this->block = $block; |
|
94 | + $this->button = $button; |
|
95 | + $this->datetime = $datetime; |
|
96 | + $this->input = $input; |
|
97 | + $this->number = $number; |
|
98 | + $this->phone = $phone; |
|
99 | + $this->select = $select; |
|
100 | + $this->text = $text; |
|
101 | + $this->assembleValidTypeOptions(); |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + private function assembleValidTypeOptions() |
|
106 | + { |
|
107 | + $block = $this->block->validTypeOptions(); |
|
108 | + $button = $this->button->validTypeOptions(); |
|
109 | + $datetime = $this->datetime->validTypeOptions(); |
|
110 | + $input = $this->input->validTypeOptions(); |
|
111 | + $number = $this->number->validTypeOptions(); |
|
112 | + $phone = $this->phone->validTypeOptions(); |
|
113 | + $select = $this->select->validTypeOptions(); |
|
114 | + $text = $this->text->validTypeOptions(); |
|
115 | + $this->valid_type_options = apply_filters( |
|
116 | + 'FHEE__EventEspresso_core_services_form_meta_InputTypes__valid_type_options', |
|
117 | + array_merge($block, $button, $datetime, $input, $number, $phone, $select, $text) |
|
118 | + ); |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * @return array |
|
124 | + */ |
|
125 | + public function getInputTypesValues(): array |
|
126 | + { |
|
127 | + $values = []; |
|
128 | + foreach ($this->valid_type_options as $value => $description) { |
|
129 | + $values[ GQLUtils::formatEnumKey($value) ] = compact('value', 'description'); |
|
130 | + } |
|
131 | + return $values; |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * @param bool $constants_only |
|
137 | + * @return array |
|
138 | + */ |
|
139 | + public function validTypeOptions(bool $constants_only = false): array |
|
140 | + { |
|
141 | + return $constants_only |
|
142 | + ? array_keys($this->valid_type_options) |
|
143 | + : $this->valid_type_options; |
|
144 | + } |
|
145 | 145 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function __construct($url) |
53 | 53 | { |
54 | - if (! filter_var($url, FILTER_VALIDATE_URL)) { |
|
54 | + if ( ! filter_var($url, FILTER_VALIDATE_URL)) { |
|
55 | 55 | throw new InvalidArgumentException( |
56 | 56 | esc_html__( |
57 | 57 | 'Invalid URL. Both the "Scheme" and "Host" are required.', |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | private function setScheme($url) |
87 | 87 | { |
88 | - $this->scheme = $url['scheme'] . '://'; |
|
88 | + $this->scheme = $url['scheme'].'://'; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function queryString() |
141 | 141 | { |
142 | - return $this->query !== '' ? '?' . $this->query : ''; |
|
142 | + return $this->query !== '' ? '?'.$this->query : ''; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | */ |
173 | 173 | public function fragment() |
174 | 174 | { |
175 | - return $this->fragment !== '' ? '#' . $this->fragment : ''; |
|
175 | + return $this->fragment !== '' ? '#'.$this->fragment : ''; |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | public function getFullUrl() |
195 | 195 | { |
196 | - return $this->scheme() . $this->host() . $this->path() . $this->queryString() . $this->fragment(); |
|
196 | + return $this->scheme().$this->host().$this->path().$this->queryString().$this->fragment(); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 |
@@ -16,194 +16,194 @@ |
||
16 | 16 | */ |
17 | 17 | class Url |
18 | 18 | { |
19 | - /** |
|
20 | - * @var string $scheme |
|
21 | - */ |
|
22 | - private $scheme; |
|
23 | - |
|
24 | - /** |
|
25 | - * @var string $host |
|
26 | - */ |
|
27 | - private $host; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var string $path |
|
31 | - */ |
|
32 | - private $path; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var string $query |
|
36 | - */ |
|
37 | - private $query; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var string $fragment |
|
41 | - */ |
|
42 | - private $fragment; |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * Url constructor. |
|
47 | - * |
|
48 | - * @param $url |
|
49 | - * @throws InvalidArgumentException |
|
50 | - */ |
|
51 | - public function __construct($url) |
|
52 | - { |
|
53 | - if (! filter_var($url, FILTER_VALIDATE_URL)) { |
|
54 | - throw new InvalidArgumentException( |
|
55 | - esc_html__( |
|
56 | - 'Invalid URL. Both the "Scheme" and "Host" are required.', |
|
57 | - 'event_espresso' |
|
58 | - ) |
|
59 | - ); |
|
60 | - } |
|
61 | - $url = parse_url($url); |
|
62 | - $this->setScheme($url); |
|
63 | - $this->setHost($url); |
|
64 | - $this->setPath($url); |
|
65 | - $this->setQuery($url); |
|
66 | - $this->setFragment($url); |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
72 | - * will return a string like: 'abc://' |
|
73 | - * |
|
74 | - * @return string |
|
75 | - */ |
|
76 | - public function scheme() |
|
77 | - { |
|
78 | - return $this->scheme; |
|
79 | - } |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * @param array $url |
|
84 | - */ |
|
85 | - private function setScheme($url) |
|
86 | - { |
|
87 | - $this->scheme = $url['scheme'] . '://'; |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
93 | - * will return a string like: 'example.com' |
|
94 | - * |
|
95 | - * @return string |
|
96 | - */ |
|
97 | - public function host() |
|
98 | - { |
|
99 | - return $this->host; |
|
100 | - } |
|
101 | - |
|
102 | - |
|
103 | - /** |
|
104 | - * @param array $url |
|
105 | - */ |
|
106 | - private function setHost($url) |
|
107 | - { |
|
108 | - $this->host = $url['host']; |
|
109 | - } |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
114 | - * will return a string like: '/path/data' |
|
115 | - * |
|
116 | - * @return string |
|
117 | - */ |
|
118 | - public function path() |
|
119 | - { |
|
120 | - return $this->path; |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * @param array $url |
|
126 | - */ |
|
127 | - private function setPath($url) |
|
128 | - { |
|
129 | - $this->path = isset($url['path']) ? $url['path'] : ''; |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - /** |
|
134 | - * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
135 | - * will return a string like: '?key=value' |
|
136 | - * |
|
137 | - * @return string |
|
138 | - */ |
|
139 | - public function queryString() |
|
140 | - { |
|
141 | - return $this->query !== '' ? '?' . $this->query : ''; |
|
142 | - } |
|
143 | - |
|
144 | - |
|
145 | - /** |
|
146 | - * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
147 | - * will return an array like: array('key' => 'value') |
|
148 | - * |
|
149 | - * @return array |
|
150 | - */ |
|
151 | - public function queryParams() |
|
152 | - { |
|
153 | - return wp_parse_args($this->query); |
|
154 | - } |
|
155 | - |
|
156 | - |
|
157 | - /** |
|
158 | - * @param array $url |
|
159 | - */ |
|
160 | - private function setQuery($url) |
|
161 | - { |
|
162 | - $this->query = isset($url['query']) ? $url['query'] : ''; |
|
163 | - } |
|
164 | - |
|
165 | - |
|
166 | - /** |
|
167 | - * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
168 | - * will return a string like: '#id' |
|
169 | - * |
|
170 | - * @return string |
|
171 | - */ |
|
172 | - public function fragment() |
|
173 | - { |
|
174 | - return $this->fragment !== '' ? '#' . $this->fragment : ''; |
|
175 | - } |
|
176 | - |
|
177 | - |
|
178 | - /** |
|
179 | - * @param array $url |
|
180 | - */ |
|
181 | - private function setFragment($url) |
|
182 | - { |
|
183 | - $this->fragment = isset($url['fragment']) ? $url['fragment'] : ''; |
|
184 | - } |
|
185 | - |
|
186 | - |
|
187 | - /** |
|
188 | - * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
189 | - * will return a string like: 'abc://example.com/path/data?key=value#id' |
|
190 | - * |
|
191 | - * @return string |
|
192 | - */ |
|
193 | - public function getFullUrl() |
|
194 | - { |
|
195 | - return $this->scheme() . $this->host() . $this->path() . $this->queryString() . $this->fragment(); |
|
196 | - } |
|
197 | - |
|
198 | - |
|
199 | - /** |
|
200 | - * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
201 | - * will return a string like: 'abc://example.com/path/data?key=value#id' |
|
202 | - * |
|
203 | - * @return string |
|
204 | - */ |
|
205 | - public function __toString() |
|
206 | - { |
|
207 | - return $this->getFullUrl(); |
|
208 | - } |
|
19 | + /** |
|
20 | + * @var string $scheme |
|
21 | + */ |
|
22 | + private $scheme; |
|
23 | + |
|
24 | + /** |
|
25 | + * @var string $host |
|
26 | + */ |
|
27 | + private $host; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var string $path |
|
31 | + */ |
|
32 | + private $path; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var string $query |
|
36 | + */ |
|
37 | + private $query; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var string $fragment |
|
41 | + */ |
|
42 | + private $fragment; |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * Url constructor. |
|
47 | + * |
|
48 | + * @param $url |
|
49 | + * @throws InvalidArgumentException |
|
50 | + */ |
|
51 | + public function __construct($url) |
|
52 | + { |
|
53 | + if (! filter_var($url, FILTER_VALIDATE_URL)) { |
|
54 | + throw new InvalidArgumentException( |
|
55 | + esc_html__( |
|
56 | + 'Invalid URL. Both the "Scheme" and "Host" are required.', |
|
57 | + 'event_espresso' |
|
58 | + ) |
|
59 | + ); |
|
60 | + } |
|
61 | + $url = parse_url($url); |
|
62 | + $this->setScheme($url); |
|
63 | + $this->setHost($url); |
|
64 | + $this->setPath($url); |
|
65 | + $this->setQuery($url); |
|
66 | + $this->setFragment($url); |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
72 | + * will return a string like: 'abc://' |
|
73 | + * |
|
74 | + * @return string |
|
75 | + */ |
|
76 | + public function scheme() |
|
77 | + { |
|
78 | + return $this->scheme; |
|
79 | + } |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * @param array $url |
|
84 | + */ |
|
85 | + private function setScheme($url) |
|
86 | + { |
|
87 | + $this->scheme = $url['scheme'] . '://'; |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
93 | + * will return a string like: 'example.com' |
|
94 | + * |
|
95 | + * @return string |
|
96 | + */ |
|
97 | + public function host() |
|
98 | + { |
|
99 | + return $this->host; |
|
100 | + } |
|
101 | + |
|
102 | + |
|
103 | + /** |
|
104 | + * @param array $url |
|
105 | + */ |
|
106 | + private function setHost($url) |
|
107 | + { |
|
108 | + $this->host = $url['host']; |
|
109 | + } |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
114 | + * will return a string like: '/path/data' |
|
115 | + * |
|
116 | + * @return string |
|
117 | + */ |
|
118 | + public function path() |
|
119 | + { |
|
120 | + return $this->path; |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * @param array $url |
|
126 | + */ |
|
127 | + private function setPath($url) |
|
128 | + { |
|
129 | + $this->path = isset($url['path']) ? $url['path'] : ''; |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + /** |
|
134 | + * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
135 | + * will return a string like: '?key=value' |
|
136 | + * |
|
137 | + * @return string |
|
138 | + */ |
|
139 | + public function queryString() |
|
140 | + { |
|
141 | + return $this->query !== '' ? '?' . $this->query : ''; |
|
142 | + } |
|
143 | + |
|
144 | + |
|
145 | + /** |
|
146 | + * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
147 | + * will return an array like: array('key' => 'value') |
|
148 | + * |
|
149 | + * @return array |
|
150 | + */ |
|
151 | + public function queryParams() |
|
152 | + { |
|
153 | + return wp_parse_args($this->query); |
|
154 | + } |
|
155 | + |
|
156 | + |
|
157 | + /** |
|
158 | + * @param array $url |
|
159 | + */ |
|
160 | + private function setQuery($url) |
|
161 | + { |
|
162 | + $this->query = isset($url['query']) ? $url['query'] : ''; |
|
163 | + } |
|
164 | + |
|
165 | + |
|
166 | + /** |
|
167 | + * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
168 | + * will return a string like: '#id' |
|
169 | + * |
|
170 | + * @return string |
|
171 | + */ |
|
172 | + public function fragment() |
|
173 | + { |
|
174 | + return $this->fragment !== '' ? '#' . $this->fragment : ''; |
|
175 | + } |
|
176 | + |
|
177 | + |
|
178 | + /** |
|
179 | + * @param array $url |
|
180 | + */ |
|
181 | + private function setFragment($url) |
|
182 | + { |
|
183 | + $this->fragment = isset($url['fragment']) ? $url['fragment'] : ''; |
|
184 | + } |
|
185 | + |
|
186 | + |
|
187 | + /** |
|
188 | + * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
189 | + * will return a string like: 'abc://example.com/path/data?key=value#id' |
|
190 | + * |
|
191 | + * @return string |
|
192 | + */ |
|
193 | + public function getFullUrl() |
|
194 | + { |
|
195 | + return $this->scheme() . $this->host() . $this->path() . $this->queryString() . $this->fragment(); |
|
196 | + } |
|
197 | + |
|
198 | + |
|
199 | + /** |
|
200 | + * For a URL like: abc://username:[email protected]:123/path/data?key=value#id |
|
201 | + * will return a string like: 'abc://example.com/path/data?key=value#id' |
|
202 | + * |
|
203 | + * @return string |
|
204 | + */ |
|
205 | + public function __toString() |
|
206 | + { |
|
207 | + return $this->getFullUrl(); |
|
208 | + } |
|
209 | 209 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | */ |
23 | 23 | public function __construct() |
24 | 24 | { |
25 | - $this->setName($this->namespace . 'ElementTypeEnum'); |
|
25 | + $this->setName($this->namespace.'ElementTypeEnum'); |
|
26 | 26 | $this->setDescription(esc_html__('Form element type.', 'event_espresso')); |
27 | 27 | parent::__construct(); |
28 | 28 | } |
@@ -16,24 +16,24 @@ |
||
16 | 16 | */ |
17 | 17 | class ElementTypeEnum extends EnumBase |
18 | 18 | { |
19 | - /** |
|
20 | - * ElementTypeEnum constructor. |
|
21 | - */ |
|
22 | - public function __construct() |
|
23 | - { |
|
24 | - $this->setName($this->namespace . 'ElementTypeEnum'); |
|
25 | - $this->setDescription(esc_html__('Form element type.', 'event_espresso')); |
|
26 | - parent::__construct(); |
|
27 | - } |
|
19 | + /** |
|
20 | + * ElementTypeEnum constructor. |
|
21 | + */ |
|
22 | + public function __construct() |
|
23 | + { |
|
24 | + $this->setName($this->namespace . 'ElementTypeEnum'); |
|
25 | + $this->setDescription(esc_html__('Form element type.', 'event_espresso')); |
|
26 | + parent::__construct(); |
|
27 | + } |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * @return array |
|
32 | - */ |
|
33 | - protected function getValues(): array |
|
34 | - { |
|
35 | - /** @var InputTypes $input_types */ |
|
36 | - $input_types = LoaderFactory::getShared('EventEspresso\core\services\form\meta\InputTypes'); |
|
37 | - return $input_types->getInputTypesValues(); |
|
38 | - } |
|
30 | + /** |
|
31 | + * @return array |
|
32 | + */ |
|
33 | + protected function getValues(): array |
|
34 | + { |
|
35 | + /** @var InputTypes $input_types */ |
|
36 | + $input_types = LoaderFactory::getShared('EventEspresso\core\services\form\meta\InputTypes'); |
|
37 | + return $input_types->getInputTypesValues(); |
|
38 | + } |
|
39 | 39 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | */ |
23 | 23 | public function __construct() |
24 | 24 | { |
25 | - $this->setName($this->namespace . 'FormStatusEnum'); |
|
25 | + $this->setName($this->namespace.'FormStatusEnum'); |
|
26 | 26 | $this->setDescription(esc_html__( |
27 | 27 | 'Whether form section or element is active, archived, shared, trashed, or used as a default on new forms.', |
28 | 28 | 'event_espresso' |
@@ -16,28 +16,28 @@ |
||
16 | 16 | */ |
17 | 17 | class FormStatusEnum extends EnumBase |
18 | 18 | { |
19 | - /** |
|
20 | - * FormStatusEnum constructor. |
|
21 | - */ |
|
22 | - public function __construct() |
|
23 | - { |
|
24 | - $this->setName($this->namespace . 'FormStatusEnum'); |
|
25 | - $this->setDescription(esc_html__( |
|
26 | - 'Whether form section or element is active, archived, shared, trashed, or used as a default on new forms.', |
|
27 | - 'event_espresso' |
|
28 | - )); |
|
29 | - parent::__construct(); |
|
30 | - } |
|
19 | + /** |
|
20 | + * FormStatusEnum constructor. |
|
21 | + */ |
|
22 | + public function __construct() |
|
23 | + { |
|
24 | + $this->setName($this->namespace . 'FormStatusEnum'); |
|
25 | + $this->setDescription(esc_html__( |
|
26 | + 'Whether form section or element is active, archived, shared, trashed, or used as a default on new forms.', |
|
27 | + 'event_espresso' |
|
28 | + )); |
|
29 | + parent::__construct(); |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * @return array |
|
35 | - */ |
|
36 | - protected function getValues(): array |
|
37 | - { |
|
38 | - /** @var FormStatus $form_status */ |
|
39 | - $form_status = LoaderFactory::getShared('EventEspresso\core\services\form\meta\FormStatus'); |
|
33 | + /** |
|
34 | + * @return array |
|
35 | + */ |
|
36 | + protected function getValues(): array |
|
37 | + { |
|
38 | + /** @var FormStatus $form_status */ |
|
39 | + $form_status = LoaderFactory::getShared('EventEspresso\core\services\form\meta\FormStatus'); |
|
40 | 40 | |
41 | - return $form_status->getFormStatusValues(); |
|
42 | - } |
|
41 | + return $form_status->getFormStatusValues(); |
|
42 | + } |
|
43 | 43 | } |
@@ -77,7 +77,7 @@ |
||
77 | 77 | $args['FIN_type'] = sanitize_text_field($input['type']); |
78 | 78 | } |
79 | 79 | |
80 | - if (! empty($input['wpUser'])) { |
|
80 | + if ( ! empty($input['wpUser'])) { |
|
81 | 81 | $parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser'])); |
82 | 82 | $args['FIN_wpUser'] = ! empty($parts['id']) ? $parts['id'] : null; |
83 | 83 | } |
@@ -17,74 +17,74 @@ |
||
17 | 17 | */ |
18 | 18 | class FormElementMutation |
19 | 19 | { |
20 | - /** |
|
21 | - * Maps the GraphQL input to a format that the model functions can use |
|
22 | - * |
|
23 | - * @param array $input Data coming from the GraphQL mutation query input |
|
24 | - * @return array |
|
25 | - */ |
|
26 | - public static function prepareFields(array $input): array |
|
27 | - { |
|
28 | - $args = []; |
|
29 | - |
|
30 | - if (isset($input['id'])) { |
|
31 | - $args['FIN_UUID'] = sanitize_text_field($input['id']); |
|
32 | - } |
|
33 | - |
|
34 | - if (isset($input['adminOnly'])) { |
|
35 | - $args['FIN_adminOnly'] = (bool) $input['adminOnly']; |
|
36 | - } |
|
37 | - |
|
38 | - if (isset($input['attributes'])) { |
|
39 | - $args['FIN_attributes'] = Attributes::fromJson(sanitize_text_field($input['attributes']))->toJson(); |
|
40 | - } |
|
41 | - |
|
42 | - if (isset($input['belongsTo'])) { |
|
43 | - $args['FSC_UUID'] = sanitize_text_field($input['belongsTo']); |
|
44 | - } |
|
45 | - |
|
46 | - if (isset($input['helpText'])) { |
|
47 | - $args['FIN_helpText'] = HelpText::fromJson(sanitize_text_field($input['helpText']))->toJson(); |
|
48 | - } |
|
49 | - |
|
50 | - if (isset($input['label'])) { |
|
51 | - $args['FIN_label'] = FormLabel::fromJson($input['label'])->toJson(); |
|
52 | - } |
|
53 | - |
|
54 | - if (isset($input['mapsTo'])) { |
|
55 | - $args['FIN_mapsTo'] = sanitize_text_field($input['mapsTo']); |
|
56 | - } |
|
57 | - |
|
58 | - if (isset($input['options'])) { |
|
59 | - $args['FIN_options'] = InputOptions::fromJson(sanitize_text_field($input['options']))->toJson(); |
|
60 | - } |
|
61 | - |
|
62 | - // order can be 0 |
|
63 | - if (array_key_exists('order', $input)) { |
|
64 | - $args['FIN_order'] = absint($input['order']); |
|
65 | - } |
|
66 | - |
|
67 | - if (isset($input['required'])) { |
|
68 | - $args['FIN_required'] = Required::fromJson(sanitize_text_field($input['required']))->toJson(); |
|
69 | - } |
|
70 | - |
|
71 | - if (isset($input['status'])) { |
|
72 | - $args['FIN_status'] = sanitize_text_field($input['status']); |
|
73 | - } |
|
74 | - |
|
75 | - if (isset($input['type'])) { |
|
76 | - $args['FIN_type'] = sanitize_text_field($input['type']); |
|
77 | - } |
|
78 | - |
|
79 | - if (! empty($input['wpUser'])) { |
|
80 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser'])); |
|
81 | - $args['FIN_wpUser'] = ! empty($parts['id']) ? $parts['id'] : null; |
|
82 | - } |
|
83 | - |
|
84 | - return apply_filters( |
|
85 | - 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__form_element_args', |
|
86 | - $args, |
|
87 | - $input |
|
88 | - ); |
|
89 | - } |
|
20 | + /** |
|
21 | + * Maps the GraphQL input to a format that the model functions can use |
|
22 | + * |
|
23 | + * @param array $input Data coming from the GraphQL mutation query input |
|
24 | + * @return array |
|
25 | + */ |
|
26 | + public static function prepareFields(array $input): array |
|
27 | + { |
|
28 | + $args = []; |
|
29 | + |
|
30 | + if (isset($input['id'])) { |
|
31 | + $args['FIN_UUID'] = sanitize_text_field($input['id']); |
|
32 | + } |
|
33 | + |
|
34 | + if (isset($input['adminOnly'])) { |
|
35 | + $args['FIN_adminOnly'] = (bool) $input['adminOnly']; |
|
36 | + } |
|
37 | + |
|
38 | + if (isset($input['attributes'])) { |
|
39 | + $args['FIN_attributes'] = Attributes::fromJson(sanitize_text_field($input['attributes']))->toJson(); |
|
40 | + } |
|
41 | + |
|
42 | + if (isset($input['belongsTo'])) { |
|
43 | + $args['FSC_UUID'] = sanitize_text_field($input['belongsTo']); |
|
44 | + } |
|
45 | + |
|
46 | + if (isset($input['helpText'])) { |
|
47 | + $args['FIN_helpText'] = HelpText::fromJson(sanitize_text_field($input['helpText']))->toJson(); |
|
48 | + } |
|
49 | + |
|
50 | + if (isset($input['label'])) { |
|
51 | + $args['FIN_label'] = FormLabel::fromJson($input['label'])->toJson(); |
|
52 | + } |
|
53 | + |
|
54 | + if (isset($input['mapsTo'])) { |
|
55 | + $args['FIN_mapsTo'] = sanitize_text_field($input['mapsTo']); |
|
56 | + } |
|
57 | + |
|
58 | + if (isset($input['options'])) { |
|
59 | + $args['FIN_options'] = InputOptions::fromJson(sanitize_text_field($input['options']))->toJson(); |
|
60 | + } |
|
61 | + |
|
62 | + // order can be 0 |
|
63 | + if (array_key_exists('order', $input)) { |
|
64 | + $args['FIN_order'] = absint($input['order']); |
|
65 | + } |
|
66 | + |
|
67 | + if (isset($input['required'])) { |
|
68 | + $args['FIN_required'] = Required::fromJson(sanitize_text_field($input['required']))->toJson(); |
|
69 | + } |
|
70 | + |
|
71 | + if (isset($input['status'])) { |
|
72 | + $args['FIN_status'] = sanitize_text_field($input['status']); |
|
73 | + } |
|
74 | + |
|
75 | + if (isset($input['type'])) { |
|
76 | + $args['FIN_type'] = sanitize_text_field($input['type']); |
|
77 | + } |
|
78 | + |
|
79 | + if (! empty($input['wpUser'])) { |
|
80 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser'])); |
|
81 | + $args['FIN_wpUser'] = ! empty($parts['id']) ? $parts['id'] : null; |
|
82 | + } |
|
83 | + |
|
84 | + return apply_filters( |
|
85 | + 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__form_element_args', |
|
86 | + $args, |
|
87 | + $input |
|
88 | + ); |
|
89 | + } |
|
90 | 90 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function __construct(EEM_Form_Element $form_element_model) |
36 | 36 | { |
37 | - $this->setName($this->namespace . 'FormElement'); |
|
37 | + $this->setName($this->namespace.'FormElement'); |
|
38 | 38 | $this->setDescription(__('A form element', 'event_espresso')); |
39 | 39 | $this->setIsCustomPostType(false); |
40 | 40 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | ), |
134 | 134 | new GraphQLField( |
135 | 135 | 'status', |
136 | - $this->namespace . 'FormStatusEnum', |
|
136 | + $this->namespace.'FormStatusEnum', |
|
137 | 137 | 'status', |
138 | 138 | esc_html__( |
139 | 139 | 'Whether form element is active, archived, trashed, or used as a default on new forms.', |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | ), |
143 | 143 | new GraphQLField( |
144 | 144 | 'type', |
145 | - $this->namespace . 'ElementTypeEnum', |
|
145 | + $this->namespace.'ElementTypeEnum', |
|
146 | 146 | 'type', |
147 | 147 | esc_html__('Form element type.', 'event_espresso') |
148 | 148 | ), |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | { |
181 | 181 | // Register mutation to update an entity. |
182 | 182 | register_graphql_mutation( |
183 | - 'update' . $this->name(), |
|
183 | + 'update'.$this->name(), |
|
184 | 184 | [ |
185 | 185 | 'inputFields' => $inputFields, |
186 | 186 | 'outputFields' => [ |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | ); |
195 | 195 | // Register mutation to delete an entity. |
196 | 196 | register_graphql_mutation( |
197 | - 'delete' . $this->name(), |
|
197 | + 'delete'.$this->name(), |
|
198 | 198 | [ |
199 | 199 | 'inputFields' => [ |
200 | 200 | 'id' => $inputFields['id'], |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | lcfirst($this->name()) => [ |
204 | 204 | 'type' => $this->name(), |
205 | 205 | 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
206 | - 'resolve' => static function ($payload) { |
|
206 | + 'resolve' => static function($payload) { |
|
207 | 207 | $deleted = (object) $payload['deleted']; |
208 | 208 | |
209 | 209 | return ! empty($deleted) ? $deleted : null; |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | |
221 | 221 | // Register mutation to update an entity. |
222 | 222 | register_graphql_mutation( |
223 | - 'create' . $this->name(), |
|
223 | + 'create'.$this->name(), |
|
224 | 224 | [ |
225 | 225 | 'inputFields' => $inputFields, |
226 | 226 | 'outputFields' => [ |
@@ -26,210 +26,210 @@ |
||
26 | 26 | */ |
27 | 27 | class FormElement extends TypeBase |
28 | 28 | { |
29 | - /** |
|
30 | - * FormElement constructor. |
|
31 | - * |
|
32 | - * @param EEM_Form_Element $form_element_model |
|
33 | - */ |
|
34 | - public function __construct(EEM_Form_Element $form_element_model) |
|
35 | - { |
|
36 | - $this->setName($this->namespace . 'FormElement'); |
|
37 | - $this->setDescription(__('A form element', 'event_espresso')); |
|
38 | - $this->setIsCustomPostType(false); |
|
29 | + /** |
|
30 | + * FormElement constructor. |
|
31 | + * |
|
32 | + * @param EEM_Form_Element $form_element_model |
|
33 | + */ |
|
34 | + public function __construct(EEM_Form_Element $form_element_model) |
|
35 | + { |
|
36 | + $this->setName($this->namespace . 'FormElement'); |
|
37 | + $this->setDescription(__('A form element', 'event_espresso')); |
|
38 | + $this->setIsCustomPostType(false); |
|
39 | 39 | |
40 | - parent::__construct($form_element_model); |
|
41 | - } |
|
40 | + parent::__construct($form_element_model); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * @return GraphQLFieldInterface[] |
|
46 | - */ |
|
47 | - public function getFields(): array |
|
48 | - { |
|
49 | - $fields = [ |
|
50 | - new GraphQLField( |
|
51 | - 'id', |
|
52 | - ['non_null' => 'ID'], |
|
53 | - null, |
|
54 | - esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
55 | - ), |
|
56 | - new GraphQLField( |
|
57 | - 'adminOnly', |
|
58 | - 'Boolean', |
|
59 | - 'adminOnly', |
|
60 | - esc_html__( |
|
61 | - 'Whether or not the element is only displayed in the admin. If false, input will appear in public forms', |
|
62 | - 'event_espresso' |
|
63 | - ) |
|
64 | - ), |
|
65 | - new GraphQLField( |
|
66 | - 'attributes', |
|
67 | - 'String', |
|
68 | - 'attributes', |
|
69 | - esc_html__( |
|
70 | - 'JSON string of HTML attributes such as class, max, min, placeholder, type, etc.', |
|
71 | - 'event_espresso' |
|
72 | - ), |
|
73 | - [$this, 'toJson'] |
|
74 | - ), |
|
75 | - new GraphQLField( |
|
76 | - 'belongsTo', |
|
77 | - 'String', |
|
78 | - 'belongsTo', |
|
79 | - esc_html__('UUID of parent form section this form element belongs to.', 'event_espresso') |
|
80 | - ), |
|
81 | - new GraphQLField( |
|
82 | - 'helpText', |
|
83 | - 'String', |
|
84 | - 'helpText', |
|
85 | - esc_html__( |
|
86 | - "JSON string of properties pertaining to any help text required for an input.", |
|
87 | - 'event_espresso' |
|
88 | - ), |
|
89 | - [$this, 'toJson'] |
|
90 | - ), |
|
91 | - new GraphQLField( |
|
92 | - 'label', |
|
93 | - 'String', |
|
94 | - 'label', |
|
95 | - esc_html__( |
|
96 | - 'JSON string of properties pertaining to an element\'s label.', |
|
97 | - 'event_espresso' |
|
98 | - ), |
|
99 | - [$this, 'toJson'] |
|
100 | - ), |
|
101 | - new GraphQLField( |
|
102 | - 'mapsTo', |
|
103 | - 'String', |
|
104 | - 'mapsTo', |
|
105 | - esc_html__("Model and Fields name that this element maps to; ex: Attendee.email", 'event_espresso') |
|
106 | - ), |
|
107 | - new GraphQLField( |
|
108 | - 'options', |
|
109 | - 'String', |
|
110 | - 'options', |
|
111 | - esc_html__( |
|
112 | - "JSON string of options for ENUM type inputs like checkboxes, radio buttons, select inputs, etc.", |
|
113 | - 'event_espresso' |
|
114 | - ), |
|
115 | - [$this, 'toJson'] |
|
116 | - ), |
|
117 | - new GraphQLField( |
|
118 | - 'order', |
|
119 | - 'Int', |
|
120 | - 'order', |
|
121 | - esc_html__('Order in which form element appears in a form.', 'event_espresso') |
|
122 | - ), |
|
123 | - new GraphQLField( |
|
124 | - 'required', |
|
125 | - 'String', |
|
126 | - 'required', |
|
127 | - esc_html__( |
|
128 | - "properties pertaining to an input\'s required status and the validation text to display.", |
|
129 | - 'event_espresso' |
|
130 | - ), |
|
131 | - [$this, 'toJson'] |
|
132 | - ), |
|
133 | - new GraphQLField( |
|
134 | - 'status', |
|
135 | - $this->namespace . 'FormStatusEnum', |
|
136 | - 'status', |
|
137 | - esc_html__( |
|
138 | - 'Whether form element is active, archived, trashed, or used as a default on new forms.', |
|
139 | - 'event_espresso' |
|
140 | - ) |
|
141 | - ), |
|
142 | - new GraphQLField( |
|
143 | - 'type', |
|
144 | - $this->namespace . 'ElementTypeEnum', |
|
145 | - 'type', |
|
146 | - esc_html__('Form element type.', 'event_espresso') |
|
147 | - ), |
|
148 | - new GraphQLOutputField( |
|
149 | - 'wpUser', |
|
150 | - 'User', |
|
151 | - null, |
|
152 | - esc_html__('WP User that created this form element.', 'event_espresso') |
|
153 | - ), |
|
154 | - new GraphQLInputField( |
|
155 | - 'wpUser', |
|
156 | - 'ID', |
|
157 | - null, |
|
158 | - esc_html__('ID of the WP User that created the form element.', 'event_espresso') |
|
159 | - ), |
|
160 | - ]; |
|
44 | + /** |
|
45 | + * @return GraphQLFieldInterface[] |
|
46 | + */ |
|
47 | + public function getFields(): array |
|
48 | + { |
|
49 | + $fields = [ |
|
50 | + new GraphQLField( |
|
51 | + 'id', |
|
52 | + ['non_null' => 'ID'], |
|
53 | + null, |
|
54 | + esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
55 | + ), |
|
56 | + new GraphQLField( |
|
57 | + 'adminOnly', |
|
58 | + 'Boolean', |
|
59 | + 'adminOnly', |
|
60 | + esc_html__( |
|
61 | + 'Whether or not the element is only displayed in the admin. If false, input will appear in public forms', |
|
62 | + 'event_espresso' |
|
63 | + ) |
|
64 | + ), |
|
65 | + new GraphQLField( |
|
66 | + 'attributes', |
|
67 | + 'String', |
|
68 | + 'attributes', |
|
69 | + esc_html__( |
|
70 | + 'JSON string of HTML attributes such as class, max, min, placeholder, type, etc.', |
|
71 | + 'event_espresso' |
|
72 | + ), |
|
73 | + [$this, 'toJson'] |
|
74 | + ), |
|
75 | + new GraphQLField( |
|
76 | + 'belongsTo', |
|
77 | + 'String', |
|
78 | + 'belongsTo', |
|
79 | + esc_html__('UUID of parent form section this form element belongs to.', 'event_espresso') |
|
80 | + ), |
|
81 | + new GraphQLField( |
|
82 | + 'helpText', |
|
83 | + 'String', |
|
84 | + 'helpText', |
|
85 | + esc_html__( |
|
86 | + "JSON string of properties pertaining to any help text required for an input.", |
|
87 | + 'event_espresso' |
|
88 | + ), |
|
89 | + [$this, 'toJson'] |
|
90 | + ), |
|
91 | + new GraphQLField( |
|
92 | + 'label', |
|
93 | + 'String', |
|
94 | + 'label', |
|
95 | + esc_html__( |
|
96 | + 'JSON string of properties pertaining to an element\'s label.', |
|
97 | + 'event_espresso' |
|
98 | + ), |
|
99 | + [$this, 'toJson'] |
|
100 | + ), |
|
101 | + new GraphQLField( |
|
102 | + 'mapsTo', |
|
103 | + 'String', |
|
104 | + 'mapsTo', |
|
105 | + esc_html__("Model and Fields name that this element maps to; ex: Attendee.email", 'event_espresso') |
|
106 | + ), |
|
107 | + new GraphQLField( |
|
108 | + 'options', |
|
109 | + 'String', |
|
110 | + 'options', |
|
111 | + esc_html__( |
|
112 | + "JSON string of options for ENUM type inputs like checkboxes, radio buttons, select inputs, etc.", |
|
113 | + 'event_espresso' |
|
114 | + ), |
|
115 | + [$this, 'toJson'] |
|
116 | + ), |
|
117 | + new GraphQLField( |
|
118 | + 'order', |
|
119 | + 'Int', |
|
120 | + 'order', |
|
121 | + esc_html__('Order in which form element appears in a form.', 'event_espresso') |
|
122 | + ), |
|
123 | + new GraphQLField( |
|
124 | + 'required', |
|
125 | + 'String', |
|
126 | + 'required', |
|
127 | + esc_html__( |
|
128 | + "properties pertaining to an input\'s required status and the validation text to display.", |
|
129 | + 'event_espresso' |
|
130 | + ), |
|
131 | + [$this, 'toJson'] |
|
132 | + ), |
|
133 | + new GraphQLField( |
|
134 | + 'status', |
|
135 | + $this->namespace . 'FormStatusEnum', |
|
136 | + 'status', |
|
137 | + esc_html__( |
|
138 | + 'Whether form element is active, archived, trashed, or used as a default on new forms.', |
|
139 | + 'event_espresso' |
|
140 | + ) |
|
141 | + ), |
|
142 | + new GraphQLField( |
|
143 | + 'type', |
|
144 | + $this->namespace . 'ElementTypeEnum', |
|
145 | + 'type', |
|
146 | + esc_html__('Form element type.', 'event_espresso') |
|
147 | + ), |
|
148 | + new GraphQLOutputField( |
|
149 | + 'wpUser', |
|
150 | + 'User', |
|
151 | + null, |
|
152 | + esc_html__('WP User that created this form element.', 'event_espresso') |
|
153 | + ), |
|
154 | + new GraphQLInputField( |
|
155 | + 'wpUser', |
|
156 | + 'ID', |
|
157 | + null, |
|
158 | + esc_html__('ID of the WP User that created the form element.', 'event_espresso') |
|
159 | + ), |
|
160 | + ]; |
|
161 | 161 | |
162 | - return apply_filters( |
|
163 | - 'FHEE__EventEspresso_core_domain_services_graphql_types__form_element_fields', |
|
164 | - $fields, |
|
165 | - $this->name, |
|
166 | - $this->model |
|
167 | - ); |
|
168 | - } |
|
162 | + return apply_filters( |
|
163 | + 'FHEE__EventEspresso_core_domain_services_graphql_types__form_element_fields', |
|
164 | + $fields, |
|
165 | + $this->name, |
|
166 | + $this->model |
|
167 | + ); |
|
168 | + } |
|
169 | 169 | |
170 | 170 | |
171 | - /** |
|
172 | - * @param array $inputFields The mutation input fields. |
|
173 | - * @throws InvalidArgumentException |
|
174 | - * @throws ReflectionException |
|
175 | - * @throws Exception |
|
176 | - * @since 5.0.0.p |
|
177 | - */ |
|
178 | - public function registerMutations(array $inputFields) |
|
179 | - { |
|
180 | - // Register mutation to update an entity. |
|
181 | - register_graphql_mutation( |
|
182 | - 'update' . $this->name(), |
|
183 | - [ |
|
184 | - 'inputFields' => $inputFields, |
|
185 | - 'outputFields' => [ |
|
186 | - lcfirst($this->name()) => [ |
|
187 | - 'type' => $this->name(), |
|
188 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
189 | - ], |
|
190 | - ], |
|
191 | - 'mutateAndGetPayload' => FormElementUpdate::mutateAndGetPayload($this->model), |
|
192 | - ] |
|
193 | - ); |
|
194 | - // Register mutation to delete an entity. |
|
195 | - register_graphql_mutation( |
|
196 | - 'delete' . $this->name(), |
|
197 | - [ |
|
198 | - 'inputFields' => [ |
|
199 | - 'id' => $inputFields['id'], |
|
200 | - ], |
|
201 | - 'outputFields' => [ |
|
202 | - lcfirst($this->name()) => [ |
|
203 | - 'type' => $this->name(), |
|
204 | - 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
205 | - 'resolve' => static function ($payload) { |
|
206 | - $deleted = (object) $payload['deleted']; |
|
171 | + /** |
|
172 | + * @param array $inputFields The mutation input fields. |
|
173 | + * @throws InvalidArgumentException |
|
174 | + * @throws ReflectionException |
|
175 | + * @throws Exception |
|
176 | + * @since 5.0.0.p |
|
177 | + */ |
|
178 | + public function registerMutations(array $inputFields) |
|
179 | + { |
|
180 | + // Register mutation to update an entity. |
|
181 | + register_graphql_mutation( |
|
182 | + 'update' . $this->name(), |
|
183 | + [ |
|
184 | + 'inputFields' => $inputFields, |
|
185 | + 'outputFields' => [ |
|
186 | + lcfirst($this->name()) => [ |
|
187 | + 'type' => $this->name(), |
|
188 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
189 | + ], |
|
190 | + ], |
|
191 | + 'mutateAndGetPayload' => FormElementUpdate::mutateAndGetPayload($this->model), |
|
192 | + ] |
|
193 | + ); |
|
194 | + // Register mutation to delete an entity. |
|
195 | + register_graphql_mutation( |
|
196 | + 'delete' . $this->name(), |
|
197 | + [ |
|
198 | + 'inputFields' => [ |
|
199 | + 'id' => $inputFields['id'], |
|
200 | + ], |
|
201 | + 'outputFields' => [ |
|
202 | + lcfirst($this->name()) => [ |
|
203 | + 'type' => $this->name(), |
|
204 | + 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
205 | + 'resolve' => static function ($payload) { |
|
206 | + $deleted = (object) $payload['deleted']; |
|
207 | 207 | |
208 | - return ! empty($deleted) ? $deleted : null; |
|
209 | - }, |
|
210 | - ], |
|
211 | - ], |
|
212 | - 'mutateAndGetPayload' => FormElementDelete::mutateAndGetPayload($this->model), |
|
213 | - ] |
|
214 | - ); |
|
208 | + return ! empty($deleted) ? $deleted : null; |
|
209 | + }, |
|
210 | + ], |
|
211 | + ], |
|
212 | + 'mutateAndGetPayload' => FormElementDelete::mutateAndGetPayload($this->model), |
|
213 | + ] |
|
214 | + ); |
|
215 | 215 | |
216 | - // Make element 'type' a required field for create mutations |
|
217 | - // Yes it's "['type']['type']" |