Completed
Branch master (16f63d)
by
unknown
05:48
created
core/domain/services/graphql/mutators/DatetimeCreate.php 1 patch
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -12,58 +12,58 @@
 block discarded – undo
12 12
 
13 13
 class DatetimeCreate extends EntityMutator
14 14
 {
15
-    /**
16
-     * Defines the mutation data modification closure.
17
-     *
18
-     * @param EEM_Datetime $model
19
-     * @param Datetime     $type
20
-     * @return callable
21
-     */
22
-    public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type)
23
-    {
24
-        /**
25
-         * Creates an entity.
26
-         *
27
-         * @param array       $input   The input for the mutation
28
-         * @param AppContext  $context The AppContext passed down to all resolvers
29
-         * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
30
-         * @return array
31
-         */
32
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
33
-            $id = null;
34
-            try {
35
-                EntityMutator::checkPermissions($model);
36
-                $args = DatetimeMutation::prepareFields($input);
15
+	/**
16
+	 * Defines the mutation data modification closure.
17
+	 *
18
+	 * @param EEM_Datetime $model
19
+	 * @param Datetime     $type
20
+	 * @return callable
21
+	 */
22
+	public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type)
23
+	{
24
+		/**
25
+		 * Creates an entity.
26
+		 *
27
+		 * @param array       $input   The input for the mutation
28
+		 * @param AppContext  $context The AppContext passed down to all resolvers
29
+		 * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
30
+		 * @return array
31
+		 */
32
+		return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
33
+			$id = null;
34
+			try {
35
+				EntityMutator::checkPermissions($model);
36
+				$args = DatetimeMutation::prepareFields($input);
37 37
 
38
-                // extract tickets and venue from args then unset them
39
-                $tickets = $args['tickets'] ?? null;
40
-                $venue   = $args['venue'] ?? null;
41
-                unset($args['tickets'], $args['venue']);
38
+				// extract tickets and venue from args then unset them
39
+				$tickets = $args['tickets'] ?? null;
40
+				$venue   = $args['venue'] ?? null;
41
+				unset($args['tickets'], $args['venue']);
42 42
 
43
-                $entity = EE_Datetime::new_instance($args);
44
-                $id = $entity->save();
45
-                EntityMutator::validateResults($id);
43
+				$entity = EE_Datetime::new_instance($args);
44
+				$id = $entity->save();
45
+				EntityMutator::validateResults($id);
46 46
 
47
-                if ($tickets) {
48
-                    DatetimeMutation::setRelatedTickets($entity, $tickets);
49
-                }
47
+				if ($tickets) {
48
+					DatetimeMutation::setRelatedTickets($entity, $tickets);
49
+				}
50 50
 
51
-                if (isset($venue)) {
52
-                    DatetimeMutation::setVenue($entity, $venue);
53
-                }
51
+				if (isset($venue)) {
52
+					DatetimeMutation::setVenue($entity, $venue);
53
+				}
54 54
 
55
-                do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_datetime_create', $entity, $input);
56
-            } catch (Exception $exception) {
57
-                EntityMutator::handleExceptions(
58
-                    $exception,
59
-                    esc_html__(
60
-                        'The datetime could not be created because of the following error(s)',
61
-                        'event_espresso'
62
-                    )
63
-                );
64
-            }
55
+				do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_datetime_create', $entity, $input);
56
+			} catch (Exception $exception) {
57
+				EntityMutator::handleExceptions(
58
+					$exception,
59
+					esc_html__(
60
+						'The datetime could not be created because of the following error(s)',
61
+						'event_espresso'
62
+					)
63
+				);
64
+			}
65 65
 
66
-            return $id ? [ 'id' => $id ] : [];
67
-        };
68
-    }
66
+			return $id ? [ 'id' => $id ] : [];
67
+		};
68
+	}
69 69
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/mutators/DatetimeUpdate.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -14,61 +14,61 @@
 block discarded – undo
14 14
 
15 15
 class DatetimeUpdate extends EntityMutator
16 16
 {
17
-    /**
18
-     * Defines the mutation data modification closure.
19
-     *
20
-     * @param EEM_Datetime $model
21
-     * @param Datetime     $type
22
-     * @return callable
23
-     */
24
-    public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type)
25
-    {
26
-        /**
27
-         * Updates an entity.
28
-         *
29
-         * @param array       $input   The input for the mutation
30
-         * @param AppContext  $context The AppContext passed down to all resolvers
31
-         * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
32
-         * @return array
33
-         * @throws EE_Error
34
-         * @throws ReflectionException
35
-         */
36
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
37
-            try {
38
-                /** @var EE_Datetime $entity */
39
-                $entity = EntityMutator::getEntityFromInputData($model, $input);
40
-                $args = DatetimeMutation::prepareFields($input);
17
+	/**
18
+	 * Defines the mutation data modification closure.
19
+	 *
20
+	 * @param EEM_Datetime $model
21
+	 * @param Datetime     $type
22
+	 * @return callable
23
+	 */
24
+	public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type)
25
+	{
26
+		/**
27
+		 * Updates an entity.
28
+		 *
29
+		 * @param array       $input   The input for the mutation
30
+		 * @param AppContext  $context The AppContext passed down to all resolvers
31
+		 * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
32
+		 * @return array
33
+		 * @throws EE_Error
34
+		 * @throws ReflectionException
35
+		 */
36
+		return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
37
+			try {
38
+				/** @var EE_Datetime $entity */
39
+				$entity = EntityMutator::getEntityFromInputData($model, $input);
40
+				$args = DatetimeMutation::prepareFields($input);
41 41
 
42
-                // extract tickets and venue from args then unset them
43
-                $tickets = $args['tickets'] ?? null;
44
-                $venue   = $args['venue'] ?? null;
45
-                unset($args['tickets'], $args['venue']);
42
+				// extract tickets and venue from args then unset them
43
+				$tickets = $args['tickets'] ?? null;
44
+				$venue   = $args['venue'] ?? null;
45
+				unset($args['tickets'], $args['venue']);
46 46
 
47
-                // Update the entity
48
-                $entity->save($args);
47
+				// Update the entity
48
+				$entity->save($args);
49 49
 
50
-                if ($tickets) {
51
-                    DatetimeMutation::setRelatedTickets($entity, $tickets);
52
-                }
50
+				if ($tickets) {
51
+					DatetimeMutation::setRelatedTickets($entity, $tickets);
52
+				}
53 53
 
54
-                if (isset($venue)) {
55
-                    DatetimeMutation::setVenue($entity, $venue);
56
-                }
54
+				if (isset($venue)) {
55
+					DatetimeMutation::setVenue($entity, $venue);
56
+				}
57 57
 
58
-                do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_datetime_update', $entity, $input);
59
-            } catch (Exception $exception) {
60
-                EntityMutator::handleExceptions(
61
-                    $exception,
62
-                    esc_html__(
63
-                        'The datetime could not be updated because of the following error(s)',
64
-                        'event_espresso'
65
-                    )
66
-                );
67
-            }
58
+				do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_datetime_update', $entity, $input);
59
+			} catch (Exception $exception) {
60
+				EntityMutator::handleExceptions(
61
+					$exception,
62
+					esc_html__(
63
+						'The datetime could not be updated because of the following error(s)',
64
+						'event_espresso'
65
+					)
66
+				);
67
+			}
68 68
 
69
-            return [
70
-                'id' => $entity->ID(),
71
-            ];
72
-        };
73
-    }
69
+			return [
70
+				'id' => $entity->ID(),
71
+			];
72
+		};
73
+	}
74 74
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/mutators/EntityMutator.php 2 patches
Indentation   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -21,200 +21,200 @@
 block discarded – undo
21 21
  */
22 22
 abstract class EntityMutator
