Completed
Branch FET/reg-form-builder/main (0f11d8)
by
unknown
02:56 queued 17s
created
core/domain/services/graphql/data/loaders/FormSectionLoader.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -15,27 +15,27 @@
 block discarded – undo
15 15
  */
16 16
 class FormSectionLoader extends AbstractLoader
17 17
 {
18
-    /**
19
-     * @return EEM_Base
20
-     * @throws EE_Error
21
-     * @throws InvalidArgumentException
22
-     * @throws InvalidDataTypeException
23
-     * @throws InvalidInterfaceException
24
-     * @throws ReflectionException
25
-     */
26
-    protected function getQuery(): EEM_Base
27
-    {
28
-        return EEM_Form_Section::instance();
29
-    }
18
+	/**
19
+	 * @return EEM_Base
20
+	 * @throws EE_Error
21
+	 * @throws InvalidArgumentException
22
+	 * @throws InvalidDataTypeException
23
+	 * @throws InvalidInterfaceException
24
+	 * @throws ReflectionException
25
+	 */
26
+	protected function getQuery(): EEM_Base
27
+	{
28
+		return EEM_Form_Section::instance();
29
+	}
30 30
 
31
-    /**
32
-     * @param array $keys
33
-     * @return array
34
-     */
35
-    protected function getWhereParams(array $keys): array
36
-    {
37
-        return [
38
-            'FSC_UUID' => ['IN', $keys],
39
-        ];
40
-    }
31
+	/**
32
+	 * @param array $keys
33
+	 * @return array
34
+	 */
35
+	protected function getWhereParams(array $keys): array
36
+	{
37
+		return [
38
+			'FSC_UUID' => ['IN', $keys],
39
+		];
40
+	}
41 41
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/data/loaders/TicketLoader.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -15,28 +15,28 @@
 block discarded – undo
15 15
  */
16 16
 class TicketLoader extends AbstractLoader
17 17
 {
18
-    /**
19
-     * @return EEM_Base
20
-     * @throws EE_Error
21
-     * @throws InvalidArgumentException
22
-     * @throws InvalidDataTypeException
23
-     * @throws InvalidInterfaceException
24
-     * @throws ReflectionException
25
-     */
26
-    protected function getQuery(): EEM_Base
27
-    {
28
-        return EEM_Ticket::instance();
29
-    }
18
+	/**
19
+	 * @return EEM_Base
20
+	 * @throws EE_Error
21
+	 * @throws InvalidArgumentException
22
+	 * @throws InvalidDataTypeException
23
+	 * @throws InvalidInterfaceException
24
+	 * @throws ReflectionException
25
+	 */
26
+	protected function getQuery(): EEM_Base
27
+	{
28
+		return EEM_Ticket::instance();
29
+	}
30 30
 
31
-    /**
32
-     * @param array $keys
33
-     * @return array
34
-     */
35
-    protected function getWhereParams(array $keys): array
36
-    {
37
-        return [
38
-            'TKT_ID'      => ['IN', $keys],
39
-            'TKT_deleted' => ['IN', [true, false]]
40
-        ];
41
-    }
31
+	/**
32
+	 * @param array $keys
33
+	 * @return array
34
+	 */
35
+	protected function getWhereParams(array $keys): array
36
+	{
37
+		return [
38
+			'TKT_ID'      => ['IN', $keys],
39
+			'TKT_deleted' => ['IN', [true, false]]
40
+		];
41
+	}
42 42
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/data/loaders/AbstractLoader.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -15,65 +15,65 @@
 block discarded – undo
15 15
  */
16 16
 abstract class AbstractLoader extends AbstractDataLoader
17 17
 {
18
-    protected $primaryKey;
18
+	protected $primaryKey;
19 19
 
20
-    /**
21
-     * @return EEM_Base
22
-     * @throws EE_Error
23
-     * @throws InvalidArgumentException
24
-     * @throws InvalidDataTypeException
25
-     * @throws InvalidInterfaceException
26
-     */
27
-    abstract protected function getQuery(): EEM_Base;
20
+	/**
21
+	 * @return EEM_Base
22
+	 * @throws EE_Error
23
+	 * @throws InvalidArgumentException
24
+	 * @throws InvalidDataTypeException
25
+	 * @throws InvalidInterfaceException
26
+	 */
27
+	abstract protected function getQuery(): EEM_Base;
28 28
 
29
-    /**
30
-     * @param array $keys
31
-     * @return array
32
-     */
33
-    abstract protected function getWhereParams(array $keys): array;
29
+	/**
30
+	 * @param array $keys
31
+	 * @return array
32
+	 */
33
+	abstract protected function getWhereParams(array $keys): array;
34 34
 
35
-    /**
36
-     * Given array of keys, loads and returns a map consisting of keys from `keys` array and loaded
37
-     * values
38
-     *
39
-     * Note that order of returned values must match exactly the order of keys.
40
-     * If some entry is not available for given key - it must include null for the missing key.
41
-     *
42
-     * For example:
43
-     * loadKeys(['a', 'b', 'c']) -> ['a' => 'value1, 'b' => null, 'c' => 'value3']
44
-     *
45
-     * @param array $keys
46
-     *
47
-     * @return array
48
-     * @throws Exception
49
-     */
50
-    public function loadKeys(array $keys): array
51
-    {
52
-        if (empty($keys)) {
53
-            return $keys;
54
-        }
35
+	/**
36
+	 * Given array of keys, loads and returns a map consisting of keys from `keys` array and loaded
37
+	 * values
38
+	 *
39
+	 * Note that order of returned values must match exactly the order of keys.
40
+	 * If some entry is not available for given key - it must include null for the missing key.
41
+	 *
42
+	 * For example:
43
+	 * loadKeys(['a', 'b', 'c']) -> ['a' => 'value1, 'b' => null, 'c' => 'value3']
44
+	 *
45
+	 * @param array $keys
46
+	 *
47
+	 * @return array
48
+	 * @throws Exception
49
+	 */
50
+	public function loadKeys(array $keys): array
51
+	{
52
+		if (empty($keys)) {
53
+			return $keys;
54
+		}
55 55
 
56
-        $args = [
57
-            $this->getWhereParams($keys),
58
-        ];
56
+		$args = [
57
+			$this->getWhereParams($keys),
58
+		];
59 59
 
60
-        $query = $this->getQuery();
61
-        $result = $query->get_all($args);
60
+		$query = $this->getQuery();
61
+		$result = $query->get_all($args);
62 62
 
63
-        $loadedItems = [];
63
+		$loadedItems = [];
64 64
 
65
-        /**
66
-         * Loop over the items and return an array of loaded items,
67
-         * where the key is the ID and the value is the Object passed through
68
-         * the model layer.
69
-         */
70
-        foreach ($keys as $key) {
71
-            if (isset($result[ $key ])) {
72
-                $loadedItems[ $key ] = $result[ $key ];
73
-            } else {
74
-                $loadedItems[ $key ] = null;
75
-            }
76
-        }
77
-        return $loadedItems;
78
-    }
65
+		/**
66
+		 * Loop over the items and return an array of loaded items,
67
+		 * where the key is the ID and the value is the Object passed through
68
+		 * the model layer.
69
+		 */
70
+		foreach ($keys as $key) {
71
+			if (isset($result[ $key ])) {
72
+				$loadedItems[ $key ] = $result[ $key ];
73
+			} else {
74
+				$loadedItems[ $key ] = null;
75
+			}
76
+		}
77
+		return $loadedItems;
78
+	}
79 79
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/data/loaders/PriceLoader.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -15,27 +15,27 @@
 block discarded – undo
15 15
  */
16 16
 class PriceLoader extends AbstractLoader
17 17
 {
18
-    /**
19
-     * @return EEM_Base
20
-     * @throws EE_Error
21
-     * @throws InvalidArgumentException
22
-     * @throws InvalidDataTypeException
23
-     * @throws InvalidInterfaceException
24
-     * @throws ReflectionException
25
-     */
26
-    protected function getQuery(): EEM_Base
27
-    {
28
-        return EEM_Price::instance();
29
-    }
18
+	/**
19
+	 * @return EEM_Base
20
+	 * @throws EE_Error
21
+	 * @throws InvalidArgumentException
22
+	 * @throws InvalidDataTypeException
23
+	 * @throws InvalidInterfaceException
24
+	 * @throws ReflectionException
25
+	 */
26
+	protected function getQuery(): EEM_Base
27
+	{
28
+		return EEM_Price::instance();
29
+	}
30 30
 
31
-    /**
32
-     * @param array $keys
33
-     * @return array
34
-     */
35
-    protected function getWhereParams(array $keys): array
36
-    {
37
-        return [
38
-            'PRC_ID' => ['IN', $keys],
39
-        ];
40
-    }
31
+	/**
32
+	 * @param array $keys
33
+	 * @return array
34
+	 */
35
+	protected function getWhereParams(array $keys): array
36
+	{
37
+		return [
38
+			'PRC_ID' => ['IN', $keys],
39
+		];
40
+	}
41 41
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/data/loaders/VenueLoader.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -15,27 +15,27 @@
 block discarded – undo
15 15
  */
16 16
 class VenueLoader extends AbstractLoader
17 17
 {
18
-    /**
19
-     * @return EEM_Base
20
-     * @throws EE_Error
21
-     * @throws InvalidArgumentException
22
-     * @throws InvalidDataTypeException
23
-     * @throws InvalidInterfaceException
24
-     * @throws ReflectionException
25
-     */
26
-    protected function getQuery(): EEM_Base
27
-    {
28
-        return EEM_Venue::instance();
29
-    }
18
+	/**
19
+	 * @return EEM_Base
20
+	 * @throws EE_Error
21
+	 * @throws InvalidArgumentException
22
+	 * @throws InvalidDataTypeException
23
+	 * @throws InvalidInterfaceException
24
+	 * @throws ReflectionException
25
+	 */
26
+	protected function getQuery(): EEM_Base
27
+	{
28
+		return EEM_Venue::instance();
29
+	}
30 30
 
31
-    /**
32
-     * @param array $keys
33
-     * @return array
34
-     */
35
-    protected function getWhereParams(array $keys): array
36
-    {
37
-        return [
38
-            'VNU_ID' => ['IN', $keys],
39
-        ];
40
-    }
31
+	/**
32
+	 * @param array $keys
33
+	 * @return array
34
+	 */
35
+	protected function getWhereParams(array $keys): array
36
+	{
37
+		return [
38
+			'VNU_ID' => ['IN', $keys],
39
+		];
40
+	}
41 41
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/data/loaders/DatetimeLoader.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -15,28 +15,28 @@
 block discarded – undo
15 15
  */
16 16
 class DatetimeLoader extends AbstractLoader
17 17
 {
18
-    /**
19
-     * @return EEM_Base
20
-     * @throws EE_Error
21
-     * @throws InvalidArgumentException
22
-     * @throws InvalidDataTypeException
23
-     * @throws InvalidInterfaceException
24
-     * @throws ReflectionException
25
-     */
26
-    protected function getQuery(): EEM_Base
27
-    {
28
-        return EEM_Datetime::instance();
29
-    }
18
+	/**
19
+	 * @return EEM_Base
20
+	 * @throws EE_Error
21
+	 * @throws InvalidArgumentException
22
+	 * @throws InvalidDataTypeException
23
+	 * @throws InvalidInterfaceException
24
+	 * @throws ReflectionException
25
+	 */
26
+	protected function getQuery(): EEM_Base
27
+	{
28
+		return EEM_Datetime::instance();
29
+	}
30 30
 
31
-    /**
32
-     * @param array $keys
33
-     * @return array
34
-     */
35
-    protected function getWhereParams(array $keys): array
36
-    {
37
-        return [
38
-            'DTT_ID'      => ['IN', $keys],
39
-            'DTT_deleted' => ['IN', [true, false]]
40
-        ];
41
-    }
31
+	/**
32
+	 * @param array $keys
33
+	 * @return array
34
+	 */
35
+	protected function getWhereParams(array $keys): array
36
+	{
37
+		return [
38
+			'DTT_ID'      => ['IN', $keys],
39
+			'DTT_deleted' => ['IN', [true, false]]
40
+		];
41
+	}
42 42
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/data/domains/EspressoEditor.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -17,25 +17,25 @@
 block discarded – undo
17 17
 class EspressoEditor implements GQLDataDomainInterface
18 18
 {
19 19
 
20
-    /**
21
-     * @param array      $loaders The loaders accessible in the AppContext
22
-     * @param AppContext $context The AppContext
23
-     * @return array
24
-     * @return array
25
-     */
26
-    public function registerLoaders(array $loaders, AppContext $context): array
27
-    {
28
-        $newLoaders = [
29
-            'espresso_attendee'    => new Loaders\AttendeeLoader($context),
30
-            'espresso_datetime'    => new Loaders\DatetimeLoader($context),
31
-            'espresso_price'       => new Loaders\PriceLoader($context),
32
-            'espresso_priceType'   => new Loaders\PriceTypeLoader($context),
33
-            'espresso_formSection' => new Loaders\FormSectionLoader($context),
34
-            'espresso_formElement' => new Loaders\FormElementLoader($context),
35
-            'espresso_ticket'      => new Loaders\TicketLoader($context),
36
-            'espresso_venue'       => new Loaders\VenueLoader($context),
37
-        ];
20
+	/**
21
+	 * @param array      $loaders The loaders accessible in the AppContext
22
+	 * @param AppContext $context The AppContext
23
+	 * @return array
24
+	 * @return array
25
+	 */
26
+	public function registerLoaders(array $loaders, AppContext $context): array
27
+	{
28
+		$newLoaders = [
29
+			'espresso_attendee'    => new Loaders\AttendeeLoader($context),
30
+			'espresso_datetime'    => new Loaders\DatetimeLoader($context),
31
+			'espresso_price'       => new Loaders\PriceLoader($context),
32
+			'espresso_priceType'   => new Loaders\PriceTypeLoader($context),
33
+			'espresso_formSection' => new Loaders\FormSectionLoader($context),
34
+			'espresso_formElement' => new Loaders\FormElementLoader($context),
35
+			'espresso_ticket'      => new Loaders\TicketLoader($context),
36
+			'espresso_venue'       => new Loaders\VenueLoader($context),
37
+		];
38 38
 
39
-        return array_merge($loaders, $newLoaders);
40
-    }
39
+		return array_merge($loaders, $newLoaders);
40
+	}
41 41
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/data/mutations/TicketMutation.php 1 patch
Indentation   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -23,195 +23,195 @@
 block discarded – undo
23 23
 class TicketMutation
24 24
 {
25 25
 
26
-    /**
27
-     * Maps the GraphQL input to a format that the model functions can use
28
-     *
29
-     * @param array $input Data coming from the GraphQL mutation query input
30
-     * @return array
31
-     * @throws Exception
32
-     */
33
-    public static function prepareFields(array $input): array
34
-    {
35
-        $args = [];
36
-
37
-        if (! empty($input['datetimes'])) {
38
-            $args['datetimes'] = array_map('sanitize_text_field', (array) $input['datetimes']);
39
-        }
40
-
41
-        if (isset($input['description'])) {
42
-            $args['TKT_description'] = wp_kses_post($input['description']);
43
-        }
44
-
45
-        if (! empty($input['endDate'])) {
46
-            $args['TKT_end_date'] = new DateTime(sanitize_text_field($input['endDate']));
47
-        }
48
-
49
-        if (array_key_exists('isDefault', $input)) {
50
-            $args['TKT_is_default'] = (bool) $input['isDefault'];
51
-        }
52
-
53
-        if (array_key_exists('isRequired', $input)) {
54
-            $args['TKT_required'] = (bool) $input['isRequired'];
55
-        }
56
-
57
-        if (array_key_exists('isTaxable', $input)) {
58
-            $args['TKT_taxable'] = (bool) $input['isTaxable'];
59
-        }
60
-
61
-        if (array_key_exists('isTrashed', $input)) {
62
-            $args['TKT_deleted'] = (bool) $input['isTrashed'];
63
-        }
64
-
65
-        if (array_key_exists('max', $input)) {
66
-            $args['TKT_max'] = (int) $input['max'];
67
-        }
68
-
69
-        if (array_key_exists('min', $input)) {
70
-            $args['TKT_min'] = (int) $input['min'];
71
-        }
72
-
73
-        if (isset($input['name'])) {
74
-            $args['TKT_name'] = sanitize_text_field($input['name']);
75
-        }
76
-
77
-        if (array_key_exists('order', $input)) {
78
-            $args['TKT_order'] = (int) $input['order'];
79
-        }
80
-
81
-        if (! empty($input['parent'])) {
82
-            $parts = Relay::fromGlobalId(sanitize_text_field($input['parent']));
83
-            $args['TKT_parent'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null;
84
-        }
85
-
86
-        // price can be 0
87
-        if (array_key_exists('price', $input)) {
88
-            $args['TKT_price'] = (float) $input['price'];
89
-        }
90
-
91
-        // prices can be an empty array when all prices are deleted
92
-        if (array_key_exists('prices', $input) && is_array($input['prices'])) {
93
-            $args['prices'] = array_map('sanitize_text_field', $input['prices']);
94
-        }
95
-
96
-        if (array_key_exists('quantity', $input)) {
97
-            $args['TKT_qty'] = (int) $input['quantity'];
98
-        }
99
-
100
-        if (array_key_exists('reserved', $input)) {
101
-            $args['TKT_reserved'] = (int) $input['reserved'];
102
-        }
103
-
104
-        if (array_key_exists('reverseCalculate', $input)) {
105
-            $args['TKT_reverse_calculate'] = (bool) $input['reverseCalculate'];
106
-        }
107
-
108
-        if (array_key_exists('row', $input)) {
109
-            $args['TKT_row'] = (int) $input['row'];
110
-        }
111
-
112
-        if (array_key_exists('sold', $input)) {
113
-            $args['TKT_sold'] = (int) $input['sold'];
114
-        }
115
-
116
-        if (! empty($input['startDate'])) {
117
-            $args['TKT_start_date'] = new DateTime(sanitize_text_field($input['startDate']));
118
-        }
119
-
120
-        if (array_key_exists('uses', $input)) {
121
-            $args['TKT_uses'] = (int) $input['uses'];
122
-        }
123
-
124
-        if (! empty($input['wpUser'])) {
125
-            $parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser']));
126
-            $args['TKT_wp_user'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null;
127
-        }
128
-
129
-        if (array_key_exists('visibility', $input)) {
130
-            $args['TKT_visibility'] = (int) $input['visibility'];
131
-        }
132
-
133
-        return apply_filters(
134
-            'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__ticket_args',
135
-            $args,
136
-            $input
137
-        );
138
-    }
139
-
140
-
141
-    /**
142
-     * Sets the related datetimes for the given ticket.
143
-     *
144
-     * @param EE_Ticket $entity    The Ticket instance.
145
-     * @param array     $datetimes Array of datetime IDs to relate.
146
-     * @throws EE_Error
147
-     * @throws InvalidArgumentException
148
-     * @throws InvalidDataTypeException
149
-     * @throws InvalidInterfaceException
150
-     * @throws ReflectionException
151
-     */
152
-    public static function setRelatedDatetimes(EE_Ticket $entity, array $datetimes)
153
-    {
154
-        $relationName = 'Datetime';
155
-        // Remove all the existing related datetimes
156
-
157
-        $entity->_remove_relations($relationName);
158
-        // @todo replace loop with single query
159
-        foreach ($datetimes as $ID) {
160
-            $parts = Relay::fromGlobalId($ID);
161
-            if (! empty($parts['id']) && absint($parts['id'])) {
162
-                $entity->_add_relation_to(
163
-                    $parts['id'],
164
-                    $relationName
165
-                );
166
-            }
167
-        }
168
-    }
169
-
170
-
171
-    /**
172
-     * Sets the related prices for the given ticket.
173
-     *
174
-     * @param EE_Ticket $entity The Ticket instance.
175
-     * @param array     $prices Array of entity IDs to relate.
176
-     * @throws EE_Error
177
-     * @throws InvalidArgumentException
178
-     * @throws InvalidDataTypeException
179
-     * @throws InvalidInterfaceException
180
-     * @throws ReflectionException
181
-     */
182
-    public static function setRelatedPrices(EE_Ticket $entity, array $prices)
183
-    {
184
-        $relationName = 'Price';
185
-        // Remove all the existing related entities
186
-        $entity->_remove_relations($relationName);
187
-
188
-        // @todo replace loop with single query
189
-        foreach ($prices as $ID) {
190
-            $parts = Relay::fromGlobalId($ID);
191
-            if (! empty($parts['id']) && absint($parts['id'])) {
192
-                $entity->_add_relation_to(
193
-                    $parts['id'],
194
-                    $relationName
195
-                );
196
-            }
197
-        }
198
-    }
199
-
200
-
201
-    /**
202
-     * @param EE_Ticket  $ticket_entity
203
-     * @throws EE_Error
204
-     * @throws InvalidArgumentException
205
-     * @throws InvalidDataTypeException
206
-     * @throws InvalidInterfaceException
207
-     * @throws ReflectionException
208
-     */
209
-    public static function addDefaultPrices(EE_Ticket $ticket_entity)
210
-    {
211
-        /** @var DefaultPrices $default_prices */
212
-        $default_prices = LoaderFactory::getLoader()->getShared(
213
-            'EventEspresso\core\domain\services\admin\entities\DefaultPrices'
214
-        );
215
-        $default_prices->create($ticket_entity);
216
-    }
26
+	/**
27
+	 * Maps the GraphQL input to a format that the model functions can use
28
+	 *
29
+	 * @param array $input Data coming from the GraphQL mutation query input
30
+	 * @return array
31
+	 * @throws Exception
32
+	 */
33
+	public static function prepareFields(array $input): array
34
+	{
35
+		$args = [];
36
+
37
+		if (! empty($input['datetimes'])) {
38
+			$args['datetimes'] = array_map('sanitize_text_field', (array) $input['datetimes']);
39
+		}
40
+
41
+		if (isset($input['description'])) {
42
+			$args['TKT_description'] = wp_kses_post($input['description']);
43
+		}
44
+
45
+		if (! empty($input['endDate'])) {
46
+			$args['TKT_end_date'] = new DateTime(sanitize_text_field($input['endDate']));
47
+		}
48
+
49
+		if (array_key_exists('isDefault', $input)) {
50
+			$args['TKT_is_default'] = (bool) $input['isDefault'];
51
+		}
52
+
53
+		if (array_key_exists('isRequired', $input)) {
54
+			$args['TKT_required'] = (bool) $input['isRequired'];
55
+		}
56
+
57
+		if (array_key_exists('isTaxable', $input)) {
58
+			$args['TKT_taxable'] = (bool) $input['isTaxable'];
59
+		}
60
+
61
+		if (array_key_exists('isTrashed', $input)) {
62
+			$args['TKT_deleted'] = (bool) $input['isTrashed'];
63
+		}
64
+
65
+		if (array_key_exists('max', $input)) {
66
+			$args['TKT_max'] = (int) $input['max'];
67
+		}
68
+
69
+		if (array_key_exists('min', $input)) {
70
+			$args['TKT_min'] = (int) $input['min'];
71
+		}
72
+
73
+		if (isset($input['name'])) {
74
+			$args['TKT_name'] = sanitize_text_field($input['name']);
75
+		}
76
+
77
+		if (array_key_exists('order', $input)) {
78
+			$args['TKT_order'] = (int) $input['order'];
79
+		}
80
+
81
+		if (! empty($input['parent'])) {
82
+			$parts = Relay::fromGlobalId(sanitize_text_field($input['parent']));
83
+			$args['TKT_parent'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null;
84
+		}
85
+
86
+		// price can be 0
87
+		if (array_key_exists('price', $input)) {
88
+			$args['TKT_price'] = (float) $input['price'];
89
+		}
90
+
91
+		// prices can be an empty array when all prices are deleted
92
+		if (array_key_exists('prices', $input) && is_array($input['prices'])) {
93
+			$args['prices'] = array_map('sanitize_text_field', $input['prices']);
94
+		}
95
+
96
+		if (array_key_exists('quantity', $input)) {
97
+			$args['TKT_qty'] = (int) $input['quantity'];
98
+		}
99
+
100
+		if (array_key_exists('reserved', $input)) {
101
+			$args['TKT_reserved'] = (int) $input['reserved'];
102
+		}
103
+
104
+		if (array_key_exists('reverseCalculate', $input)) {
105
+			$args['TKT_reverse_calculate'] = (bool) $input['reverseCalculate'];
106
+		}
107
+
108
+		if (array_key_exists('row', $input)) {
109
+			$args['TKT_row'] = (int) $input['row'];
110
+		}
111
+
112
+		if (array_key_exists('sold', $input)) {
113
+			$args['TKT_sold'] = (int) $input['sold'];
114
+		}
115
+
116
+		if (! empty($input['startDate'])) {
117
+			$args['TKT_start_date'] = new DateTime(sanitize_text_field($input['startDate']));
118
+		}
119
+
120
+		if (array_key_exists('uses', $input)) {
121
+			$args['TKT_uses'] = (int) $input['uses'];
122
+		}
123
+
124
+		if (! empty($input['wpUser'])) {
125
+			$parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser']));
126
+			$args['TKT_wp_user'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null;
127
+		}
128
+
129
+		if (array_key_exists('visibility', $input)) {
130
+			$args['TKT_visibility'] = (int) $input['visibility'];
131
+		}
132
+
133
+		return apply_filters(
134
+			'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__ticket_args',
135
+			$args,
136
+			$input
137
+		);
138
+	}
139
+
140
+
141
+	/**
142
+	 * Sets the related datetimes for the given ticket.
143
+	 *
144
+	 * @param EE_Ticket $entity    The Ticket instance.
145
+	 * @param array     $datetimes Array of datetime IDs to relate.
146
+	 * @throws EE_Error
147
+	 * @throws InvalidArgumentException
148
+	 * @throws InvalidDataTypeException
149
+	 * @throws InvalidInterfaceException
150
+	 * @throws ReflectionException
151
+	 */
152
+	public static function setRelatedDatetimes(EE_Ticket $entity, array $datetimes)
153
+	{
154
+		$relationName = 'Datetime';
155
+		// Remove all the existing related datetimes
156
+
157
+		$entity->_remove_relations($relationName);
158
+		// @todo replace loop with single query
159
+		foreach ($datetimes as $ID) {
160
+			$parts = Relay::fromGlobalId($ID);
161
+			if (! empty($parts['id']) && absint($parts['id'])) {
162
+				$entity->_add_relation_to(
163
+					$parts['id'],
164
+					$relationName
165
+				);
166
+			}
167
+		}
168
+	}
169
+
170
+
171
+	/**
172
+	 * Sets the related prices for the given ticket.
173
+	 *
174
+	 * @param EE_Ticket $entity The Ticket instance.
175
+	 * @param array     $prices Array of entity IDs to relate.
176
+	 * @throws EE_Error
177
+	 * @throws InvalidArgumentException
178
+	 * @throws InvalidDataTypeException
179
+	 * @throws InvalidInterfaceException
180
+	 * @throws ReflectionException
181
+	 */
182
+	public static function setRelatedPrices(EE_Ticket $entity, array $prices)
183
+	{
184
+		$relationName = 'Price';
185
+		// Remove all the existing related entities
186
+		$entity->_remove_relations($relationName);
187
+
188
+		// @todo replace loop with single query
189
+		foreach ($prices as $ID) {
190
+			$parts = Relay::fromGlobalId($ID);
191
+			if (! empty($parts['id']) && absint($parts['id'])) {
192
+				$entity->_add_relation_to(
193
+					$parts['id'],
194
+					$relationName
195
+				);
196
+			}
197
+		}
198
+	}
199
+
200
+
201
+	/**
202
+	 * @param EE_Ticket  $ticket_entity
203
+	 * @throws EE_Error
204
+	 * @throws InvalidArgumentException
205
+	 * @throws InvalidDataTypeException
206
+	 * @throws InvalidInterfaceException
207
+	 * @throws ReflectionException
208
+	 */
209
+	public static function addDefaultPrices(EE_Ticket $ticket_entity)
210
+	{
211
+		/** @var DefaultPrices $default_prices */
212
+		$default_prices = LoaderFactory::getLoader()->getShared(
213
+			'EventEspresso\core\domain\services\admin\entities\DefaultPrices'
214
+		);
215
+		$default_prices->create($ticket_entity);
216
+	}
217 217
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/data/mutations/VenueMutation.php 2 patches
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -14,101 +14,101 @@
 block discarded – undo
14 14
 class VenueMutation
15 15
 {
16 16
 
17
-    /**
18
-     * Maps the GraphQL input to a format that the model functions can use
19
-     *
20
-     * @param array  $input         Data coming from the GraphQL mutation query input
21
-     * @return array
22
-     * @throws Exception
23
-     */
24
-    public static function prepareFields(array $input): array
25
-    {
26
-        $args = [];
27
-
28
-        if (! empty($input['name'])) {
29
-            $args['VNU_name'] = sanitize_text_field($input['name']);
30
-        }
31
-
32
-        if (! empty($input['description'])) {
33
-            $args['VNU_desc'] = wp_kses_post($input['description']);
34
-        }
35
-
36
-        if (! empty($input['shortDescription'])) {
37
-            $args['VNU_short_desc'] = sanitize_text_field($input['shortDescription']);
38
-        }
39
-
40
-        if (! empty($input['identifier'])) {
41
-            $args['VNU_identifier'] = sanitize_title($input['identifier']);
42
-        }
43
-
44
-        if (! empty($input['created'])) {
45
-            $args['VNU_created'] = new DateTime(sanitize_text_field($input['created']));
46
-        }
47
-
48
-        if (! empty($input['order'])) {
49
-            $args['VNU_order'] = absint($input['order']);
50
-        }
51
-
52
-        if (! empty($input['wpUser'])) {
53
-            $args['VNU_wp_user'] = absint($input['wpUser']);
54
-        }
55
-
56
-        if (! empty($input['address'])) {
57
-            $args['VNU_address'] = sanitize_text_field($input['address']);
58
-        }
59
-
60
-        if (! empty($input['address2'])) {
61
-            $args['VNU_address2'] = sanitize_text_field($input['address2']);
62
-        }
63
-
64
-        if (! empty($input['city'])) {
65
-            $args['VNU_city'] = sanitize_text_field($input['city']);
66
-        }
67
-
68
-        if (! empty($input['state'])) {
69
-            $args['STA_ID'] = absint($input['state']);
70
-        }
71
-
72
-        if (! empty($input['country'])) {
73
-            $args['CNT_ISO'] = sanitize_text_field($input['country']);
74
-        }
75
-
76
-        if (! empty($input['zip'])) {
77
-            $args['VNU_zip'] = sanitize_text_field($input['zip']);
78
-        }
79
-
80
-        if (! empty($input['capacity'])) {
81
-            $args['VNU_capacity'] = absint($input['capacity']);
82
-        }
83
-
84
-        if (! empty($input['phone'])) {
85
-            $args['VNU_phone'] = sanitize_text_field($input['phone']);
86
-        }
87
-
88
-        if (! empty($input['virtualPhone'])) {
89
-            $args['VNU_virtual_phone'] = sanitize_text_field($input['virtualPhone']);
90
-        }
91
-
92
-        if (! empty($input['url'])) {
93
-            $args['VNU_url'] = sanitize_text_field($input['url']);
94
-        }
95
-
96
-        if (! empty($input['virtualUrl'])) {
97
-            $args['VNU_virtual_url'] = sanitize_text_field($input['virtualUrl']);
98
-        }
99
-
100
-        if (! empty($input['googleMapLink'])) {
101
-            $args['VNU_google_map_link'] = sanitize_text_field($input['googleMapLink']);
102
-        }
103
-
104
-        if (! empty($input['enableForGmap'])) {
105
-            $args['VNU_enable_for_gmap'] = (bool) $input['enableForGmap'];
106
-        }
107
-
108
-        return apply_filters(
109
-            'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__venue_args',
110
-            $args,
111
-            $input
112
-        );
113
-    }
17
+	/**
18
+	 * Maps the GraphQL input to a format that the model functions can use
19
+	 *
20
+	 * @param array  $input         Data coming from the GraphQL mutation query input
21
+	 * @return array
22
+	 * @throws Exception
23
+	 */
24
+	public static function prepareFields(array $input): array
25
+	{
26
+		$args = [];
27
+
28
+		if (! empty($input['name'])) {
29
+			$args['VNU_name'] = sanitize_text_field($input['name']);
30
+		}
31
+
32
+		if (! empty($input['description'])) {
33
+			$args['VNU_desc'] = wp_kses_post($input['description']);
34
+		}
35
+
36
+		if (! empty($input['shortDescription'])) {
37
+			$args['VNU_short_desc'] = sanitize_text_field($input['shortDescription']);
38
+		}
39
+
40
+		if (! empty($input['identifier'])) {
41
+			$args['VNU_identifier'] = sanitize_title($input['identifier']);
42
+		}
43
+
44
+		if (! empty($input['created'])) {
45
+			$args['VNU_created'] = new DateTime(sanitize_text_field($input['created']));
46
+		}
47
+
48
+		if (! empty($input['order'])) {
49
+			$args['VNU_order'] = absint($input['order']);
50
+		}
51
+
52
+		if (! empty($input['wpUser'])) {
53
+			$args['VNU_wp_user'] = absint($input['wpUser']);
54
+		}
55
+
56
+		if (! empty($input['address'])) {
57
+			$args['VNU_address'] = sanitize_text_field($input['address']);
58
+		}
59
+
60
+		if (! empty($input['address2'])) {
61
+			$args['VNU_address2'] = sanitize_text_field($input['address2']);
62
+		}
63
+
64
+		if (! empty($input['city'])) {
65
+			$args['VNU_city'] = sanitize_text_field($input['city']);
66
+		}
67
+
68
+		if (! empty($input['state'])) {
69
+			$args['STA_ID'] = absint($input['state']);
70
+		}
71
+
72
+		if (! empty($input['country'])) {
73
+			$args['CNT_ISO'] = sanitize_text_field($input['country']);
74
+		}
75
+
76
+		if (! empty($input['zip'])) {
77
+			$args['VNU_zip'] = sanitize_text_field($input['zip']);
78
+		}
79
+
80
+		if (! empty($input['capacity'])) {
81
+			$args['VNU_capacity'] = absint($input['capacity']);
82
+		}
83
+
84
+		if (! empty($input['phone'])) {
85
+			$args['VNU_phone'] = sanitize_text_field($input['phone']);
86
+		}
87
+
88
+		if (! empty($input['virtualPhone'])) {
89
+			$args['VNU_virtual_phone'] = sanitize_text_field($input['virtualPhone']);
90
+		}
91
+
92
+		if (! empty($input['url'])) {
93
+			$args['VNU_url'] = sanitize_text_field($input['url']);
94
+		}
95
+
96
+		if (! empty($input['virtualUrl'])) {
97
+			$args['VNU_virtual_url'] = sanitize_text_field($input['virtualUrl']);
98
+		}
99
+
100
+		if (! empty($input['googleMapLink'])) {
101
+			$args['VNU_google_map_link'] = sanitize_text_field($input['googleMapLink']);
102
+		}
103
+
104
+		if (! empty($input['enableForGmap'])) {
105
+			$args['VNU_enable_for_gmap'] = (bool) $input['enableForGmap'];
106
+		}
107
+
108
+		return apply_filters(
109
+			'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__venue_args',
110
+			$args,
111
+			$input
112
+		);
113
+	}
114 114
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -25,83 +25,83 @@
 block discarded – undo
25 25
     {
26 26
         $args = [];
27 27
 
28
-        if (! empty($input['name'])) {
28
+        if ( ! empty($input['name'])) {
29 29
             $args['VNU_name'] = sanitize_text_field($input['name']);
30 30
         }
31 31
 
32
-        if (! empty($input['description'])) {
32
+        if ( ! empty($input['description'])) {
33 33
             $args['VNU_desc'] = wp_kses_post($input['description']);
34 34
         }
35 35
 
36
-        if (! empty($input['shortDescription'])) {
36
+        if ( ! empty($input['shortDescription'])) {
37 37
             $args['VNU_short_desc'] = sanitize_text_field($input['shortDescription']);
38 38
         }
39 39
 
40
-        if (! empty($input['identifier'])) {
40
+        if ( ! empty($input['identifier'])) {
41 41
             $args['VNU_identifier'] = sanitize_title($input['identifier']);
42 42
         }
43 43
 
44
-        if (! empty($input['created'])) {
44
+        if ( ! empty($input['created'])) {
45 45
             $args['VNU_created'] = new DateTime(sanitize_text_field($input['created']));
46 46
         }
47 47
 
48
-        if (! empty($input['order'])) {
48
+        if ( ! empty($input['order'])) {
49 49
             $args['VNU_order'] = absint($input['order']);
50 50
         }
51 51
 
52
-        if (! empty($input['wpUser'])) {
52
+        if ( ! empty($input['wpUser'])) {
53 53
             $args['VNU_wp_user'] = absint($input['wpUser']);
54 54
         }
55 55
 
56
-        if (! empty($input['address'])) {
56
+        if ( ! empty($input['address'])) {
57 57
             $args['VNU_address'] = sanitize_text_field($input['address']);
58 58
         }
59 59
 
60
-        if (! empty($input['address2'])) {
60
+        if ( ! empty($input['address2'])) {
61 61
             $args['VNU_address2'] = sanitize_text_field($input['address2']);
62 62
         }
63 63
 
64
-        if (! empty($input['city'])) {
64
+        if ( ! empty($input['city'])) {
65 65
             $args['VNU_city'] = sanitize_text_field($input['city']);
66 66
         }
67 67
 
68
-        if (! empty($input['state'])) {
68
+        if ( ! empty($input['state'])) {
69 69
             $args['STA_ID'] = absint($input['state']);
70 70
         }
71 71
 
72
-        if (! empty($input['country'])) {
72
+        if ( ! empty($input['country'])) {
73 73
             $args['CNT_ISO'] = sanitize_text_field($input['country']);
74 74
         }
75 75
 
76
-        if (! empty($input['zip'])) {
76
+        if ( ! empty($input['zip'])) {
77 77
             $args['VNU_zip'] = sanitize_text_field($input['zip']);
78 78
         }
79 79
 
80
-        if (! empty($input['capacity'])) {
80
+        if ( ! empty($input['capacity'])) {
81 81
             $args['VNU_capacity'] = absint($input['capacity']);
82 82
         }
83 83
 
84
-        if (! empty($input['phone'])) {
84
+        if ( ! empty($input['phone'])) {
85 85
             $args['VNU_phone'] = sanitize_text_field($input['phone']);
86 86
         }
87 87
 
88
-        if (! empty($input['virtualPhone'])) {
88
+        if ( ! empty($input['virtualPhone'])) {
89 89
             $args['VNU_virtual_phone'] = sanitize_text_field($input['virtualPhone']);
90 90
         }
91 91
 
92
-        if (! empty($input['url'])) {
92
+        if ( ! empty($input['url'])) {
93 93
             $args['VNU_url'] = sanitize_text_field($input['url']);
94 94
         }
95 95
 
96
-        if (! empty($input['virtualUrl'])) {
96
+        if ( ! empty($input['virtualUrl'])) {
97 97
             $args['VNU_virtual_url'] = sanitize_text_field($input['virtualUrl']);
98 98
         }
99 99
 
100
-        if (! empty($input['googleMapLink'])) {
100
+        if ( ! empty($input['googleMapLink'])) {
101 101
             $args['VNU_google_map_link'] = sanitize_text_field($input['googleMapLink']);
102 102
         }
103 103
 
104
-        if (! empty($input['enableForGmap'])) {
104
+        if ( ! empty($input['enableForGmap'])) {
105 105
             $args['VNU_enable_for_gmap'] = (bool) $input['enableForGmap'];
106 106
         }
107 107
 
Please login to merge, or discard this patch.