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