23 23
 {
24
-    /**
25
-     * Get data entity using database ID
26
-     * @param EEM_Base $model
27
-     * @param integer  $ID          database ID
28
-     * @param string   $capability
29
-     * @return EE_Base_Class
30
-     * @throws OutOfBoundsException
31
-     * @throws UserError
32
-     * @throws EE_Error
33
-     */
34
-    protected static function getEntityFromID(
35
-        EEM_Base $model,
36
-        int $ID,
37
-        string $capability = 'ee_edit_events'
38
-    ): EE_Base_Class {
39
-        EntityMutator::checkPermissions($model, $capability, $ID);
40
-        return EntityMutator::getEntity($model, $ID);
41
-    }
42
-
43
-
44
-    /**
45
-     * Get data entity from request parameters
46
-     * @param EEM_Base $model
47
-     * @param array    $input       Sanitized GraphQL request parameters
48
-     * @param string   $capability
49
-     * @return EE_Base_Class
50
-     * @throws OutOfBoundsException
51
-     * @throws UserError
52
-     * @throws EE_Error
53
-     */
54
-    protected static function getEntityFromInputData(
55
-        EEM_Base $model,
56
-        array $input,
57
-        string $capability = 'ee_edit_events'
58
-    ): EE_Base_Class {
59
-        $ID = EntityMutator::getEntityID($model, $input);
60
-        EntityMutator::checkPermissions($model, $capability, $ID);
61
-        return EntityMutator::getEntity($model, $ID);
62
-    }
63
-
64
-
65
-    /**
66
-     * Check if current user has the required permissions to perform the mutation
67
-     * @param EEM_Base $model
68
-     * @param string   $capability
69
-     * @param array    ...$args        Optional further parameters to be passed to current_user_can(), typically starting with an object ID
70
-     * @throws UserError
71
-     * @see https://developer.wordpress.org/reference/functions/current_user_can/
72
-     * @see https://developer.wordpress.org/reference/functions/map_meta_cap/ for argument $args explanation
73
-     */
74
-    protected static function checkPermissions(EEM_Base $model, string $capability = 'ee_edit_events', ...$args)
75
-    {
76
-        if (
77
-            ! (
78
-                (isset($args[0]) && current_user_can($capability, ...$args))
79
-                || (! isset($args[0]) && current_user_can($capability))
80
-            )
81
-        ) {
82
-            $model_name = $model->get_this_model_name();
83
-            $message    = sprintf(
84
-                esc_html_x(
85
-                    'We\'re sorry but you do not have the required permissions to execute %1$s mutations!',
86
-                    'We\'re sorry but you do not have the required permissions to execute entity(datetime/ticket/etc) mutations!',
87
-                    'event_espresso'
88
-                ),
89
-                strtolower($model_name)
90
-            );
91
-            throw new UserError($message);
92
-        }
93
-    }
94
-
95
-
96
-    /**
97
-     * Get entity ID from GraphQL Relay
98
-     * @param EEM_Base $model
99
-     * @param array    $input  Sanitized GraphQL request parameters
100
-     * @return int
101
-     * @throws OutOfBoundsException
102
-     */
103
-    protected static function getEntityIDFromGlobalId(EEM_Base $model, array $input): int
104
-    {
105
-        $id_parts = ! empty($input['id']) ? Relay::fromGlobalId($input['id']) : null;
106
-        $id       = ! empty($id_parts['id']) ? absint($id_parts['id']) : 0;
107
-        if ($id > 0) {
108
-            return $id;
109
-        }
110
-        // no ID? throw an exception
111
-        $model_name = $model->get_this_model_name();
112
-        throw new OutOfBoundsException(
113
-            sprintf(
114
-                esc_html_x(
115
-                    'A missing or invalid %1$s ID was received.',
116
-                    'A missing or invalid entity(datetime/ticket/etc) ID was received.',
117
-                    'event_espresso'
118
-                ),
119
-                strtolower($model_name)
120
-            )
121
-        );
122
-    }
123
-
124
-
125
-    /**
126
-     * Get data entity using database ID
127
-     * @param EEM_Base   $model
128
-     * @param int|string $ID     Database ID
129
-     * @return EE_Base_Class
130
-     * @throws OutOfBoundsException
131
-     * @throws EE_Error
132
-     */
133
-    protected static function getEntity(EEM_Base $model, $ID = 0): EE_Base_Class
134
-    {
135
-        $entity = $model->get_one_by_ID($ID);
136
-        $model_name = $model->get_this_model_name();
137
-        $class_name = 'EE_' . $model_name;
138
-        if ($entity instanceof $class_name) {
139
-            /** @var EE_Base_Class $entity */
140
-            return $entity;
141
-        }
142
-        // OOPS!!! invalid entity
143
-        throw new OutOfBoundsException(
144
-            sprintf(
145
-                esc_html_x(
146
-                    'A valid %1$s could not be retrieved from the database.',
147
-                    'A valid entity(datetime/ticket/etc) could not be found in the database.',
148
-                    'event_espresso'
149
-                ),
150
-                strtolower($model_name)
151
-            )
152
-        );
153
-    }
154
-
155
-
156
-    /**
157
-     * @param array|string  $results
158
-     * @param string        $message
159
-     * @return void
160
-     * @throws RuntimeException
161
-     */
162
-    protected static function validateResults($results, string $message = '')
163
-    {
164
-        if (empty($results)) {
165
-            $message = $message !== ''
166
-                ? $message
167
-                : esc_html__(
168
-                    'An unknown error occurred. Please check your server\'s error  logs for more information',
169
-                    'event_espresso'
170
-                );
171
-            throw new RuntimeException($message);
172
-        }
173
-    }
174
-
175
-
176
-    /**
177
-     * @param Exception $exception
178
-     * @param string    $message_prefix
179
-     * @return void
180
-     * @throws RuntimeException
181
-     */
182
-    protected static function handleExceptions(Exception $exception, string $message_prefix = '')
183
-    {
184
-        $message_prefix = $message_prefix !== ''
185
-            ? $message_prefix
186
-            : esc_html__(
187
-                'The mutation could not be executed because of the following error(s)',
188
-                'event_espresso'
189
-            );
190
-        throw new RuntimeException(
191
-            sprintf('%1$s: %2$s', $message_prefix, $exception->getMessage())
192
-        );
193
-    }
194
-
195
-    /**
196
-     * Check if given model has a UUID field
197
-     * @return bool `true` if yes and `false` if no
198
-     */
199
-    protected static function hasUuidField(EEM_Base $model): bool
200
-    {
201
-        $primaryKey = $model->get_primary_key_field()->get_name(); // e.g. "FSC_UUID" will give us "FSC"
202
-        [$keyPrefix] = explode('_', $primaryKey);
203
-        $uuid_field  = $keyPrefix . '_UUID'; // e.g. "FSC_UUID"
204
-        return $model->has_field($uuid_field);
205
-    }
206
-
207
-    /**
208
-     * Get database entity ID using model and request parameters
209
-     * @param EEM_Base $model
210
-     * @param array    $input  Sanitized GraphQL request parameters
211
-     * @return string|int
212
-     */
213
-    protected static function getEntityID(EEM_Base $model, array $input)
214
-    {
215
-        if (EntityMutator::hasUuidField($model)) {
216
-            return $input['id'];
217
-        }
218
-        return EntityMutator::getEntityIDFromGlobalId($model, $input);
219
-    }
24
+	/**
25
+	 * Get data entity using database ID
26
+	 * @param EEM_Base $model
27
+	 * @param integer  $ID          database ID
28
+	 * @param string   $capability
29
+	 * @return EE_Base_Class
30
+	 * @throws OutOfBoundsException
31
+	 * @throws UserError
32
+	 * @throws EE_Error
33
+	 */
34
+	protected static function getEntityFromID(
35
+		EEM_Base $model,
36
+		int $ID,
37
+		string $capability = 'ee_edit_events'
38
+	): EE_Base_Class {
39
+		EntityMutator::checkPermissions($model, $capability, $ID);
40
+		return EntityMutator::getEntity($model, $ID);
41
+	}
42
+
43
+
44
+	/**
45
+	 * Get data entity from request parameters
46
+	 * @param EEM_Base $model
47
+	 * @param array    $input       Sanitized GraphQL request parameters
48
+	 * @param string   $capability
49
+	 * @return EE_Base_Class
50
+	 * @throws OutOfBoundsException
51
+	 * @throws UserError
52
+	 * @throws EE_Error
53
+	 */
54
+	protected static function getEntityFromInputData(
55
+		EEM_Base $model,
56
+		array $input,
57
+		string $capability = 'ee_edit_events'
58
+	): EE_Base_Class {
59
+		$ID = EntityMutator::getEntityID($model, $input);
60
+		EntityMutator::checkPermissions($model, $capability, $ID);
61
+		return EntityMutator::getEntity($model, $ID);
62
+	}
63
+
64
+
65
+	/**
66
+	 * Check if current user has the required permissions to perform the mutation
67
+	 * @param EEM_Base $model
68
+	 * @param string   $capability
69
+	 * @param array    ...$args        Optional further parameters to be passed to current_user_can(), typically starting with an object ID
70
+	 * @throws UserError
71
+	 * @see https://developer.wordpress.org/reference/functions/current_user_can/
72
+	 * @see https://developer.wordpress.org/reference/functions/map_meta_cap/ for argument $args explanation
73
+	 */
74
+	protected static function checkPermissions(EEM_Base $model, string $capability = 'ee_edit_events', ...$args)
75
+	{
76
+		if (
77
+			! (
78
+				(isset($args[0]) && current_user_can($capability, ...$args))
79
+				|| (! isset($args[0]) && current_user_can($capability))
80
+			)
81
+		) {
82
+			$model_name = $model->get_this_model_name();
83
+			$message    = sprintf(
84
+				esc_html_x(
85
+					'We\'re sorry but you do not have the required permissions to execute %1$s mutations!',
86
+					'We\'re sorry but you do not have the required permissions to execute entity(datetime/ticket/etc) mutations!',
87
+					'event_espresso'
88
+				),
89
+				strtolower($model_name)
90
+			);
91
+			throw new UserError($message);
92
+		}
93
+	}
94
+
95
+
96
+	/**
97
+	 * Get entity ID from GraphQL Relay
98
+	 * @param EEM_Base $model
99
+	 * @param array    $input  Sanitized GraphQL request parameters
100
+	 * @return int
101
+	 * @throws OutOfBoundsException
102
+	 */
103
+	protected static function getEntityIDFromGlobalId(EEM_Base $model, array $input): int
104
+	{
105
+		$id_parts = ! empty($input['id']) ? Relay::fromGlobalId($input['id']) : null;
106
+		$id       = ! empty($id_parts['id']) ? absint($id_parts['id']) : 0;
107
+		if ($id > 0) {
108
+			return $id;
109
+		}
110
+		// no ID? throw an exception
111
+		$model_name = $model->get_this_model_name();
112
+		throw new OutOfBoundsException(
113
+			sprintf(
114
+				esc_html_x(
115
+					'A missing or invalid %1$s ID was received.',
116
+					'A missing or invalid entity(datetime/ticket/etc) ID was received.',
117
+					'event_espresso'
118
+				),
119
+				strtolower($model_name)
120
+			)
121
+		);
122
+	}
123
+
124
+
125
+	/**
126
+	 * Get data entity using database ID
127
+	 * @param EEM_Base   $model
128
+	 * @param int|string $ID     Database ID
129
+	 * @return EE_Base_Class
130
+	 * @throws OutOfBoundsException
131
+	 * @throws EE_Error
132
+	 */
133
+	protected static function getEntity(EEM_Base $model, $ID = 0): EE_Base_Class
134
+	{
135
+		$entity = $model->get_one_by_ID($ID);
136
+		$model_name = $model->get_this_model_name();
137
+		$class_name = 'EE_' . $model_name;
138
+		if ($entity instanceof $class_name) {
139
+			/** @var EE_Base_Class $entity */
140
+			return $entity;
141
+		}
142
+		// OOPS!!! invalid entity
143
+		throw new OutOfBoundsException(
144
+			sprintf(
145
+				esc_html_x(
146
+					'A valid %1$s could not be retrieved from the database.',
147
+					'A valid entity(datetime/ticket/etc) could not be found in the database.',
148
+					'event_espresso'
149
+				),
150
+				strtolower($model_name)
151
+			)
152
+		);
153
+	}
154
+
155
+
156
+	/**
157
+	 * @param array|string  $results
158
+	 * @param string        $message
159
+	 * @return void
160
+	 * @throws RuntimeException
161
+	 */
162
+	protected static function validateResults($results, string $message = '')
163
+	{
164
+		if (empty($results)) {
165
+			$message = $message !== ''
166
+				? $message
167
+				: esc_html__(
168
+					'An unknown error occurred. Please check your server\'s error  logs for more information',
169
+					'event_espresso'
170
+				);
171
+			throw new RuntimeException($message);
172
+		}
173
+	}
174
+
175
+
176
+	/**
177
+	 * @param Exception $exception
178
+	 * @param string    $message_prefix
179
+	 * @return void
180
+	 * @throws RuntimeException
181
+	 */
182
+	protected static function handleExceptions(Exception $exception, string $message_prefix = '')
183
+	{
184
+		$message_prefix = $message_prefix !== ''
185
+			? $message_prefix
186
+			: esc_html__(
187
+				'The mutation could not be executed because of the following error(s)',
188
+				'event_espresso'
189
+			);
190
+		throw new RuntimeException(
191
+			sprintf('%1$s: %2$s', $message_prefix, $exception->getMessage())
192
+		);
193
+	}
194
+
195
+	/**
196
+	 * Check if given model has a UUID field
197
+	 * @return bool `true` if yes and `false` if no
198
+	 */
199
+	protected static function hasUuidField(EEM_Base $model): bool
200
+	{
201
+		$primaryKey = $model->get_primary_key_field()->get_name(); // e.g. "FSC_UUID" will give us "FSC"
202
+		[$keyPrefix] = explode('_', $primaryKey);
203
+		$uuid_field  = $keyPrefix . '_UUID'; // e.g. "FSC_UUID"
204
+		return $model->has_field($uuid_field);
205
+	}
206
+
207
+	/**
208
+	 * Get database entity ID using model and request parameters
209
+	 * @param EEM_Base $model
210
+	 * @param array    $input  Sanitized GraphQL request parameters
211
+	 * @return string|int
212
+	 */
213
+	protected static function getEntityID(EEM_Base $model, array $input)
214
+	{
215
+		if (EntityMutator::hasUuidField($model)) {
216
+			return $input['id'];
217
+		}
218
+		return EntityMutator::getEntityIDFromGlobalId($model, $input);
219
+	}
220 220
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
         if (
77 77
             ! (
78 78
                 (isset($args[0]) && current_user_can($capability, ...$args))
79
-                || (! isset($args[0]) && current_user_can($capability))
79
+                || ( ! isset($args[0]) && current_user_can($capability))
80 80
             )
81 81
         ) {
82 82
             $model_name = $model->get_this_model_name();
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
     {
135 135
         $entity = $model->get_one_by_ID($ID);
136 136
         $model_name = $model->get_this_model_name();
137
-        $class_name = 'EE_' . $model_name;
137
+        $class_name = 'EE_'.$model_name;
138 138
         if ($entity instanceof $class_name) {
139 139
             /** @var EE_Base_Class $entity */
140 140
             return $entity;
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
     {
201 201
         $primaryKey = $model->get_primary_key_field()->get_name(); // e.g. "FSC_UUID" will give us "FSC"
202 202
         [$keyPrefix] = explode('_', $primaryKey);
203
-        $uuid_field  = $keyPrefix . '_UUID'; // e.g. "FSC_UUID"
203
+        $uuid_field  = $keyPrefix.'_UUID'; // e.g. "FSC_UUID"
204 204
         return $model->has_field($uuid_field);
205 205
     }
206 206
 
Please login to merge, or discard this patch.
core/domain/services/graphql/data/mutations/DatetimeMutation.php 2 patches
Indentation   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -20,136 +20,136 @@
 block discarded – undo
20 20
  */
21 21
 class DatetimeMutation
22 22
 {
23
-    /**
24
-     * Maps the GraphQL input to a format that the model functions can use
25
-     *
26
-     * @param array $input Data coming from the GraphQL mutation query input
27
-     * @return array
28
-     * @throws Exception
29
-     */
30
-    public static function prepareFields(array $input): array
31
-    {
32
-        $args = [];
33
-
34
-        if (array_key_exists('capacity', $input)) {
35
-            $args['DTT_reg_limit'] = (int) $input['capacity'];
36
-        }
37
-
38
-        if (isset($input['description'])) {
39
-            $args['DTT_description'] = wp_kses_post($input['description']);
40
-        }
41
-
42
-        if (! empty($input['endDate'])) {
43
-            $args['DTT_EVT_end'] = new DateTime(sanitize_text_field($input['endDate']));
44
-        }
45
-
46
-        if (! empty($input['eventId'])) {
47
-            $args['EVT_ID'] = absint($input['eventId']);
48
-        } elseif (! empty($input['event'])) {
49
-            $parts = Relay::fromGlobalId(sanitize_text_field($input['event']));
50
-            $args['EVT_ID'] = ! empty($parts['id']) ? $parts['id'] : null;
51
-        }
52
-
53
-        if (array_key_exists('isPrimary', $input)) {
54
-            $args['DTT_is_primary'] = (bool) $input['isPrimary'];
55
-        }
56
-
57
-        if (array_key_exists('isTrashed', $input)) {
58
-            $args['DTT_deleted'] = (bool) $input['isTrashed'];
59
-        }
60
-
61
-        if (isset($input['name'])) {
62
-            $args['DTT_name'] = sanitize_text_field($input['name']);
63
-        }
64
-
65
-        if (array_key_exists('order', $input)) {
66
-            $args['DTT_order'] = (int) $input['order'];
67
-        }
68
-
69
-        if (! empty($input['parent'])) {
70
-            $parts = Relay::fromGlobalId(sanitize_text_field($input['parent']));
71
-            $args['DTT_parent'] = ! empty($parts['id']) ? $parts['id'] : null;
72
-        }
73
-
74
-        if (array_key_exists('reserved', $input)) {
75
-            $args['DTT_reserved'] = (int) $input['reserved'];
76
-        }
77
-
78
-        if (array_key_exists('sold', $input)) {
79
-            $args['DTT_sold'] = (int) $input['sold'];
80
-        }
81
-
82
-        if (! empty($input['startDate'])) {
83
-            $args['DTT_EVT_start'] = new DateTime(sanitize_text_field($input['startDate']));
84
-        }
85
-
86
-        if (! empty($input['tickets'])) {
87
-            $args['tickets'] = array_map('sanitize_text_field', (array) $input['tickets']);
88
-        }
89
-
90
-        if (array_key_exists('venue', $input)) {
91
-            $venue_id = sanitize_text_field($input['venue']);
92
-            $parts = Relay::fromGlobalId($venue_id);
93
-            $venue_id = ! empty($parts['id']) ? $parts['id'] : $venue_id;
94
-            $args['venue'] = absint($venue_id);
95
-        }
96
-
97
-        return apply_filters(
98
-            'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__datetime_args',
99
-            $args,
100
-            $input
101
-        );
102
-    }
103
-
104
-
105
-    /**
106
-     * Sets the related tickets for the given datetime.
107
-     *
108
-     * @param EE_Datetime $entity  The datetime instance.
109
-     * @param array       $tickets Array of ticket IDs to relate.
110
-     * @throws EE_Error
111
-     * @throws InvalidDataTypeException
112
-     * @throws InvalidInterfaceException
113
-     * @throws InvalidArgumentException
114
-     * @throws ReflectionException
115
-     */
116
-    public static function setRelatedTickets(EE_Datetime $entity, array $tickets)
117
-    {
118
-        $relationName = 'Ticket';
119
-        // Remove all the existing related tickets
120
-        $entity->_remove_relations($relationName);
121
-
122
-        foreach ($tickets as $ID) {
123
-            $parts = Relay::fromGlobalId($ID);
124
-            if (! empty($parts['id']) && absint($parts['id'])) {
125
-                $entity->_add_relation_to(
126
-                    $parts['id'],
127
-                    $relationName
128
-                );
129
-            }
130
-        }
131
-    }
132
-
133
-
134
-    /**
135
-     * Sets the venue for the datetime.
136
-     *
137
-     * @param EE_Datetime $entity The datetime instance.
138
-     * @param int      $venue  The venue ID
139
-     * @throws EE_Error
140
-     * @throws InvalidDataTypeException
141
-     * @throws InvalidInterfaceException
142
-     * @throws InvalidArgumentException
143
-     * @throws ReflectionException
144
-     */
145
-    public static function setVenue(EE_Datetime $entity, int $venue)
146
-    {
147
-        if (empty($venue)) {
148
-            if (! is_null($entity->venue())) {
149
-                $entity->remove_venue($venue);
150
-            }
151
-        } else {
152
-            $entity->add_venue($venue);
153
-        }
154
-    }
23
+	/**
24
+	 * Maps the GraphQL input to a format that the model functions can use
25
+	 *
26
+	 * @param array $input Data coming from the GraphQL mutation query input
27
+	 * @return array
28
+	 * @throws Exception
29
+	 */
30
+	public static function prepareFields(array $input): array
31
+	{
32
+		$args = [];
33
+
34
+		if (array_key_exists('capacity', $input)) {
35
+			$args['DTT_reg_limit'] = (int) $input['capacity'];
36
+		}
37
+
38
+		if (isset($input['description'])) {
39
+			$args['DTT_description'] = wp_kses_post($input['description']);
40
+		}
41
+
42
+		if (! empty($input['endDate'])) {
43
+			$args['DTT_EVT_end'] = new DateTime(sanitize_text_field($input['endDate']));
44
+		}
45
+
46
+		if (! empty($input['eventId'])) {
47
+			$args['EVT_ID'] = absint($input['eventId']);
48
+		} elseif (! empty($input['event'])) {
49
+			$parts = Relay::fromGlobalId(sanitize_text_field($input['event']));
50
+			$args['EVT_ID'] = ! empty($parts['id']) ? $parts['id'] : null;
51
+		}
52
+
53
+		if (array_key_exists('isPrimary', $input)) {
54
+			$args['DTT_is_primary'] = (bool) $input['isPrimary'];
55
+		}
56
+
57
+		if (array_key_exists('isTrashed', $input)) {
58
+			$args['DTT_deleted'] = (bool) $input['isTrashed'];
59
+		}
60
+
61
+		if (isset($input['name'])) {
62
+			$args['DTT_name'] = sanitize_text_field($input['name']);
63
+		}
64
+
65
+		if (array_key_exists('order', $input)) {
66
+			$args['DTT_order'] = (int) $input['order'];
67
+		}
68
+
69
+		if (! empty($input['parent'])) {
70
+			$parts = Relay::fromGlobalId(sanitize_text_field($input['parent']));
71
+			$args['DTT_parent'] = ! empty($parts['id']) ? $parts['id'] : null;
72
+		}
73
+
74
+		if (array_key_exists('reserved', $input)) {
75
+			$args['DTT_reserved'] = (int) $input['reserved'];
76
+		}
77
+
78
+		if (array_key_exists('sold', $input)) {
79
+			$args['DTT_sold'] = (int) $input['sold'];
80
+		}
81
+
82
+		if (! empty($input['startDate'])) {
83
+			$args['DTT_EVT_start'] = new DateTime(sanitize_text_field($input['startDate']));
84
+		}
85
+
86
+		if (! empty($input['tickets'])) {
87
+			$args['tickets'] = array_map('sanitize_text_field', (array) $input['tickets']);
88
+		}
89
+
90
+		if (array_key_exists('venue', $input)) {
91
+			$venue_id = sanitize_text_field($input['venue']);
92
+			$parts = Relay::fromGlobalId($venue_id);
93
+			$venue_id = ! empty($parts['id']) ? $parts['id'] : $venue_id;
94
+			$args['venue'] = absint($venue_id);
95
+		}
96
+
97
+		return apply_filters(
98
+			'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__datetime_args',
99
+			$args,
100
+			$input
101
+		);
102
+	}
103
+
104
+
105
+	/**
106
+	 * Sets the related tickets for the given datetime.
107
+	 *
108
+	 * @param EE_Datetime $entity  The datetime instance.
109
+	 * @param array       $tickets Array of ticket IDs to relate.
110
+	 * @throws EE_Error
111
+	 * @throws InvalidDataTypeException
112
+	 * @throws InvalidInterfaceException
113
+	 * @throws InvalidArgumentException
114
+	 * @throws ReflectionException
115
+	 */
116
+	public static function setRelatedTickets(EE_Datetime $entity, array $tickets)
117
+	{
118
+		$relationName = 'Ticket';
119
+		// Remove all the existing related tickets
120
+		$entity->_remove_relations($relationName);
121
+
122
+		foreach ($tickets as $ID) {
123
+			$parts = Relay::fromGlobalId($ID);
124
+			if (! empty($parts['id']) && absint($parts['id'])) {
125
+				$entity->_add_relation_to(
126
+					$parts['id'],
127
+					$relationName
128
+				);
129
+			}
130
+		}
131
+	}
132
+
133
+
134
+	/**
135
+	 * Sets the venue for the datetime.
136
+	 *
137
+	 * @param EE_Datetime $entity The datetime instance.
138
+	 * @param int      $venue  The venue ID
139
+	 * @throws EE_Error
140
+	 * @throws InvalidDataTypeException
141
+	 * @throws InvalidInterfaceException
142
+	 * @throws InvalidArgumentException
143
+	 * @throws ReflectionException
144
+	 */
145
+	public static function setVenue(EE_Datetime $entity, int $venue)
146
+	{
147
+		if (empty($venue)) {
148
+			if (! is_null($entity->venue())) {
149
+				$entity->remove_venue($venue);
150
+			}
151
+		} else {
152
+			$entity->add_venue($venue);
153
+		}
154
+	}
155 155
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
             $args['DTT_description'] = wp_kses_post($input['description']);
40 40
         }
41 41
 
42
-        if (! empty($input['endDate'])) {
42
+        if ( ! empty($input['endDate'])) {
43 43
             $args['DTT_EVT_end'] = new DateTime(sanitize_text_field($input['endDate']));
44 44
         }
45 45
 
46
-        if (! empty($input['eventId'])) {
46
+        if ( ! empty($input['eventId'])) {
47 47
             $args['EVT_ID'] = absint($input['eventId']);
48
-        } elseif (! empty($input['event'])) {
48
+        } elseif ( ! empty($input['event'])) {
49 49
             $parts = Relay::fromGlobalId(sanitize_text_field($input['event']));
50 50
             $args['EVT_ID'] = ! empty($parts['id']) ? $parts['id'] : null;
51 51
         }
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
             $args['DTT_order'] = (int) $input['order'];
67 67
         }
68 68
 
69
-        if (! empty($input['parent'])) {
69
+        if ( ! empty($input['parent'])) {
70 70
             $parts = Relay::fromGlobalId(sanitize_text_field($input['parent']));
71 71
             $args['DTT_parent'] = ! empty($parts['id']) ? $parts['id'] : null;
72 72
         }
@@ -79,11 +79,11 @@  discard block
 block discarded – undo
79 79
             $args['DTT_sold'] = (int) $input['sold'];
80 80
         }
81 81
 
82
-        if (! empty($input['startDate'])) {
82
+        if ( ! empty($input['startDate'])) {
83 83
             $args['DTT_EVT_start'] = new DateTime(sanitize_text_field($input['startDate']));
84 84
         }
85 85
 
86
-        if (! empty($input['tickets'])) {
86
+        if ( ! empty($input['tickets'])) {
87 87
             $args['tickets'] = array_map('sanitize_text_field', (array) $input['tickets']);
88 88
         }
89 89
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 
122 122
         foreach ($tickets as $ID) {
123 123
             $parts = Relay::fromGlobalId($ID);
124
-            if (! empty($parts['id']) && absint($parts['id'])) {
124
+            if ( ! empty($parts['id']) && absint($parts['id'])) {
125 125
                 $entity->_add_relation_to(
126 126
                     $parts['id'],
127 127
                     $relationName
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
     public static function setVenue(EE_Datetime $entity, int $venue)
146 146
     {
147 147
         if (empty($venue)) {
148
-            if (! is_null($entity->venue())) {
148
+            if ( ! is_null($entity->venue())) {
149 149
                 $entity->remove_venue($venue);
150 150
             }
151 151
         } else {
Please login to merge, or discard this patch.
domain/services/graphql/connection_resolvers/AbstractConnectionResolver.php 2 patches
Indentation   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -19,165 +19,165 @@
 block discarded – undo
19 19
  */
20 20
 abstract class AbstractConnectionResolver extends WPGraphQLConnectionResolver
21 21
 {
22
-    public const MAX_QUERY_LIMIT = 250;
23
-
24
-    private ?Utilities $utilities = null;
25
-
26
-
27
-    public function __construct($source, array $args, AppContext $context, ResolveInfo $info)
28
-    {
29
-        add_filter(
30
-            'graphql_connection_max_query_amount',
31
-            static function ($max_query_amount) {
32
-                return self::MAX_QUERY_LIMIT;
33
-            }
34
-        );
35
-        parent::__construct($source, $args, $context, $info);
36
-    }
37
-
38
-
39
-    /**
40
-     * @return Utilities
41
-     */
42
-    public function getUtilities(): Utilities
43
-    {
44
-        if (! $this->utilities instanceof Utilities) {
45
-            $this->utilities = LoaderFactory::getLoader()->getShared(Utilities::class);
46
-        }
47
-        return $this->utilities;
48
-    }
49
-
50
-
51
-    /**
52
-     * Set limit the highest value of first and last, with a (filterable) max of 500
53
-     *
54
-     * @return int
55
-     */
56
-    protected function getLimit(): int
57
-    {
58
-        $first = ! empty($this->args['first'])
59
-            ? absint($this->args['first'])
60
-            : null;
61
-        $last  = ! empty($this->args['last'])
62
-            ? absint($this->args['last'])
63
-            : null;
64
-
65
-        $limit = min(
66
-            max($first, $last, self::MAX_QUERY_LIMIT),
67
-            $this->query_amount
68
-        );
69
-        $limit++;
70
-        return $limit;
71
-    }
72
-
73
-    // /**
74
-    //  * Get_amount_requested
75
-    //  *
76
-    //  * This checks the $args to determine the amount requested
77
-    //  *
78
-    //  * @return int|null
79
-    //  * @throws Exception
80
-    //  */
81
-    // // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
82
-    // public function get_amount_requested(): ?int
83
-    // {
84
-    //     $amount_requested = parent::get_amount_requested();
85
-    //
86
-    //     /**
87
-    //      * If both first & last are used in the input args, throw an exception as that won't
88
-    //      * work properly
89
-    //      */
90
-    //     if (empty($this->args['first']) && empty($this->args['last']) && $amount_requested === ConnectionsManager::MAX_AMOUNT_REQUESTED) {
91
-    //         return ConnectionsManager::MAX_AMOUNT_REQUESTED; // default.
92
-    //     }
93
-    //
94
-    //     return $amount_requested;
95
-    // }
96
-
97
-    /**
98
-     * Determine whether the offset is valid, i.e the entity corresponding to the
99
-     * offset exists. Offset is equivalent to entity ID. So this function is equivalent to
100
-     * checking if the entity with the given ID exists.
101
-     *
102
-     * @param int $offset The ID of the node used for the cursor offset
103
-     * @return bool
104
-     */
105
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
106
-    public function is_valid_offset($offset): bool
107
-    {
108
-        $entity = $this->get_query()->get_one_by_ID($offset);
109
-
110
-        return $entity instanceof EE_Base_Class;
111
-    }
112
-
113
-    /**
114
-     * Validates Model.
115
-     *
116
-     * @param EE_Base_Class|null $model Entity node.
117
-     * @return bool
118
-     */
119
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
120
-    protected function is_valid_model($model): bool
121
-    {
122
-        return $model instanceof EE_Base_Class;
123
-    }
124
-
125
-
126
-    /**
127
-     * Map the orderby inputArgs to the WP_Query
128
-     *
129
-     * @param array  $query_args
130
-     * @param array  $where_params
131
-     * @param string $primary_key
132
-     * @return array
133
-     */
134
-    protected function mapOrderbyInputArgs(array $query_args, array $where_params, string $primary_key): array
135
-    {
136
-        // ID of the current offset
137
-        $cursor = $this->args['after'] ?? null;
138
-        $cursor = $cursor ?: ($this->args['before'] ?? null);
139
-        $offset = $this->get_offset_for_cursor($cursor);
140
-
141
-        if (! empty($this->args['where']['orderby']) && is_array($this->args['where']['orderby'])) {
142
-            $query_args['order_by'] = [];
143
-            foreach ($this->args['where']['orderby'] as $orderby_input) {
144
-                $query_args['order_by'][ $orderby_input['field'] ] = $orderby_input['order'];
145
-            }
146
-        } elseif ($offset) {
147
-            $compare = $this->args['last'] ? '<' : '>';
148
-            $where_params[ $primary_key ] = [$compare, $offset];
149
-        }
150
-        return [$query_args, $where_params];
151
-    }
152
-
153
-
154
-    /**
155
-     * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model
156
-     * friendly keys.
157
-     *
158
-     * @param array $where_args
159
-     * @param array $arg_mapping Array where keys are GQL field names and values are EE model field names.
160
-     * @param array $id_fields The fields to convert from global IDs to DB IDs.
161
-     * @return array
162
-     */
163
-    protected function sanitizeWhereArgsForInputFields(array $where_args, array $arg_mapping, array $id_fields = []): array
164
-    {
165
-        return $this->getUtilities()->sanitizeWhereArgs($where_args, $arg_mapping, $id_fields);
166
-    }
167
-
168
-
169
-    /**
170
-     * This returns the sanitized "search" keywords from where_args
171
-     *
172
-     * @param array $where_args
173
-     * @return string
174
-     */
175
-    protected function getSearchKeywords(array $where_args): string
176
-    {
177
-        $search = '';
178
-        if (! empty($where_args['search'])) {
179
-            $search = sanitize_text_field($where_args['search']);
180
-        }
181
-        return esc_sql($search);
182
-    }
22
+	public const MAX_QUERY_LIMIT = 250;
23
+
24
+	private ?Utilities $utilities = null;
25
+
26
+
27
+	public function __construct($source, array $args, AppContext $context, ResolveInfo $info)
28
+	{
29
+		add_filter(
30
+			'graphql_connection_max_query_amount',
31
+			static function ($max_query_amount) {
32
+				return self::MAX_QUERY_LIMIT;
33
+			}
34
+		);
35
+		parent::__construct($source, $args, $context, $info);
36
+	}
37
+
38
+
39
+	/**
40
+	 * @return Utilities
41
+	 */
42
+	public function getUtilities(): Utilities
43
+	{
44
+		if (! $this->utilities instanceof Utilities) {
45
+			$this->utilities = LoaderFactory::getLoader()->getShared(Utilities::class);
46
+		}
47
+		return $this->utilities;
48
+	}
49
+
50
+
51
+	/**
52
+	 * Set limit the highest value of first and last, with a (filterable) max of 500
53
+	 *
54
+	 * @return int
55
+	 */
56
+	protected function getLimit(): int
57
+	{
58
+		$first = ! empty($this->args['first'])
59
+			? absint($this->args['first'])
60
+			: null;
61
+		$last  = ! empty($this->args['last'])
62
+			? absint($this->args['last'])
63
+			: null;
64
+
65
+		$limit = min(
66
+			max($first, $last, self::MAX_QUERY_LIMIT),
67
+			$this->query_amount
68
+		);
69
+		$limit++;
70
+		return $limit;
71
+	}
72
+
73
+	// /**
74
+	//  * Get_amount_requested
75
+	//  *
76
+	//  * This checks the $args to determine the amount requested
77
+	//  *
78
+	//  * @return int|null
79
+	//  * @throws Exception
80
+	//  */
81
+	// // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
82
+	// public function get_amount_requested(): ?int
83
+	// {
84
+	//     $amount_requested = parent::get_amount_requested();
85
+	//
86
+	//     /**
87
+	//      * If both first & last are used in the input args, throw an exception as that won't
88
+	//      * work properly
89
+	//      */
90
+	//     if (empty($this->args['first']) && empty($this->args['last']) && $amount_requested === ConnectionsManager::MAX_AMOUNT_REQUESTED) {
91
+	//         return ConnectionsManager::MAX_AMOUNT_REQUESTED; // default.
92
+	//     }
93
+	//
94
+	//     return $amount_requested;
95
+	// }
96
+
97
+	/**
98
+	 * Determine whether the offset is valid, i.e the entity corresponding to the
99
+	 * offset exists. Offset is equivalent to entity ID. So this function is equivalent to
100
+	 * checking if the entity with the given ID exists.
101
+	 *
102
+	 * @param int $offset The ID of the node used for the cursor offset
103
+	 * @return bool
104
+	 */
105
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
106
+	public function is_valid_offset($offset): bool
107
+	{
108
+		$entity = $this->get_query()->get_one_by_ID($offset);
109
+
110
+		return $entity instanceof EE_Base_Class;
111
+	}
112
+
113
+	/**
114
+	 * Validates Model.
115
+	 *
116
+	 * @param EE_Base_Class|null $model Entity node.
117
+	 * @return bool
118
+	 */
119
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
120
+	protected function is_valid_model($model): bool
121
+	{
122
+		return $model instanceof EE_Base_Class;
123
+	}
124
+
125
+
126
+	/**
127
+	 * Map the orderby inputArgs to the WP_Query
128
+	 *
129
+	 * @param array  $query_args
130
+	 * @param array  $where_params
131
+	 * @param string $primary_key
132
+	 * @return array
133
+	 */
134
+	protected function mapOrderbyInputArgs(array $query_args, array $where_params, string $primary_key): array
135
+	{
136
+		// ID of the current offset
137
+		$cursor = $this->args['after'] ?? null;
138
+		$cursor = $cursor ?: ($this->args['before'] ?? null);
139
+		$offset = $this->get_offset_for_cursor($cursor);
140
+
141
+		if (! empty($this->args['where']['orderby']) && is_array($this->args['where']['orderby'])) {
142
+			$query_args['order_by'] = [];
143
+			foreach ($this->args['where']['orderby'] as $orderby_input) {
144
+				$query_args['order_by'][ $orderby_input['field'] ] = $orderby_input['order'];
145
+			}
146
+		} elseif ($offset) {
147
+			$compare = $this->args['last'] ? '<' : '>';
148
+			$where_params[ $primary_key ] = [$compare, $offset];
149
+		}
150
+		return [$query_args, $where_params];
151
+	}
152
+
153
+
154
+	/**
155
+	 * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model
156
+	 * friendly keys.
157
+	 *
158
+	 * @param array $where_args
159
+	 * @param array $arg_mapping Array where keys are GQL field names and values are EE model field names.
160
+	 * @param array $id_fields The fields to convert from global IDs to DB IDs.
161
+	 * @return array
162
+	 */
163
+	protected function sanitizeWhereArgsForInputFields(array $where_args, array $arg_mapping, array $id_fields = []): array
164
+	{
165
+		return $this->getUtilities()->sanitizeWhereArgs($where_args, $arg_mapping, $id_fields);
166
+	}
167
+
168
+
169
+	/**
170
+	 * This returns the sanitized "search" keywords from where_args
171
+	 *
172
+	 * @param array $where_args
173
+	 * @return string
174
+	 */
175
+	protected function getSearchKeywords(array $where_args): string
176
+	{
177
+		$search = '';
178
+		if (! empty($where_args['search'])) {
179
+			$search = sanitize_text_field($where_args['search']);
180
+		}
181
+		return esc_sql($search);
182
+	}
183 183
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
     {
29 29
         add_filter(
30 30
             'graphql_connection_max_query_amount',
31
-            static function ($max_query_amount) {
31
+            static function($max_query_amount) {
32 32
                 return self::MAX_QUERY_LIMIT;
33 33
             }
34 34
         );
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public function getUtilities(): Utilities
43 43
     {
44
-        if (! $this->utilities instanceof Utilities) {
44
+        if ( ! $this->utilities instanceof Utilities) {
45 45
             $this->utilities = LoaderFactory::getLoader()->getShared(Utilities::class);
46 46
         }
47 47
         return $this->utilities;
@@ -138,14 +138,14 @@  discard block
 block discarded – undo
138 138
         $cursor = $cursor ?: ($this->args['before'] ?? null);
139 139
         $offset = $this->get_offset_for_cursor($cursor);
140 140
 
141
-        if (! empty($this->args['where']['orderby']) && is_array($this->args['where']['orderby'])) {
141
+        if ( ! empty($this->args['where']['orderby']) && is_array($this->args['where']['orderby'])) {
142 142
             $query_args['order_by'] = [];
143 143
             foreach ($this->args['where']['orderby'] as $orderby_input) {
144
-                $query_args['order_by'][ $orderby_input['field'] ] = $orderby_input['order'];
144
+                $query_args['order_by'][$orderby_input['field']] = $orderby_input['order'];
145 145
             }
146 146
         } elseif ($offset) {
147 147
             $compare = $this->args['last'] ? '<' : '>';
148
-            $where_params[ $primary_key ] = [$compare, $offset];
148
+            $where_params[$primary_key] = [$compare, $offset];
149 149
         }
150 150
         return [$query_args, $where_params];
151 151
     }
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
     protected function getSearchKeywords(array $where_args): string
176 176
     {
177 177
         $search = '';
178
-        if (! empty($where_args['search'])) {
178
+        if ( ! empty($where_args['search'])) {
179 179
             $search = sanitize_text_field($where_args['search']);
180 180
         }
181 181
         return esc_sql($search);
Please login to merge, or discard this patch.
services/admin/registrations/list_table/page_header/EventFilterHeader.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -21,66 +21,66 @@
 block discarded – undo
21 21
  */
22 22
 class EventFilterHeader extends AdminPageHeaderDecorator
23 23
 {
24
-    private EEM_Event $event_model;
24
+	private EEM_Event $event_model;
25 25
 
26 26
 
27
-    /**
28
-     * EventFilterHeader constructor.
29
-     *
30
-     * @param RequestInterface $request
31
-     * @param EEM_Event        $event_model
32
-     */
33
-    public function __construct(RequestInterface $request, EEM_Event $event_model)
34
-    {
35
-        parent::__construct($request);
36
-        $this->event_model = $event_model;
37
-    }
27
+	/**
28
+	 * EventFilterHeader constructor.
29
+	 *
30
+	 * @param RequestInterface $request
31
+	 * @param EEM_Event        $event_model
32
+	 */
33
+	public function __construct(RequestInterface $request, EEM_Event $event_model)
34
+	{
35
+		parent::__construct($request);
36
+		$this->event_model = $event_model;
37
+	}
38 38
 
39 39
 
40
-    /**
41
-     * @param string $text
42
-     * @return string
43
-     * @throws EE_Error
44
-     * @throws ReflectionException
45
-     * @since 4.10.2.p
46
-     */
47
-    public function getHeaderText(string $text = ''): string
48
-    {
49
-        $EVT_ID = $this->request->getRequestParam('EVT_ID');
50
-        $EVT_ID = $this->request->getRequestParam('event_id', $EVT_ID, 'int');
51
-        $reg_status_code = $this->request->getRequestParam('_reg_status', '');
52
-        $reg_statuses    = $reg_status_code
53
-            ? EEM_Status::instance()->localized_status(
54
-                [$reg_status_code => 'APPROVED'],
55
-                false,
56
-                'lowercase'
57
-            )
58
-            : [];
59
-        $reg_status = $reg_statuses[ $reg_status_code ] ?? '';
60
-        if ($EVT_ID) {
61
-            $event = $this->event_model->get_one_by_ID($EVT_ID);
62
-            if ($event instanceof EE_Event) {
63
-                $text .= sprintf(
64
-                    /* translators: %s: <h3>  %s: <a href>Event Name</a>  %s: </h3> */
65
-                    // phpcs:ignore WordPress.WP.I18n.UnorderedPlaceholdersText
66
-                    esc_html__('%s Viewing%s registrations for the event: %s%s', 'event_espresso'),
67
-                    '<h3 class="ee-filter-header__text">',
68
-                    $reg_status ? " <span class='ee-status-outline ee-status-outline--micro ee-status-bg--$reg_status_code'>$reg_status</span>" : '',
69
-                    '&nbsp;<a href="'
70
-                    . EE_Admin_Page::add_query_args_and_nonce(
71
-                        array(
72
-                            'action' => 'edit',
73
-                            'post'   => $event->ID(),
74
-                        ),
75
-                        EVENTS_ADMIN_URL
76
-                    )
77
-                    . '">'
78
-                    . $event->get('EVT_name')
79
-                    . '</a>&nbsp;',
80
-                    '</h3>'
81
-                );
82
-            }
83
-        }
84
-        return $text;
85
-    }
40
+	/**
41
+	 * @param string $text
42
+	 * @return string
43
+	 * @throws EE_Error
44
+	 * @throws ReflectionException
45
+	 * @since 4.10.2.p
46
+	 */
47
+	public function getHeaderText(string $text = ''): string
48
+	{
49
+		$EVT_ID = $this->request->getRequestParam('EVT_ID');
50
+		$EVT_ID = $this->request->getRequestParam('event_id', $EVT_ID, 'int');
51
+		$reg_status_code = $this->request->getRequestParam('_reg_status', '');
52
+		$reg_statuses    = $reg_status_code
53
+			? EEM_Status::instance()->localized_status(
54
+				[$reg_status_code => 'APPROVED'],
55
+				false,
56
+				'lowercase'
57
+			)
58
+			: [];
59
+		$reg_status = $reg_statuses[ $reg_status_code ] ?? '';
60
+		if ($EVT_ID) {
61
+			$event = $this->event_model->get_one_by_ID($EVT_ID);
62
+			if ($event instanceof EE_Event) {
63
+				$text .= sprintf(
64
+					/* translators: %s: <h3>  %s: <a href>Event Name</a>  %s: </h3> */
65
+					// phpcs:ignore WordPress.WP.I18n.UnorderedPlaceholdersText
66
+					esc_html__('%s Viewing%s registrations for the event: %s%s', 'event_espresso'),
67
+					'<h3 class="ee-filter-header__text">',
68
+					$reg_status ? " <span class='ee-status-outline ee-status-outline--micro ee-status-bg--$reg_status_code'>$reg_status</span>" : '',
69
+					'&nbsp;<a href="'
70
+					. EE_Admin_Page::add_query_args_and_nonce(
71
+						array(
72
+							'action' => 'edit',
73
+							'post'   => $event->ID(),
74
+						),
75
+						EVENTS_ADMIN_URL
76
+					)
77
+					. '">'
78
+					. $event->get('EVT_name')
79
+					. '</a>&nbsp;',
80
+					'</h3>'
81
+				);
82
+			}
83
+		}
84
+		return $text;
85
+	}
86 86
 }
Please login to merge, or discard this patch.
services/admin/registrations/list_table/page_header/DateFilterHeader.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -20,58 +20,58 @@
 block discarded – undo
20 20
  */
21 21
 class DateFilterHeader extends AdminPageHeaderDecorator
22 22
 {
23
-    private EEM_Datetime $datetime_model;
23
+	private EEM_Datetime $datetime_model;
24 24
 
25 25
 
26
-    /**
27
-     * DateFilterHeader constructor.
28
-     *
29
-     * @param RequestInterface $request
30
-     * @param EEM_Datetime     $datetime_model
31
-     */
32
-    public function __construct(RequestInterface $request, EEM_Datetime $datetime_model)
33
-    {
34
-        parent::__construct($request);
35
-        $this->datetime_model = $datetime_model;
36
-    }
26
+	/**
27
+	 * DateFilterHeader constructor.
28
+	 *
29
+	 * @param RequestInterface $request
30
+	 * @param EEM_Datetime     $datetime_model
31
+	 */
32
+	public function __construct(RequestInterface $request, EEM_Datetime $datetime_model)
33
+	{
34
+		parent::__construct($request);
35
+		$this->datetime_model = $datetime_model;
36
+	}
37 37
 
38 38
 
39
-    /**
40
-     * @param string $text
41
-     * @return string
42
-     * @throws EE_Error
43
-     * @throws ReflectionException
44
-     * @since 4.10.2.p
45
-     */
46
-    public function getHeaderText(string $text = ''): string
47
-    {
48
-        $DTT_ID = $this->request->getRequestParam('DTT_ID');
49
-        $DTT_ID = $this->request->getRequestParam('datetime_id', $DTT_ID, 'int');
50
-        if ($DTT_ID) {
51
-            $datetime = $this->datetime_model->get_one_by_ID($DTT_ID);
52
-            if ($datetime instanceof EE_Datetime && $text !== '') {
53
-                $active_status   = $datetime->get_active_status();
54
-                $datetime_status =
55
-                    '<span class="ee-status ee-status-bg--' . esc_attr($active_status) . ' event-active-status-' .
56
-                    esc_attr($active_status) . '">'
57
-                    . EEH_Template::pretty_status($active_status, false, 'sentence')
58
-                    . '</span>';
59
-                // remove the closing h3 heading tag if it exists
60
-                $text = str_replace(
61
-                    '</h3>',
62
-                    '',
63
-                    $text
64
-                );
65
-                $text .= '&nbsp; &nbsp; ';
66
-                $text .= '<span class="ee-filter-header__details">';
67
-                $text .= '<span class="dashicons dashicons-calendar-alt"></span>';
68
-                $text .= $datetime->name();
69
-                $text .= ' ( ' . $datetime->start_date() . ' )';
70
-                $text .= $datetime_status;
71
-                $text .= '</span></h3>';
72
-            }
73
-        }
39
+	/**
40
+	 * @param string $text
41
+	 * @return string
42
+	 * @throws EE_Error
43
+	 * @throws ReflectionException
44
+	 * @since 4.10.2.p
45
+	 */
46
+	public function getHeaderText(string $text = ''): string
47
+	{
48
+		$DTT_ID = $this->request->getRequestParam('DTT_ID');
49
+		$DTT_ID = $this->request->getRequestParam('datetime_id', $DTT_ID, 'int');
50
+		if ($DTT_ID) {
51
+			$datetime = $this->datetime_model->get_one_by_ID($DTT_ID);
52
+			if ($datetime instanceof EE_Datetime && $text !== '') {
53
+				$active_status   = $datetime->get_active_status();
54
+				$datetime_status =
55
+					'<span class="ee-status ee-status-bg--' . esc_attr($active_status) . ' event-active-status-' .
56
+					esc_attr($active_status) . '">'
57
+					. EEH_Template::pretty_status($active_status, false, 'sentence')
58
+					. '</span>';
59
+				// remove the closing h3 heading tag if it exists
60
+				$text = str_replace(
61
+					'</h3>',
62
+					'',
63
+					$text
64
+				);
65
+				$text .= '&nbsp; &nbsp; ';
66
+				$text .= '<span class="ee-filter-header__details">';
67
+				$text .= '<span class="dashicons dashicons-calendar-alt"></span>';
68
+				$text .= $datetime->name();
69
+				$text .= ' ( ' . $datetime->start_date() . ' )';
70
+				$text .= $datetime_status;
71
+				$text .= '</span></h3>';
72
+			}
73
+		}
74 74
 
75
-        return $text;
76
-    }
75
+		return $text;
76
+	}
77 77
 }
Please login to merge, or discard this patch.
services/admin/registrations/list_table/page_header/TicketFilterHeader.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -19,58 +19,58 @@
 block discarded – undo
19 19
  */
20 20
 class TicketFilterHeader extends AdminPageHeaderDecorator
21 21
 {
22
-    private EEM_Ticket $ticket_model;
22
+	private EEM_Ticket $ticket_model;
23 23
 
24 24
 
25
-    /**
26
-     * TicketFilterHeader constructor.
27
-     *
28
-     * @param RequestInterface $request
29
-     * @param EEM_Ticket       $ticket_model
30
-     */
31
-    public function __construct(RequestInterface $request, EEM_Ticket $ticket_model)
32
-    {
33
-        parent::__construct($request);
34
-        $this->ticket_model = $ticket_model;
35
-    }
25
+	/**
26
+	 * TicketFilterHeader constructor.
27
+	 *
28
+	 * @param RequestInterface $request
29
+	 * @param EEM_Ticket       $ticket_model
30
+	 */
31
+	public function __construct(RequestInterface $request, EEM_Ticket $ticket_model)
32
+	{
33
+		parent::__construct($request);
34
+		$this->ticket_model = $ticket_model;
35
+	}
36 36
 
37 37
 
38
-    /**
39
-     * @param string $text
40
-     * @return string
41
-     * @throws EE_Error
42
-     * @throws ReflectionException
43
-     * @since 4.10.2.p
44
-     */
45
-    public function getHeaderText(string $text = ''): string
46
-    {
47
-        $TKT_ID = $this->request->getRequestParam('TKT_ID');
48
-        $TKT_ID = $this->request->getRequestParam('ticket_id', $TKT_ID, 'int');
49
-        if ($TKT_ID) {
50
-            $ticket = $this->ticket_model->get_one_by_ID($TKT_ID);
51
-            if ($ticket instanceof EE_Ticket) {
52
-                $ticket_details = '<span class="ee-ticket-name">' . $ticket->name() . '</span> ';
53
-                $ticket_details .= ! $ticket->is_free()
54
-                    ? '<span class="ee-ticket-price">' . $ticket->pretty_price() . '</span>'
55
-                    : '<span class="reg-overview-free-event-spn">'
56
-                      . esc_html__('free', 'event_espresso')
57
-                      . '</span>';
58
-                // remove the closing h3 heading tag if it exists
59
-                $text = str_replace(
60
-                    '</h3>',
61
-                    '',
62
-                    $text
63
-                );
64
-                if (empty($text)) {
65
-                    $text = '<h3 class="ee-filter-header__text">';
66
-                    $text .= esc_html__('Viewing registrations for ticket:', 'event_espresso');
67
-                }
68
-                $text .= '&nbsp; &nbsp; ';
69
-                $text .= '<span class="ee-filter-header__details">';
70
-                $text .= '<span class="dashicons dashicons-tickets-alt"></span>';
71
-                $text .= $ticket_details . '</span></h3>';
72
-            }
73
-        }
74
-        return $text;
75
-    }
38
+	/**
39
+	 * @param string $text
40
+	 * @return string
41
+	 * @throws EE_Error
42
+	 * @throws ReflectionException
43
+	 * @since 4.10.2.p
44
+	 */
45
+	public function getHeaderText(string $text = ''): string
46
+	{
47
+		$TKT_ID = $this->request->getRequestParam('TKT_ID');
48
+		$TKT_ID = $this->request->getRequestParam('ticket_id', $TKT_ID, 'int');
49
+		if ($TKT_ID) {
50
+			$ticket = $this->ticket_model->get_one_by_ID($TKT_ID);
51
+			if ($ticket instanceof EE_Ticket) {
52
+				$ticket_details = '<span class="ee-ticket-name">' . $ticket->name() . '</span> ';
53
+				$ticket_details .= ! $ticket->is_free()
54
+					? '<span class="ee-ticket-price">' . $ticket->pretty_price() . '</span>'
55
+					: '<span class="reg-overview-free-event-spn">'
56
+					  . esc_html__('free', 'event_espresso')
57
+					  . '</span>';
58
+				// remove the closing h3 heading tag if it exists
59
+				$text = str_replace(
60
+					'</h3>',
61
+					'',
62
+					$text
63
+				);
64
+				if (empty($text)) {
65
+					$text = '<h3 class="ee-filter-header__text">';
66
+					$text .= esc_html__('Viewing registrations for ticket:', 'event_espresso');
67
+				}
68
+				$text .= '&nbsp; &nbsp; ';
69
+				$text .= '<span class="ee-filter-header__details">';
70
+				$text .= '<span class="dashicons dashicons-tickets-alt"></span>';
71
+				$text .= $ticket_details . '</span></h3>';
72
+			}
73
+		}
74
+		return $text;
75
+	}
76 76
 }
Please login to merge, or discard this patch.
admin/registrations/list_table/page_header/AttendeeFilterHeader.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -20,53 +20,53 @@
 block discarded – undo
20 20
  */
21 21
 class AttendeeFilterHeader extends AdminPageHeaderDecorator
22 22
 {
23
-    private EEM_Attendee $attendee_model;
23
+	private EEM_Attendee $attendee_model;
24 24
 
25 25
 
26
-    /**
27
-     * AttendeeFilterHeader constructor.
28
-     *
29
-     * @param RequestInterface $request
30
-     * @param EEM_Attendee     $attendee_model
31
-     */
32
-    public function __construct(RequestInterface $request, EEM_Attendee $attendee_model)
33
-    {
34
-        parent::__construct($request);
35
-        $this->attendee_model = $attendee_model;
36
-    }
26
+	/**
27
+	 * AttendeeFilterHeader constructor.
28
+	 *
29
+	 * @param RequestInterface $request
30
+	 * @param EEM_Attendee     $attendee_model
31
+	 */
32
+	public function __construct(RequestInterface $request, EEM_Attendee $attendee_model)
33
+	{
34
+		parent::__construct($request);
35
+		$this->attendee_model = $attendee_model;
36
+	}
37 37
 
38 38
 
39
-    /**
40
-     * @param string $text
41
-     * @return string
42
-     * @throws EE_Error
43
-     * @throws ReflectionException
44
-     * @since 4.10.2.p
45
-     */
46
-    public function getHeaderText(string $text = ''): string
47
-    {
48
-        $ATT_ID = $this->request->getRequestParam('ATT_ID');
49
-        $ATT_ID = $this->request->getRequestParam('attendee_id', $ATT_ID, 'int');
50
-        if ($ATT_ID) {
51
-            $attendee = $this->attendee_model->get_one_by_ID($ATT_ID);
52
-            if ($attendee instanceof EE_Attendee) {
53
-                $text .= sprintf(
54
-                    esc_html__(
55
-                        '%1$s Viewing registrations for %2$s%3$s',
56
-                        'event_espresso'
57
-                    ),
58
-                    '<h3 class="ee-filter-header__text">',
59
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
60
-                        array(
61
-                            'action' => 'edit_attendee',
62
-                            'post'   => $ATT_ID,
63
-                        ),
64
-                        REG_ADMIN_URL
65
-                    ) . '">' . $attendee->full_name() . '</a>',
66
-                    '</h3>'
67
-                );
68
-            }
69
-        }
70
-        return $text;
71
-    }
39
+	/**
40
+	 * @param string $text
41
+	 * @return string
42
+	 * @throws EE_Error
43
+	 * @throws ReflectionException
44
+	 * @since 4.10.2.p
45
+	 */
46
+	public function getHeaderText(string $text = ''): string
47
+	{
48
+		$ATT_ID = $this->request->getRequestParam('ATT_ID');
49
+		$ATT_ID = $this->request->getRequestParam('attendee_id', $ATT_ID, 'int');
50
+		if ($ATT_ID) {
51
+			$attendee = $this->attendee_model->get_one_by_ID($ATT_ID);
52
+			if ($attendee instanceof EE_Attendee) {
53
+				$text .= sprintf(
54
+					esc_html__(
55
+						'%1$s Viewing registrations for %2$s%3$s',
56
+						'event_espresso'
57
+					),
58
+					'<h3 class="ee-filter-header__text">',
59
+					'<a href="' . EE_Admin_Page::add_query_args_and_nonce(
60
+						array(
61
+							'action' => 'edit_attendee',
62
+							'post'   => $ATT_ID,
63
+						),
64
+						REG_ADMIN_URL
65
+					) . '">' . $attendee->full_name() . '</a>',
66
+					'</h3>'
67
+				);
68
+			}
69
+		}
70
+		return $text;
71
+	}
72 72
 }
Please login to merge, or discard this patch.