@@ -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 $VID:$ |
|
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 $VID:$ |
|
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']" |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function __construct(EEM_Form_Section $form_section_model) |
36 | 36 | { |
37 | - $this->setName($this->namespace . 'FormSection'); |
|
37 | + $this->setName($this->namespace.'FormSection'); |
|
38 | 38 | $this->setDescription(__('A form section', 'event_espresso')); |
39 | 39 | $this->setIsCustomPostType(false); |
40 | 40 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | ), |
57 | 57 | new GraphQLField( |
58 | 58 | 'appliesTo', |
59 | - $this->namespace . 'FormSectionAppliesToEnum', |
|
59 | + $this->namespace.'FormSectionAppliesToEnum', |
|
60 | 60 | 'appliesTo', |
61 | 61 | esc_html__('Form user type that this form section should be presented to.', 'event_espresso') |
62 | 62 | ), |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | ), |
95 | 95 | new GraphQLField( |
96 | 96 | 'status', |
97 | - $this->namespace . 'FormStatusEnum', |
|
97 | + $this->namespace.'FormStatusEnum', |
|
98 | 98 | 'status', |
99 | 99 | esc_html__( |
100 | 100 | 'Whether form section is active, archived, shared, trashed, or used as a default on new forms.', |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | { |
136 | 136 | // Register mutation to update an entity. |
137 | 137 | register_graphql_mutation( |
138 | - 'update' . $this->name(), |
|
138 | + 'update'.$this->name(), |
|
139 | 139 | [ |
140 | 140 | 'inputFields' => $inputFields, |
141 | 141 | 'outputFields' => [ |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | ); |
150 | 150 | // Register mutation to delete an entity. |
151 | 151 | register_graphql_mutation( |
152 | - 'delete' . $this->name(), |
|
152 | + 'delete'.$this->name(), |
|
153 | 153 | [ |
154 | 154 | 'inputFields' => [ |
155 | 155 | 'id' => $inputFields['id'], |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | lcfirst($this->name()) => [ |
159 | 159 | 'type' => $this->name(), |
160 | 160 | 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
161 | - 'resolve' => static function ($payload) { |
|
161 | + 'resolve' => static function($payload) { |
|
162 | 162 | $deleted = (object) $payload['deleted']; |
163 | 163 | |
164 | 164 | return ! empty($deleted) ? $deleted : null; |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | |
172 | 172 | // Register mutation to update an entity. |
173 | 173 | register_graphql_mutation( |
174 | - 'create' . $this->name(), |
|
174 | + 'create'.$this->name(), |
|
175 | 175 | [ |
176 | 176 | 'inputFields' => $inputFields, |
177 | 177 | 'outputFields' => [ |
@@ -26,191 +26,191 @@ |
||
26 | 26 | */ |
27 | 27 | class FormSection extends TypeBase |
28 | 28 | { |
29 | - /** |
|
30 | - * FormSection constructor. |
|
31 | - * |
|
32 | - * @param EEM_Form_Section $form_section_model |
|
33 | - */ |
|
34 | - public function __construct(EEM_Form_Section $form_section_model) |
|
35 | - { |
|
36 | - $this->setName($this->namespace . 'FormSection'); |
|
37 | - $this->setDescription(__('A form section', 'event_espresso')); |
|
38 | - $this->setIsCustomPostType(false); |
|
29 | + /** |
|
30 | + * FormSection constructor. |
|
31 | + * |
|
32 | + * @param EEM_Form_Section $form_section_model |
|
33 | + */ |
|
34 | + public function __construct(EEM_Form_Section $form_section_model) |
|
35 | + { |
|
36 | + $this->setName($this->namespace . 'FormSection'); |
|
37 | + $this->setDescription(__('A form section', 'event_espresso')); |
|
38 | + $this->setIsCustomPostType(false); |
|
39 | 39 | |
40 | - parent::__construct($form_section_model); |
|
41 | - } |
|
40 | + parent::__construct($form_section_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 | - 'appliesTo', |
|
58 | - $this->namespace . 'FormSectionAppliesToEnum', |
|
59 | - 'appliesTo', |
|
60 | - esc_html__('Form user type that this form section should be presented to.', 'event_espresso') |
|
61 | - ), |
|
62 | - new GraphQLField( |
|
63 | - 'attributes', |
|
64 | - 'String', |
|
65 | - 'attributes', |
|
66 | - esc_html__( |
|
67 | - 'JSON string of HTML attributes, such as class, to be applied to this form section\'s container.', |
|
68 | - 'event_espresso' |
|
69 | - ), |
|
70 | - [$this, 'toJson'] |
|
71 | - ), |
|
72 | - new GraphQLField( |
|
73 | - 'belongsTo', |
|
74 | - 'String', |
|
75 | - 'belongsTo', |
|
76 | - esc_html__('UUID or ID of related entity this form section belongs to.', 'event_espresso') |
|
77 | - ), |
|
78 | - new GraphQLOutputField( |
|
79 | - 'isActive', |
|
80 | - 'Boolean', |
|
81 | - 'isActive', |
|
82 | - esc_html__('Flag indicating whether the section is active.', 'event_espresso') |
|
83 | - ), |
|
84 | - new GraphQLOutputField( |
|
85 | - 'isArchived', |
|
86 | - 'Boolean', |
|
87 | - 'isArchived', |
|
88 | - esc_html__('Flag indicating whether the section is archived.', 'event_espresso') |
|
89 | - ), |
|
90 | - new GraphQLOutputField( |
|
91 | - 'isDefault', |
|
92 | - 'Boolean', |
|
93 | - 'isDefault', |
|
94 | - esc_html__('Flag indicating whether the section is a default one.', 'event_espresso') |
|
95 | - ), |
|
96 | - new GraphQLOutputField( |
|
97 | - 'isShared', |
|
98 | - 'Boolean', |
|
99 | - 'isShared', |
|
100 | - esc_html__('Flag indicating whether the section is a shared one.', 'event_espresso') |
|
101 | - ), |
|
102 | - new GraphQLOutputField( |
|
103 | - 'isTrashed', |
|
104 | - 'Boolean', |
|
105 | - 'isTrashed', |
|
106 | - esc_html__('Flag indicating whether the section is trashed.', 'event_espresso') |
|
107 | - ), |
|
108 | - new GraphQLField( |
|
109 | - 'label', |
|
110 | - 'String', |
|
111 | - 'label', |
|
112 | - esc_html__( |
|
113 | - 'JSON string of properties pertaining to a form section\'s label.', |
|
114 | - 'event_espresso' |
|
115 | - ), |
|
116 | - [$this, 'toJson'] |
|
117 | - ), |
|
118 | - new GraphQLField( |
|
119 | - 'order', |
|
120 | - 'Int', |
|
121 | - 'order', |
|
122 | - esc_html__('Order in which form section appears in a form.', 'event_espresso') |
|
123 | - ), |
|
124 | - new GraphQLField( |
|
125 | - 'status', |
|
126 | - $this->namespace . 'FormStatusEnum', |
|
127 | - 'status', |
|
128 | - esc_html__( |
|
129 | - 'Whether form section is active, archived, shared, trashed, or used as a default on new forms.', |
|
130 | - 'event_espresso' |
|
131 | - ) |
|
132 | - ), |
|
133 | - new GraphQLOutputField( |
|
134 | - 'wpUser', |
|
135 | - 'User', |
|
136 | - null, |
|
137 | - esc_html__('WP User that created this form section.', 'event_espresso') |
|
138 | - ), |
|
139 | - new GraphQLInputField( |
|
140 | - 'wpUser', |
|
141 | - 'ID', |
|
142 | - null, |
|
143 | - esc_html__('ID of the WP User that created the form section.', 'event_espresso') |
|
144 | - ), |
|
145 | - ]; |
|
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 | + 'appliesTo', |
|
58 | + $this->namespace . 'FormSectionAppliesToEnum', |
|
59 | + 'appliesTo', |
|
60 | + esc_html__('Form user type that this form section should be presented to.', 'event_espresso') |
|
61 | + ), |
|
62 | + new GraphQLField( |
|
63 | + 'attributes', |
|
64 | + 'String', |
|
65 | + 'attributes', |
|
66 | + esc_html__( |
|
67 | + 'JSON string of HTML attributes, such as class, to be applied to this form section\'s container.', |
|
68 | + 'event_espresso' |
|
69 | + ), |
|
70 | + [$this, 'toJson'] |
|
71 | + ), |
|
72 | + new GraphQLField( |
|
73 | + 'belongsTo', |
|
74 | + 'String', |
|
75 | + 'belongsTo', |
|
76 | + esc_html__('UUID or ID of related entity this form section belongs to.', 'event_espresso') |
|
77 | + ), |
|
78 | + new GraphQLOutputField( |
|
79 | + 'isActive', |
|
80 | + 'Boolean', |
|
81 | + 'isActive', |
|
82 | + esc_html__('Flag indicating whether the section is active.', 'event_espresso') |
|
83 | + ), |
|
84 | + new GraphQLOutputField( |
|
85 | + 'isArchived', |
|
86 | + 'Boolean', |
|
87 | + 'isArchived', |
|
88 | + esc_html__('Flag indicating whether the section is archived.', 'event_espresso') |
|
89 | + ), |
|
90 | + new GraphQLOutputField( |
|
91 | + 'isDefault', |
|
92 | + 'Boolean', |
|
93 | + 'isDefault', |
|
94 | + esc_html__('Flag indicating whether the section is a default one.', 'event_espresso') |
|
95 | + ), |
|
96 | + new GraphQLOutputField( |
|
97 | + 'isShared', |
|
98 | + 'Boolean', |
|
99 | + 'isShared', |
|
100 | + esc_html__('Flag indicating whether the section is a shared one.', 'event_espresso') |
|
101 | + ), |
|
102 | + new GraphQLOutputField( |
|
103 | + 'isTrashed', |
|
104 | + 'Boolean', |
|
105 | + 'isTrashed', |
|
106 | + esc_html__('Flag indicating whether the section is trashed.', 'event_espresso') |
|
107 | + ), |
|
108 | + new GraphQLField( |
|
109 | + 'label', |
|
110 | + 'String', |
|
111 | + 'label', |
|
112 | + esc_html__( |
|
113 | + 'JSON string of properties pertaining to a form section\'s label.', |
|
114 | + 'event_espresso' |
|
115 | + ), |
|
116 | + [$this, 'toJson'] |
|
117 | + ), |
|
118 | + new GraphQLField( |
|
119 | + 'order', |
|
120 | + 'Int', |
|
121 | + 'order', |
|
122 | + esc_html__('Order in which form section appears in a form.', 'event_espresso') |
|
123 | + ), |
|
124 | + new GraphQLField( |
|
125 | + 'status', |
|
126 | + $this->namespace . 'FormStatusEnum', |
|
127 | + 'status', |
|
128 | + esc_html__( |
|
129 | + 'Whether form section is active, archived, shared, trashed, or used as a default on new forms.', |
|
130 | + 'event_espresso' |
|
131 | + ) |
|
132 | + ), |
|
133 | + new GraphQLOutputField( |
|
134 | + 'wpUser', |
|
135 | + 'User', |
|
136 | + null, |
|
137 | + esc_html__('WP User that created this form section.', 'event_espresso') |
|
138 | + ), |
|
139 | + new GraphQLInputField( |
|
140 | + 'wpUser', |
|
141 | + 'ID', |
|
142 | + null, |
|
143 | + esc_html__('ID of the WP User that created the form section.', 'event_espresso') |
|
144 | + ), |
|
145 | + ]; |
|
146 | 146 | |
147 | - return apply_filters( |
|
148 | - 'FHEE__EventEspresso_core_domain_services_graphql_types__form_section_fields', |
|
149 | - $fields, |
|
150 | - $this->name, |
|
151 | - $this->model |
|
152 | - ); |
|
153 | - } |
|
147 | + return apply_filters( |
|
148 | + 'FHEE__EventEspresso_core_domain_services_graphql_types__form_section_fields', |
|
149 | + $fields, |
|
150 | + $this->name, |
|
151 | + $this->model |
|
152 | + ); |
|
153 | + } |
|
154 | 154 | |
155 | 155 | |
156 | - /** |
|
157 | - * @param array $inputFields The mutation input fields. |
|
158 | - * @throws InvalidArgumentException |
|
159 | - * @throws ReflectionException |
|
160 | - * @throws Exception |
|
161 | - * @since $VID:$ |
|
162 | - */ |
|
163 | - public function registerMutations(array $inputFields) |
|
164 | - { |
|
165 | - // Register mutation to update an entity. |
|
166 | - register_graphql_mutation( |
|
167 | - 'update' . $this->name(), |
|
168 | - [ |
|
169 | - 'inputFields' => $inputFields, |
|
170 | - 'outputFields' => [ |
|
171 | - lcfirst($this->name()) => [ |
|
172 | - 'type' => $this->name(), |
|
173 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
174 | - ], |
|
175 | - ], |
|
176 | - 'mutateAndGetPayload' => FormSectionUpdate::mutateAndGetPayload($this->model), |
|
177 | - ] |
|
178 | - ); |
|
179 | - // Register mutation to delete an entity. |
|
180 | - register_graphql_mutation( |
|
181 | - 'delete' . $this->name(), |
|
182 | - [ |
|
183 | - 'inputFields' => [ |
|
184 | - 'id' => $inputFields['id'], |
|
185 | - ], |
|
186 | - 'outputFields' => [ |
|
187 | - lcfirst($this->name()) => [ |
|
188 | - 'type' => $this->name(), |
|
189 | - 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
190 | - 'resolve' => static function ($payload) { |
|
191 | - $deleted = (object) $payload['deleted']; |
|
156 | + /** |
|
157 | + * @param array $inputFields The mutation input fields. |
|
158 | + * @throws InvalidArgumentException |
|
159 | + * @throws ReflectionException |
|
160 | + * @throws Exception |
|
161 | + * @since $VID:$ |
|
162 | + */ |
|
163 | + public function registerMutations(array $inputFields) |
|
164 | + { |
|
165 | + // Register mutation to update an entity. |
|
166 | + register_graphql_mutation( |
|
167 | + 'update' . $this->name(), |
|
168 | + [ |
|
169 | + 'inputFields' => $inputFields, |
|
170 | + 'outputFields' => [ |
|
171 | + lcfirst($this->name()) => [ |
|
172 | + 'type' => $this->name(), |
|
173 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
174 | + ], |
|
175 | + ], |
|
176 | + 'mutateAndGetPayload' => FormSectionUpdate::mutateAndGetPayload($this->model), |
|
177 | + ] |
|
178 | + ); |
|
179 | + // Register mutation to delete an entity. |
|
180 | + register_graphql_mutation( |
|
181 | + 'delete' . $this->name(), |
|
182 | + [ |
|
183 | + 'inputFields' => [ |
|
184 | + 'id' => $inputFields['id'], |
|
185 | + ], |
|
186 | + 'outputFields' => [ |
|
187 | + lcfirst($this->name()) => [ |
|
188 | + 'type' => $this->name(), |
|
189 | + 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
190 | + 'resolve' => static function ($payload) { |
|
191 | + $deleted = (object) $payload['deleted']; |
|
192 | 192 | |
193 | - return ! empty($deleted) ? $deleted : null; |
|
194 | - }, |
|
195 | - ], |
|
196 | - ], |
|
197 | - 'mutateAndGetPayload' => FormSectionDelete::mutateAndGetPayload($this->model), |
|
198 | - ] |
|
199 | - ); |
|
193 | + return ! empty($deleted) ? $deleted : null; |
|
194 | + }, |
|
195 | + ], |
|
196 | + ], |
|
197 | + 'mutateAndGetPayload' => FormSectionDelete::mutateAndGetPayload($this->model), |
|
198 | + ] |
|
199 | + ); |
|
200 | 200 | |
201 | - // Register mutation to update an entity. |
|
202 | - register_graphql_mutation( |
|
203 | - 'create' . $this->name(), |
|
204 | - [ |
|
205 | - 'inputFields' => $inputFields, |
|
206 | - 'outputFields' => [ |
|
207 | - lcfirst($this->name()) => [ |
|
208 | - 'type' => $this->name(), |
|
209 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
210 | - ], |
|
211 | - ], |
|
212 | - 'mutateAndGetPayload' => FormSectionCreate::mutateAndGetPayload($this->model), |
|
213 | - ] |
|
214 | - ); |
|
215 | - } |
|
201 | + // Register mutation to update an entity. |
|
202 | + register_graphql_mutation( |
|
203 | + 'create' . $this->name(), |
|
204 | + [ |
|
205 | + 'inputFields' => $inputFields, |
|
206 | + 'outputFields' => [ |
|
207 | + lcfirst($this->name()) => [ |
|
208 | + 'type' => $this->name(), |
|
209 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
210 | + ], |
|
211 | + ], |
|
212 | + 'mutateAndGetPayload' => FormSectionCreate::mutateAndGetPayload($this->model), |
|
213 | + ] |
|
214 | + ); |
|
215 | + } |
|
216 | 216 | } |
@@ -17,73 +17,73 @@ |
||
17 | 17 | class FormSectionDelete extends EntityMutator |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * Defines the mutation data modification closure. |
|
22 | - * |
|
23 | - * @param EEM_Form_Section $model |
|
24 | - * @return callable |
|
25 | - */ |
|
26 | - public static function mutateAndGetPayload(EEM_Form_Section $model) |
|
27 | - { |
|
28 | - /** |
|
29 | - * Deletes an entity. |
|
30 | - * |
|
31 | - * @param array $input The input for the mutation |
|
32 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
33 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
34 | - * @return array |
|
35 | - */ |
|
36 | - return static function (array $input, AppContext $context, ResolveInfo $info) use ($model): array { |
|
37 | - try { |
|
38 | - /** @var EE_Form_Section $entity */ |
|
39 | - $entity = EntityMutator::getEntityFromInputData($model, $input); |
|
20 | + /** |
|
21 | + * Defines the mutation data modification closure. |
|
22 | + * |
|
23 | + * @param EEM_Form_Section $model |
|
24 | + * @return callable |
|
25 | + */ |
|
26 | + public static function mutateAndGetPayload(EEM_Form_Section $model) |
|
27 | + { |
|
28 | + /** |
|
29 | + * Deletes an entity. |
|
30 | + * |
|
31 | + * @param array $input The input for the mutation |
|
32 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
33 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
34 | + * @return array |
|
35 | + */ |
|
36 | + return static function (array $input, AppContext $context, ResolveInfo $info) use ($model): array { |
|
37 | + try { |
|
38 | + /** @var EE_Form_Section $entity */ |
|
39 | + $entity = EntityMutator::getEntityFromInputData($model, $input); |
|
40 | 40 | |
41 | - $result = FormSectionDelete::deleteSectionAndRelations($entity); |
|
41 | + $result = FormSectionDelete::deleteSectionAndRelations($entity); |
|
42 | 42 | |
43 | - EntityMutator::validateResults($result); |
|
43 | + EntityMutator::validateResults($result); |
|
44 | 44 | |
45 | - do_action( |
|
46 | - 'AHEE__EventEspresso_core_domain_services_graphql_mutators_form_section_delete', |
|
47 | - $entity, |
|
48 | - $input |
|
49 | - ); |
|
50 | - } catch (Exception $exception) { |
|
51 | - EntityMutator::handleExceptions( |
|
52 | - $exception, |
|
53 | - esc_html__( |
|
54 | - 'The form section could not be deleted because of the following error(s)', |
|
55 | - 'event_espresso' |
|
56 | - ) |
|
57 | - ); |
|
58 | - } |
|
45 | + do_action( |
|
46 | + 'AHEE__EventEspresso_core_domain_services_graphql_mutators_form_section_delete', |
|
47 | + $entity, |
|
48 | + $input |
|
49 | + ); |
|
50 | + } catch (Exception $exception) { |
|
51 | + EntityMutator::handleExceptions( |
|
52 | + $exception, |
|
53 | + esc_html__( |
|
54 | + 'The form section could not be deleted because of the following error(s)', |
|
55 | + 'event_espresso' |
|
56 | + ) |
|
57 | + ); |
|
58 | + } |
|
59 | 59 | |
60 | - return [ |
|
61 | - 'deleted' => $entity, |
|
62 | - ]; |
|
63 | - }; |
|
64 | - } |
|
60 | + return [ |
|
61 | + 'deleted' => $entity, |
|
62 | + ]; |
|
63 | + }; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * Deletes a form section along with its related form elements. |
|
68 | - * |
|
69 | - * @param EE_Form_Section $entity |
|
70 | - * @return bool | int |
|
71 | - * @throws ReflectionException |
|
72 | - * @throws InvalidArgumentException |
|
73 | - * @throws InvalidInterfaceException |
|
74 | - * @throws InvalidDataTypeException |
|
75 | - * @throws EE_Error |
|
76 | - */ |
|
77 | - public static function deleteSectionAndRelations(EE_Form_Section $entity) |
|
78 | - { |
|
79 | - // Remove related non-default form elements |
|
80 | - $entity->delete_related('Form_Element', [ |
|
81 | - [ |
|
82 | - 'FIN_status' => ['NOT IN', [ FormStatus::SHARED, FormStatus::DEFAULT] ] |
|
83 | - ] |
|
84 | - ]); |
|
66 | + /** |
|
67 | + * Deletes a form section along with its related form elements. |
|
68 | + * |
|
69 | + * @param EE_Form_Section $entity |
|
70 | + * @return bool | int |
|
71 | + * @throws ReflectionException |
|
72 | + * @throws InvalidArgumentException |
|
73 | + * @throws InvalidInterfaceException |
|
74 | + * @throws InvalidDataTypeException |
|
75 | + * @throws EE_Error |
|
76 | + */ |
|
77 | + public static function deleteSectionAndRelations(EE_Form_Section $entity) |
|
78 | + { |
|
79 | + // Remove related non-default form elements |
|
80 | + $entity->delete_related('Form_Element', [ |
|
81 | + [ |
|
82 | + 'FIN_status' => ['NOT IN', [ FormStatus::SHARED, FormStatus::DEFAULT] ] |
|
83 | + ] |
|
84 | + ]); |
|
85 | 85 | |
86 | - // Now delete the form section |
|
87 | - return $entity->delete(); |
|
88 | - } |
|
86 | + // Now delete the form section |
|
87 | + return $entity->delete(); |
|
88 | + } |
|
89 | 89 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
34 | 34 | * @return array |
35 | 35 | */ |
36 | - return static function (array $input, AppContext $context, ResolveInfo $info) use ($model): array { |
|
36 | + return static function(array $input, AppContext $context, ResolveInfo $info) use ($model): array { |
|
37 | 37 | try { |
38 | 38 | /** @var EE_Form_Section $entity */ |
39 | 39 | $entity = EntityMutator::getEntityFromInputData($model, $input); |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | // Remove related non-default form elements |
80 | 80 | $entity->delete_related('Form_Element', [ |
81 | 81 | [ |
82 | - 'FIN_status' => ['NOT IN', [ FormStatus::SHARED, FormStatus::DEFAULT] ] |
|
82 | + 'FIN_status' => ['NOT IN', [FormStatus::SHARED, FormStatus::DEFAULT]] |
|
83 | 83 | ] |
84 | 84 | ]); |
85 | 85 |
@@ -4,36 +4,36 @@ |
||
4 | 4 | |
5 | 5 | class Block |
6 | 6 | { |
7 | - /** |
|
8 | - * indicates that the element is a general HTML block |
|
9 | - */ |
|
10 | - public const TYPE_HTML = 'html'; |
|
7 | + /** |
|
8 | + * indicates that the element is a general HTML block |
|
9 | + */ |
|
10 | + public const TYPE_HTML = 'html'; |
|
11 | 11 | |
12 | - /** |
|
13 | - * @var array |
|
14 | - */ |
|
15 | - private $valid_type_options; |
|
12 | + /** |
|
13 | + * @var array |
|
14 | + */ |
|
15 | + private $valid_type_options; |
|
16 | 16 | |
17 | 17 | |
18 | - public function __construct() |
|
19 | - { |
|
20 | - $this->valid_type_options = apply_filters( |
|
21 | - 'FHEE__EventEspresso_core_services_form_meta_inputs_Block__valid_type_options', |
|
22 | - [ |
|
23 | - Block::TYPE_HTML => esc_html__('HTML Block', 'event_espresso'), |
|
24 | - ] |
|
25 | - ); |
|
26 | - } |
|
18 | + public function __construct() |
|
19 | + { |
|
20 | + $this->valid_type_options = apply_filters( |
|
21 | + 'FHEE__EventEspresso_core_services_form_meta_inputs_Block__valid_type_options', |
|
22 | + [ |
|
23 | + Block::TYPE_HTML => esc_html__('HTML Block', 'event_espresso'), |
|
24 | + ] |
|
25 | + ); |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * @param bool $constants_only |
|
31 | - * @return array |
|
32 | - */ |
|
33 | - public function validTypeOptions(bool $constants_only = false): array |
|
34 | - { |
|
35 | - return $constants_only |
|
36 | - ? array_keys($this->valid_type_options) |
|
37 | - : $this->valid_type_options; |
|
38 | - } |
|
29 | + /** |
|
30 | + * @param bool $constants_only |
|
31 | + * @return array |
|
32 | + */ |
|
33 | + public function validTypeOptions(bool $constants_only = false): array |
|
34 | + { |
|
35 | + return $constants_only |
|
36 | + ? array_keys($this->valid_type_options) |
|
37 | + : $this->valid_type_options; |
|
38 | + } |
|
39 | 39 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function get_table_name() |
95 | 95 | { |
96 | - return $this->get_table_prefix() . $this->_table_name; |
|
96 | + return $this->get_table_prefix().$this->_table_name; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function get_table_alias() |
107 | 107 | { |
108 | - if (! $this->_table_alias) { |
|
108 | + if ( ! $this->_table_alias) { |
|
109 | 109 | throw new EE_Error("You must call _construct_finalize_with_alias before using the EE_Table_Base. Did you forget to call parent::__construct at the end of your EEMerimental_Base child's __construct?"); |
110 | 110 | } |
111 | 111 | return $this->_table_alias; |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | public function get_fully_qualified_pk_column() |
130 | 130 | { |
131 | - return $this->get_table_alias() . "." . $this->get_pk_column(); |
|
131 | + return $this->get_table_alias().".".$this->get_pk_column(); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function get_select_join_limit($limit) |
141 | 141 | { |
142 | - $limit = is_array($limit) ? 'LIMIT ' . implode(',', array_map('intval', $limit)) : 'LIMIT ' . (int) $limit; |
|
143 | - return SP . '(SELECT * FROM ' . $this->_table_name . SP . $limit . ') AS ' . $this->_table_alias; |
|
142 | + $limit = is_array($limit) ? 'LIMIT '.implode(',', array_map('intval', $limit)) : 'LIMIT '.(int) $limit; |
|
143 | + return SP.'(SELECT * FROM '.$this->_table_name.SP.$limit.') AS '.$this->_table_alias; |
|
144 | 144 | } |
145 | 145 | |
146 | 146 |
@@ -6,151 +6,151 @@ |
||
6 | 6 | */ |
7 | 7 | abstract class EE_Table_Base |
8 | 8 | { |
9 | - /** |
|
10 | - * This holds the table_name without the table prefix. |
|
11 | - * |
|
12 | - * @var string |
|
13 | - */ |
|
14 | - public $_table_name; |
|
15 | - |
|
16 | - |
|
17 | - /** |
|
18 | - * This holds what is used as the alias for the table in queries. |
|
19 | - * |
|
20 | - * @var string |
|
21 | - */ |
|
22 | - public $_table_alias; |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * Table's private key column |
|
27 | - * |
|
28 | - * @var string |
|
29 | - */ |
|
30 | - protected $_pk_column; |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * Whether this table is a global table (in multisite) or specific to site. |
|
35 | - * |
|
36 | - * @var bool |
|
37 | - */ |
|
38 | - protected $_global; |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * @param string $table_name with or without wpdb prefix |
|
43 | - * @param string $pk_column |
|
44 | - * @param boolean $global whether the table is "global" as in there is only 1 table on an entire multisite |
|
45 | - * install, or whether each site on a multisite install has a copy of this table |
|
46 | - * @global wpdb $wpdb |
|
47 | - */ |
|
48 | - public function __construct($table_name, $pk_column, $global = false) |
|
49 | - { |
|
50 | - $this->_global = $global; |
|
51 | - $prefix = $this->get_table_prefix(); |
|
52 | - // if they added the prefix, let's remove it because we delay adding the prefix until right when its needed. |
|
53 | - if (strpos($table_name, $prefix) === 0) { |
|
54 | - $table_name = substr_replace($table_name, '', 0, strlen($prefix)); |
|
55 | - } |
|
56 | - $this->_table_name = $table_name; |
|
57 | - $this->_pk_column = $pk_column; |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * This returns the table prefix for the current model state. |
|
63 | - * |
|
64 | - * @return string |
|
65 | - * @global wpdb $wpdb |
|
66 | - */ |
|
67 | - public function get_table_prefix() |
|
68 | - { |
|
69 | - global $wpdb; |
|
70 | - if ($this->_global) { |
|
71 | - return $wpdb->base_prefix; |
|
72 | - } |
|
73 | - return $wpdb->get_blog_prefix(EEM_Base::get_model_query_blog_id()); |
|
74 | - } |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * Used to set the table_alias property |
|
79 | - * |
|
80 | - * @param string $table_alias |
|
81 | - */ |
|
82 | - public function _construct_finalize_with_alias($table_alias) |
|
83 | - { |
|
84 | - $this->_table_alias = $table_alias; |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * Returns the fully qualified table name for the database (includes the table prefix current for the blog). |
|
90 | - * |
|
91 | - * @return string |
|
92 | - */ |
|
93 | - public function get_table_name() |
|
94 | - { |
|
95 | - return $this->get_table_prefix() . $this->_table_name; |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * Provides what is currently set as the alias for the table to be used in queries. |
|
101 | - * |
|
102 | - * @return string |
|
103 | - * @throws EE_Error |
|
104 | - */ |
|
105 | - public function get_table_alias() |
|
106 | - { |
|
107 | - if (! $this->_table_alias) { |
|
108 | - throw new EE_Error("You must call _construct_finalize_with_alias before using the EE_Table_Base. Did you forget to call parent::__construct at the end of your EEMerimental_Base child's __construct?"); |
|
109 | - } |
|
110 | - return $this->_table_alias; |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * @return string name of column of PK |
|
116 | - */ |
|
117 | - public function get_pk_column() |
|
118 | - { |
|
119 | - return $this->_pk_column; |
|
120 | - } |
|
121 | - |
|
122 | - |
|
123 | - /** |
|
124 | - * returns a string with the table alias, a period, and the private key's column. |
|
125 | - * |
|
126 | - * @return string |
|
127 | - */ |
|
128 | - public function get_fully_qualified_pk_column() |
|
129 | - { |
|
130 | - return $this->get_table_alias() . "." . $this->get_pk_column(); |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * returns the special sql for a inner select with a limit. |
|
136 | - * |
|
137 | - * @return string SQL select |
|
138 | - */ |
|
139 | - public function get_select_join_limit($limit) |
|
140 | - { |
|
141 | - $limit = is_array($limit) ? 'LIMIT ' . implode(',', array_map('intval', $limit)) : 'LIMIT ' . (int) $limit; |
|
142 | - return SP . '(SELECT * FROM ' . $this->_table_name . SP . $limit . ') AS ' . $this->_table_alias; |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * Returns whether or not htis is a global table (ie, on multisite there's |
|
148 | - * only one of these tables, on the main blog) |
|
149 | - * |
|
150 | - * @return boolean |
|
151 | - */ |
|
152 | - public function is_global() |
|
153 | - { |
|
154 | - return $this->_global; |
|
155 | - } |
|
9 | + /** |
|
10 | + * This holds the table_name without the table prefix. |
|
11 | + * |
|
12 | + * @var string |
|
13 | + */ |
|
14 | + public $_table_name; |
|
15 | + |
|
16 | + |
|
17 | + /** |
|
18 | + * This holds what is used as the alias for the table in queries. |
|
19 | + * |
|
20 | + * @var string |
|
21 | + */ |
|
22 | + public $_table_alias; |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * Table's private key column |
|
27 | + * |
|
28 | + * @var string |
|
29 | + */ |
|
30 | + protected $_pk_column; |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * Whether this table is a global table (in multisite) or specific to site. |
|
35 | + * |
|
36 | + * @var bool |
|
37 | + */ |
|
38 | + protected $_global; |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * @param string $table_name with or without wpdb prefix |
|
43 | + * @param string $pk_column |
|
44 | + * @param boolean $global whether the table is "global" as in there is only 1 table on an entire multisite |
|
45 | + * install, or whether each site on a multisite install has a copy of this table |
|
46 | + * @global wpdb $wpdb |
|
47 | + */ |
|
48 | + public function __construct($table_name, $pk_column, $global = false) |
|
49 | + { |
|
50 | + $this->_global = $global; |
|
51 | + $prefix = $this->get_table_prefix(); |
|
52 | + // if they added the prefix, let's remove it because we delay adding the prefix until right when its needed. |
|
53 | + if (strpos($table_name, $prefix) === 0) { |
|
54 | + $table_name = substr_replace($table_name, '', 0, strlen($prefix)); |
|
55 | + } |
|
56 | + $this->_table_name = $table_name; |
|
57 | + $this->_pk_column = $pk_column; |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * This returns the table prefix for the current model state. |
|
63 | + * |
|
64 | + * @return string |
|
65 | + * @global wpdb $wpdb |
|
66 | + */ |
|
67 | + public function get_table_prefix() |
|
68 | + { |
|
69 | + global $wpdb; |
|
70 | + if ($this->_global) { |
|
71 | + return $wpdb->base_prefix; |
|
72 | + } |
|
73 | + return $wpdb->get_blog_prefix(EEM_Base::get_model_query_blog_id()); |
|
74 | + } |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * Used to set the table_alias property |
|
79 | + * |
|
80 | + * @param string $table_alias |
|
81 | + */ |
|
82 | + public function _construct_finalize_with_alias($table_alias) |
|
83 | + { |
|
84 | + $this->_table_alias = $table_alias; |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * Returns the fully qualified table name for the database (includes the table prefix current for the blog). |
|
90 | + * |
|
91 | + * @return string |
|
92 | + */ |
|
93 | + public function get_table_name() |
|
94 | + { |
|
95 | + return $this->get_table_prefix() . $this->_table_name; |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * Provides what is currently set as the alias for the table to be used in queries. |
|
101 | + * |
|
102 | + * @return string |
|
103 | + * @throws EE_Error |
|
104 | + */ |
|
105 | + public function get_table_alias() |
|
106 | + { |
|
107 | + if (! $this->_table_alias) { |
|
108 | + throw new EE_Error("You must call _construct_finalize_with_alias before using the EE_Table_Base. Did you forget to call parent::__construct at the end of your EEMerimental_Base child's __construct?"); |
|
109 | + } |
|
110 | + return $this->_table_alias; |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * @return string name of column of PK |
|
116 | + */ |
|
117 | + public function get_pk_column() |
|
118 | + { |
|
119 | + return $this->_pk_column; |
|
120 | + } |
|
121 | + |
|
122 | + |
|
123 | + /** |
|
124 | + * returns a string with the table alias, a period, and the private key's column. |
|
125 | + * |
|
126 | + * @return string |
|
127 | + */ |
|
128 | + public function get_fully_qualified_pk_column() |
|
129 | + { |
|
130 | + return $this->get_table_alias() . "." . $this->get_pk_column(); |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * returns the special sql for a inner select with a limit. |
|
136 | + * |
|
137 | + * @return string SQL select |
|
138 | + */ |
|
139 | + public function get_select_join_limit($limit) |
|
140 | + { |
|
141 | + $limit = is_array($limit) ? 'LIMIT ' . implode(',', array_map('intval', $limit)) : 'LIMIT ' . (int) $limit; |
|
142 | + return SP . '(SELECT * FROM ' . $this->_table_name . SP . $limit . ') AS ' . $this->_table_alias; |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * Returns whether or not htis is a global table (ie, on multisite there's |
|
148 | + * only one of these tables, on the main blog) |
|
149 | + * |
|
150 | + * @return boolean |
|
151 | + */ |
|
152 | + public function is_global() |
|
153 | + { |
|
154 | + return $this->_global; |
|
155 | + } |
|
156 | 156 | } |