@@ -14,79 +14,79 @@ |
||
| 14 | 14 | class EventMutation |
| 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 | - * @param string $mutation_name Name of the mutation being performed |
|
| 22 | - * @return array |
|
| 23 | - * @throws Exception |
|
| 24 | - */ |
|
| 25 | - public static function prepareFields(array $input, $mutation_name) |
|
| 26 | - { |
|
| 27 | - |
|
| 28 | - $args = []; |
|
| 29 | - |
|
| 30 | - if (! empty($input['additionalLimit'])) { |
|
| 31 | - $args['EVT_additional_limit'] = absint($input['additionalLimit']); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - if (array_key_exists('allowOverflow', $input)) { |
|
| 35 | - $args['EVT_allow_overflow'] = (bool) ($input['allowOverflow']); |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - if (! empty($input['desc'])) { |
|
| 39 | - $args['EVT_desc'] = sanitize_post_field('post_content', $input['desc'], null, $context = 'db'); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - if (array_key_exists('displayDesc', $input)) { |
|
| 43 | - $args['EVT_display_desc'] = (bool) ($input['displayDesc']); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - if (array_key_exists('displayTicketSelector', $input)) { |
|
| 47 | - $args['EVT_display_ticket_selector'] = (bool) ($input['displayTicketSelector']); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - if (array_key_exists('donations', $input)) { |
|
| 51 | - $args['EVT_donations'] = (bool) ($input['donations']); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - if (! empty($input['externalUrl'])) { |
|
| 55 | - $args['EVT_external_URL'] = sanitize_text_field($input['externalUrl']); |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - if (array_key_exists('memberOnly', $input)) { |
|
| 59 | - $args['EVT_member_only'] = (bool) ($input['memberOnly']); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - if (! empty($input['name'])) { |
|
| 63 | - $args['EVT_name'] = sanitize_text_field($input['name']); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - if (! empty($input['order'])) { |
|
| 67 | - $args['EVT_order'] = absint($input['order']); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - if (! empty($input['phone'])) { |
|
| 71 | - $args['EVT_phone'] = sanitize_text_field($input['phone']); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - if (! empty($input['shortDesc'])) { |
|
| 75 | - $args['EVT_short_desc'] = sanitize_post_field('post_excerpt', $input['shortDesc'], null, $context = 'db'); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - if (! empty($input['timezoneString'])) { |
|
| 79 | - $args['EVT_timezone_string'] = sanitize_text_field($input['timezoneString']); |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - if (! empty($input['visibleOn'])) { |
|
| 83 | - $args['EVT_visible_on'] = new DateTime(sanitize_text_field($input['visibleOn'])); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - if (! empty($input['wpUser'])) { |
|
| 87 | - $args['EVT_wp_user'] = absint($input['wpUser']); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - return $args; |
|
| 91 | - } |
|
| 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 | + * @param string $mutation_name Name of the mutation being performed |
|
| 22 | + * @return array |
|
| 23 | + * @throws Exception |
|
| 24 | + */ |
|
| 25 | + public static function prepareFields(array $input, $mutation_name) |
|
| 26 | + { |
|
| 27 | + |
|
| 28 | + $args = []; |
|
| 29 | + |
|
| 30 | + if (! empty($input['additionalLimit'])) { |
|
| 31 | + $args['EVT_additional_limit'] = absint($input['additionalLimit']); |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + if (array_key_exists('allowOverflow', $input)) { |
|
| 35 | + $args['EVT_allow_overflow'] = (bool) ($input['allowOverflow']); |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + if (! empty($input['desc'])) { |
|
| 39 | + $args['EVT_desc'] = sanitize_post_field('post_content', $input['desc'], null, $context = 'db'); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + if (array_key_exists('displayDesc', $input)) { |
|
| 43 | + $args['EVT_display_desc'] = (bool) ($input['displayDesc']); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + if (array_key_exists('displayTicketSelector', $input)) { |
|
| 47 | + $args['EVT_display_ticket_selector'] = (bool) ($input['displayTicketSelector']); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + if (array_key_exists('donations', $input)) { |
|
| 51 | + $args['EVT_donations'] = (bool) ($input['donations']); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + if (! empty($input['externalUrl'])) { |
|
| 55 | + $args['EVT_external_URL'] = sanitize_text_field($input['externalUrl']); |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + if (array_key_exists('memberOnly', $input)) { |
|
| 59 | + $args['EVT_member_only'] = (bool) ($input['memberOnly']); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + if (! empty($input['name'])) { |
|
| 63 | + $args['EVT_name'] = sanitize_text_field($input['name']); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + if (! empty($input['order'])) { |
|
| 67 | + $args['EVT_order'] = absint($input['order']); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + if (! empty($input['phone'])) { |
|
| 71 | + $args['EVT_phone'] = sanitize_text_field($input['phone']); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + if (! empty($input['shortDesc'])) { |
|
| 75 | + $args['EVT_short_desc'] = sanitize_post_field('post_excerpt', $input['shortDesc'], null, $context = 'db'); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + if (! empty($input['timezoneString'])) { |
|
| 79 | + $args['EVT_timezone_string'] = sanitize_text_field($input['timezoneString']); |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + if (! empty($input['visibleOn'])) { |
|
| 83 | + $args['EVT_visible_on'] = new DateTime(sanitize_text_field($input['visibleOn'])); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + if (! empty($input['wpUser'])) { |
|
| 87 | + $args['EVT_wp_user'] = absint($input['wpUser']); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + return $args; |
|
| 91 | + } |
|
| 92 | 92 | } |
@@ -27,137 +27,137 @@ |
||
| 27 | 27 | class TicketMutation |
| 28 | 28 | { |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Maps the GraphQL input to a format that the model functions can use |
|
| 32 | - * |
|
| 33 | - * @param array $input Data coming from the GraphQL mutation query input |
|
| 34 | - * @return array |
|
| 35 | - * @throws Exception |
|
| 36 | - */ |
|
| 37 | - public static function prepareFields(array $input) |
|
| 38 | - { |
|
| 39 | - $args = []; |
|
| 40 | - |
|
| 41 | - if (! empty($input['name'])) { |
|
| 42 | - $args['TKT_name'] = sanitize_text_field($input['name']); |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - if (! empty($input['description'])) { |
|
| 46 | - $args['TKT_description'] = sanitize_text_field($input['description']); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - if (! empty($input['price'])) { |
|
| 50 | - $args['TKT_price'] = (float) $input['price']; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - if (! empty($input['startDate'])) { |
|
| 54 | - $args['TKT_start_date'] = new DateTime(sanitize_text_field($input['startDate'])); |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - if (! empty($input['endDate'])) { |
|
| 58 | - $args['TKT_end_date'] = new DateTime(sanitize_text_field($input['endDate'])); |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - if (! empty($input['datetimes'])) { |
|
| 62 | - $args['datetimes'] = array_map('sanitize_text_field', (array) $input['datetimes']); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - if (! empty($input['prices'])) { |
|
| 66 | - $args['prices'] = array_map('sanitize_text_field', (array) $input['prices']); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - if (array_key_exists('isTrashed', $input)) { |
|
| 70 | - $args['TKT_deleted'] = (bool) $input['isTrashed']; |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - // Likewise the other fields... |
|
| 74 | - |
|
| 75 | - return $args; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * Sets the related datetimes for the given ticket. |
|
| 81 | - * |
|
| 82 | - * @param EE_Ticket $entity The Ticket instance. |
|
| 83 | - * @param array $datetimes Array of datetime IDs to relate. |
|
| 84 | - * @throws EE_Error |
|
| 85 | - * @throws InvalidArgumentException |
|
| 86 | - * @throws InvalidDataTypeException |
|
| 87 | - * @throws InvalidInterfaceException |
|
| 88 | - * @throws ReflectionException |
|
| 89 | - */ |
|
| 90 | - public static function setRelatedDatetimes($entity, array $datetimes) |
|
| 91 | - { |
|
| 92 | - $relationName = 'Datetime'; |
|
| 93 | - // Remove all the existing related datetimes |
|
| 94 | - |
|
| 95 | - $entity->_remove_relations($relationName); |
|
| 96 | - // @todo replace loop with single query |
|
| 97 | - foreach ($datetimes as $ID) { |
|
| 98 | - $parts = Relay::fromGlobalId($ID); |
|
| 99 | - if (! empty($parts['id']) && absint($parts['id'])) { |
|
| 100 | - $entity->_add_relation_to( |
|
| 101 | - $parts['id'], |
|
| 102 | - $relationName |
|
| 103 | - ); |
|
| 104 | - } |
|
| 105 | - } |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * Sets the related prices for the given ticket. |
|
| 111 | - * |
|
| 112 | - * @param EE_Ticket $entity The Ticket instance. |
|
| 113 | - * @param array $prices Array of entity IDs to relate. |
|
| 114 | - * @throws EE_Error |
|
| 115 | - * @throws InvalidArgumentException |
|
| 116 | - * @throws InvalidDataTypeException |
|
| 117 | - * @throws InvalidInterfaceException |
|
| 118 | - * @throws ReflectionException |
|
| 119 | - */ |
|
| 120 | - public static function setRelatedPrices($entity, array $prices) |
|
| 121 | - { |
|
| 122 | - $relationName = 'Price'; |
|
| 123 | - // Remove all the existing related entities |
|
| 124 | - $entity->_remove_relations($relationName); |
|
| 125 | - |
|
| 126 | - // @todo replace loop with single query |
|
| 127 | - foreach ($prices as $ID) { |
|
| 128 | - $parts = Relay::fromGlobalId($ID); |
|
| 129 | - if (! empty($parts['id']) && absint($parts['id'])) { |
|
| 130 | - $entity->_add_relation_to( |
|
| 131 | - $parts['id'], |
|
| 132 | - $relationName |
|
| 133 | - ); |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * @param EE_Ticket $ticket_entity |
|
| 141 | - * @param EEM_Ticket $ticket_model |
|
| 142 | - * @throws DomainException |
|
| 143 | - * @throws EE_Error |
|
| 144 | - * @throws InvalidArgumentException |
|
| 145 | - * @throws InvalidDataTypeException |
|
| 146 | - * @throws InvalidInterfaceException |
|
| 147 | - * @throws ModelConfigurationException |
|
| 148 | - * @throws ReflectionException |
|
| 149 | - * @throws RestException |
|
| 150 | - * @throws UnexpectedEntityException |
|
| 151 | - * @throws EE_Error |
|
| 152 | - * @since $VID:$ |
|
| 153 | - */ |
|
| 154 | - public static function addDefaultPrices(EE_Ticket $ticket_entity, EEM_Ticket $ticket_model) |
|
| 155 | - { |
|
| 156 | - $price_model = EEM_Price::instance(); |
|
| 157 | - $default_prices = $price_model->get_all_default_prices(); |
|
| 158 | - foreach ($default_prices as $default_price) { |
|
| 159 | - $default_price->save(); |
|
| 160 | - $default_price->_add_relation_to($ticket_entity, 'Ticket'); |
|
| 161 | - } |
|
| 162 | - } |
|
| 30 | + /** |
|
| 31 | + * Maps the GraphQL input to a format that the model functions can use |
|
| 32 | + * |
|
| 33 | + * @param array $input Data coming from the GraphQL mutation query input |
|
| 34 | + * @return array |
|
| 35 | + * @throws Exception |
|
| 36 | + */ |
|
| 37 | + public static function prepareFields(array $input) |
|
| 38 | + { |
|
| 39 | + $args = []; |
|
| 40 | + |
|
| 41 | + if (! empty($input['name'])) { |
|
| 42 | + $args['TKT_name'] = sanitize_text_field($input['name']); |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + if (! empty($input['description'])) { |
|
| 46 | + $args['TKT_description'] = sanitize_text_field($input['description']); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + if (! empty($input['price'])) { |
|
| 50 | + $args['TKT_price'] = (float) $input['price']; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + if (! empty($input['startDate'])) { |
|
| 54 | + $args['TKT_start_date'] = new DateTime(sanitize_text_field($input['startDate'])); |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + if (! empty($input['endDate'])) { |
|
| 58 | + $args['TKT_end_date'] = new DateTime(sanitize_text_field($input['endDate'])); |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + if (! empty($input['datetimes'])) { |
|
| 62 | + $args['datetimes'] = array_map('sanitize_text_field', (array) $input['datetimes']); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + if (! empty($input['prices'])) { |
|
| 66 | + $args['prices'] = array_map('sanitize_text_field', (array) $input['prices']); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + if (array_key_exists('isTrashed', $input)) { |
|
| 70 | + $args['TKT_deleted'] = (bool) $input['isTrashed']; |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + // Likewise the other fields... |
|
| 74 | + |
|
| 75 | + return $args; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Sets the related datetimes for the given ticket. |
|
| 81 | + * |
|
| 82 | + * @param EE_Ticket $entity The Ticket instance. |
|
| 83 | + * @param array $datetimes Array of datetime IDs to relate. |
|
| 84 | + * @throws EE_Error |
|
| 85 | + * @throws InvalidArgumentException |
|
| 86 | + * @throws InvalidDataTypeException |
|
| 87 | + * @throws InvalidInterfaceException |
|
| 88 | + * @throws ReflectionException |
|
| 89 | + */ |
|
| 90 | + public static function setRelatedDatetimes($entity, array $datetimes) |
|
| 91 | + { |
|
| 92 | + $relationName = 'Datetime'; |
|
| 93 | + // Remove all the existing related datetimes |
|
| 94 | + |
|
| 95 | + $entity->_remove_relations($relationName); |
|
| 96 | + // @todo replace loop with single query |
|
| 97 | + foreach ($datetimes as $ID) { |
|
| 98 | + $parts = Relay::fromGlobalId($ID); |
|
| 99 | + if (! empty($parts['id']) && absint($parts['id'])) { |
|
| 100 | + $entity->_add_relation_to( |
|
| 101 | + $parts['id'], |
|
| 102 | + $relationName |
|
| 103 | + ); |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * Sets the related prices for the given ticket. |
|
| 111 | + * |
|
| 112 | + * @param EE_Ticket $entity The Ticket instance. |
|
| 113 | + * @param array $prices Array of entity IDs to relate. |
|
| 114 | + * @throws EE_Error |
|
| 115 | + * @throws InvalidArgumentException |
|
| 116 | + * @throws InvalidDataTypeException |
|
| 117 | + * @throws InvalidInterfaceException |
|
| 118 | + * @throws ReflectionException |
|
| 119 | + */ |
|
| 120 | + public static function setRelatedPrices($entity, array $prices) |
|
| 121 | + { |
|
| 122 | + $relationName = 'Price'; |
|
| 123 | + // Remove all the existing related entities |
|
| 124 | + $entity->_remove_relations($relationName); |
|
| 125 | + |
|
| 126 | + // @todo replace loop with single query |
|
| 127 | + foreach ($prices as $ID) { |
|
| 128 | + $parts = Relay::fromGlobalId($ID); |
|
| 129 | + if (! empty($parts['id']) && absint($parts['id'])) { |
|
| 130 | + $entity->_add_relation_to( |
|
| 131 | + $parts['id'], |
|
| 132 | + $relationName |
|
| 133 | + ); |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * @param EE_Ticket $ticket_entity |
|
| 141 | + * @param EEM_Ticket $ticket_model |
|
| 142 | + * @throws DomainException |
|
| 143 | + * @throws EE_Error |
|
| 144 | + * @throws InvalidArgumentException |
|
| 145 | + * @throws InvalidDataTypeException |
|
| 146 | + * @throws InvalidInterfaceException |
|
| 147 | + * @throws ModelConfigurationException |
|
| 148 | + * @throws ReflectionException |
|
| 149 | + * @throws RestException |
|
| 150 | + * @throws UnexpectedEntityException |
|
| 151 | + * @throws EE_Error |
|
| 152 | + * @since $VID:$ |
|
| 153 | + */ |
|
| 154 | + public static function addDefaultPrices(EE_Ticket $ticket_entity, EEM_Ticket $ticket_model) |
|
| 155 | + { |
|
| 156 | + $price_model = EEM_Price::instance(); |
|
| 157 | + $default_prices = $price_model->get_all_default_prices(); |
|
| 158 | + foreach ($default_prices as $default_price) { |
|
| 159 | + $default_price->save(); |
|
| 160 | + $default_price->_add_relation_to($ticket_entity, 'Ticket'); |
|
| 161 | + } |
|
| 162 | + } |
|
| 163 | 163 | } |
@@ -38,31 +38,31 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | $args = []; |
| 40 | 40 | |
| 41 | - if (! empty($input['name'])) { |
|
| 41 | + if ( ! empty($input['name'])) { |
|
| 42 | 42 | $args['TKT_name'] = sanitize_text_field($input['name']); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - if (! empty($input['description'])) { |
|
| 45 | + if ( ! empty($input['description'])) { |
|
| 46 | 46 | $args['TKT_description'] = sanitize_text_field($input['description']); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - if (! empty($input['price'])) { |
|
| 49 | + if ( ! empty($input['price'])) { |
|
| 50 | 50 | $args['TKT_price'] = (float) $input['price']; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - if (! empty($input['startDate'])) { |
|
| 53 | + if ( ! empty($input['startDate'])) { |
|
| 54 | 54 | $args['TKT_start_date'] = new DateTime(sanitize_text_field($input['startDate'])); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - if (! empty($input['endDate'])) { |
|
| 57 | + if ( ! empty($input['endDate'])) { |
|
| 58 | 58 | $args['TKT_end_date'] = new DateTime(sanitize_text_field($input['endDate'])); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - if (! empty($input['datetimes'])) { |
|
| 61 | + if ( ! empty($input['datetimes'])) { |
|
| 62 | 62 | $args['datetimes'] = array_map('sanitize_text_field', (array) $input['datetimes']); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if (! empty($input['prices'])) { |
|
| 65 | + if ( ! empty($input['prices'])) { |
|
| 66 | 66 | $args['prices'] = array_map('sanitize_text_field', (array) $input['prices']); |
| 67 | 67 | } |
| 68 | 68 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | // @todo replace loop with single query |
| 97 | 97 | foreach ($datetimes as $ID) { |
| 98 | 98 | $parts = Relay::fromGlobalId($ID); |
| 99 | - if (! empty($parts['id']) && absint($parts['id'])) { |
|
| 99 | + if ( ! empty($parts['id']) && absint($parts['id'])) { |
|
| 100 | 100 | $entity->_add_relation_to( |
| 101 | 101 | $parts['id'], |
| 102 | 102 | $relationName |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | // @todo replace loop with single query |
| 127 | 127 | foreach ($prices as $ID) { |
| 128 | 128 | $parts = Relay::fromGlobalId($ID); |
| 129 | - if (! empty($parts['id']) && absint($parts['id'])) { |
|
| 129 | + if ( ! empty($parts['id']) && absint($parts['id'])) { |
|
| 130 | 130 | $entity->_add_relation_to( |
| 131 | 131 | $parts['id'], |
| 132 | 132 | $relationName |
@@ -13,54 +13,54 @@ |
||
| 13 | 13 | class PriceMutation |
| 14 | 14 | { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * Maps the GraphQL input to a format that the model functions can use |
|
| 18 | - * |
|
| 19 | - * @param array $input Data coming from the GraphQL mutation query input |
|
| 20 | - * @return array |
|
| 21 | - */ |
|
| 22 | - public static function prepareFields(array $input) |
|
| 23 | - { |
|
| 24 | - $args = []; |
|
| 16 | + /** |
|
| 17 | + * Maps the GraphQL input to a format that the model functions can use |
|
| 18 | + * |
|
| 19 | + * @param array $input Data coming from the GraphQL mutation query input |
|
| 20 | + * @return array |
|
| 21 | + */ |
|
| 22 | + public static function prepareFields(array $input) |
|
| 23 | + { |
|
| 24 | + $args = []; |
|
| 25 | 25 | |
| 26 | - if (! empty($input['priceType'])) { |
|
| 27 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['priceType'])); |
|
| 28 | - $args['PRT_ID'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
|
| 29 | - } |
|
| 26 | + if (! empty($input['priceType'])) { |
|
| 27 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['priceType'])); |
|
| 28 | + $args['PRT_ID'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - if (! empty($input['name'])) { |
|
| 32 | - $args['PRC_name'] = sanitize_text_field($input['name']); |
|
| 33 | - } |
|
| 31 | + if (! empty($input['name'])) { |
|
| 32 | + $args['PRC_name'] = sanitize_text_field($input['name']); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - if (! empty($input['desc'])) { |
|
| 36 | - $args['PRC_desc'] = sanitize_text_field($input['desc']); |
|
| 37 | - } |
|
| 35 | + if (! empty($input['desc'])) { |
|
| 36 | + $args['PRC_desc'] = sanitize_text_field($input['desc']); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - if (! empty($input['amount'])) { |
|
| 40 | - $args['PRC_amount'] = (float) $input['amount']; |
|
| 41 | - } |
|
| 39 | + if (! empty($input['amount'])) { |
|
| 40 | + $args['PRC_amount'] = (float) $input['amount']; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - if (array_key_exists('isDefault', $input)) { |
|
| 44 | - $args['PRC_is_default'] = (bool) $input['isDefault']; |
|
| 45 | - } |
|
| 43 | + if (array_key_exists('isDefault', $input)) { |
|
| 44 | + $args['PRC_is_default'] = (bool) $input['isDefault']; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - if (array_key_exists('isTrashed', $input)) { |
|
| 48 | - $args['PRC_deleted'] = (bool) $input['isTrashed']; |
|
| 49 | - } |
|
| 47 | + if (array_key_exists('isTrashed', $input)) { |
|
| 48 | + $args['PRC_deleted'] = (bool) $input['isTrashed']; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - if (! empty($input['overrides'])) { |
|
| 52 | - $args['PRC_overrides'] = (int) $input['overrides']; |
|
| 53 | - } |
|
| 51 | + if (! empty($input['overrides'])) { |
|
| 52 | + $args['PRC_overrides'] = (int) $input['overrides']; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - if (! empty($input['order'])) { |
|
| 56 | - $args['PRC_order'] = (int) $input['order']; |
|
| 57 | - } |
|
| 55 | + if (! empty($input['order'])) { |
|
| 56 | + $args['PRC_order'] = (int) $input['order']; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - if (! empty($input['parent'])) { |
|
| 60 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['parent'])); |
|
| 61 | - $args['PRC_parent'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
|
| 62 | - } |
|
| 59 | + if (! empty($input['parent'])) { |
|
| 60 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['parent'])); |
|
| 61 | + $args['PRC_parent'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - return $args; |
|
| 65 | - } |
|
| 64 | + return $args; |
|
| 65 | + } |
|
| 66 | 66 | } |
@@ -23,20 +23,20 @@ discard block |
||
| 23 | 23 | { |
| 24 | 24 | $args = []; |
| 25 | 25 | |
| 26 | - if (! empty($input['priceType'])) { |
|
| 26 | + if ( ! empty($input['priceType'])) { |
|
| 27 | 27 | $parts = Relay::fromGlobalId(sanitize_text_field($input['priceType'])); |
| 28 | 28 | $args['PRT_ID'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - if (! empty($input['name'])) { |
|
| 31 | + if ( ! empty($input['name'])) { |
|
| 32 | 32 | $args['PRC_name'] = sanitize_text_field($input['name']); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if (! empty($input['desc'])) { |
|
| 35 | + if ( ! empty($input['desc'])) { |
|
| 36 | 36 | $args['PRC_desc'] = sanitize_text_field($input['desc']); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - if (! empty($input['amount'])) { |
|
| 39 | + if ( ! empty($input['amount'])) { |
|
| 40 | 40 | $args['PRC_amount'] = (float) $input['amount']; |
| 41 | 41 | } |
| 42 | 42 | |
@@ -48,15 +48,15 @@ discard block |
||
| 48 | 48 | $args['PRC_deleted'] = (bool) $input['isTrashed']; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - if (! empty($input['overrides'])) { |
|
| 51 | + if ( ! empty($input['overrides'])) { |
|
| 52 | 52 | $args['PRC_overrides'] = (int) $input['overrides']; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if (! empty($input['order'])) { |
|
| 55 | + if ( ! empty($input['order'])) { |
|
| 56 | 56 | $args['PRC_order'] = (int) $input['order']; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - if (! empty($input['parent'])) { |
|
| 59 | + if ( ! empty($input['parent'])) { |
|
| 60 | 60 | $parts = Relay::fromGlobalId(sanitize_text_field($input['parent'])); |
| 61 | 61 | $args['PRC_parent'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
| 62 | 62 | } |
@@ -21,79 +21,79 @@ |
||
| 21 | 21 | class DatetimeMutation |
| 22 | 22 | { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Maps the GraphQL input to a format that the model functions can use |
|
| 26 | - * |
|
| 27 | - * @param array $input Data coming from the GraphQL mutation query input |
|
| 28 | - * @return array |
|
| 29 | - * @throws Exception |
|
| 30 | - */ |
|
| 31 | - public static function prepareFields(array $input) |
|
| 32 | - { |
|
| 33 | - $args = []; |
|
| 34 | - |
|
| 35 | - if (! empty($input['eventId'])) { |
|
| 36 | - $args['EVT_ID'] = absint($input['eventId']); |
|
| 37 | - } elseif (! empty($input['event'])) { |
|
| 38 | - $parts = Relay::fromGlobalId($input['event']); |
|
| 39 | - $args['EVT_ID'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - if (! empty($input['name'])) { |
|
| 43 | - $args['DTT_name'] = sanitize_text_field($input['name']); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - if (! empty($input['description'])) { |
|
| 47 | - $args['DTT_description'] = sanitize_text_field($input['description']); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - if (! empty($input['startDate'])) { |
|
| 51 | - $args['DTT_EVT_start'] = new DateTime(sanitize_text_field($input['startDate'])); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - if (! empty($input['endDate'])) { |
|
| 55 | - $args['DTT_EVT_end'] = new DateTime(sanitize_text_field($input['endDate'])); |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - if (! empty($input['tickets'])) { |
|
| 59 | - $args['tickets'] = array_map('sanitize_text_field', (array) $input['tickets']); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - if (array_key_exists('isTrashed', $input)) { |
|
| 63 | - $args['DTT_deleted'] = (bool) $input['isTrashed']; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - // Likewise the other fields... |
|
| 67 | - |
|
| 68 | - return $args; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * Sets the related tickets for the given datetime. |
|
| 74 | - * |
|
| 75 | - * @param EE_Datetime $entity The datetime instance. |
|
| 76 | - * @param array $tickets Array of ticket IDs to relate. |
|
| 77 | - * @throws EE_Error |
|
| 78 | - * @throws InvalidDataTypeException |
|
| 79 | - * @throws InvalidInterfaceException |
|
| 80 | - * @throws InvalidArgumentException |
|
| 81 | - * @throws ReflectionException |
|
| 82 | - */ |
|
| 83 | - public static function setRelatedTickets($entity, array $tickets) |
|
| 84 | - { |
|
| 85 | - $relationName = 'Ticket'; |
|
| 86 | - // Remove all the existing related tickets |
|
| 87 | - $entity->_remove_relations($relationName); |
|
| 88 | - |
|
| 89 | - foreach ($tickets as $ID) { |
|
| 90 | - $parts = Relay::fromGlobalId($ID); |
|
| 91 | - if (! empty($parts['id']) && absint($parts['id'])) { |
|
| 92 | - $entity->_add_relation_to( |
|
| 93 | - $parts['id'], |
|
| 94 | - $relationName |
|
| 95 | - ); |
|
| 96 | - } |
|
| 97 | - } |
|
| 98 | - } |
|
| 24 | + /** |
|
| 25 | + * Maps the GraphQL input to a format that the model functions can use |
|
| 26 | + * |
|
| 27 | + * @param array $input Data coming from the GraphQL mutation query input |
|
| 28 | + * @return array |
|
| 29 | + * @throws Exception |
|
| 30 | + */ |
|
| 31 | + public static function prepareFields(array $input) |
|
| 32 | + { |
|
| 33 | + $args = []; |
|
| 34 | + |
|
| 35 | + if (! empty($input['eventId'])) { |
|
| 36 | + $args['EVT_ID'] = absint($input['eventId']); |
|
| 37 | + } elseif (! empty($input['event'])) { |
|
| 38 | + $parts = Relay::fromGlobalId($input['event']); |
|
| 39 | + $args['EVT_ID'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + if (! empty($input['name'])) { |
|
| 43 | + $args['DTT_name'] = sanitize_text_field($input['name']); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + if (! empty($input['description'])) { |
|
| 47 | + $args['DTT_description'] = sanitize_text_field($input['description']); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + if (! empty($input['startDate'])) { |
|
| 51 | + $args['DTT_EVT_start'] = new DateTime(sanitize_text_field($input['startDate'])); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + if (! empty($input['endDate'])) { |
|
| 55 | + $args['DTT_EVT_end'] = new DateTime(sanitize_text_field($input['endDate'])); |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + if (! empty($input['tickets'])) { |
|
| 59 | + $args['tickets'] = array_map('sanitize_text_field', (array) $input['tickets']); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + if (array_key_exists('isTrashed', $input)) { |
|
| 63 | + $args['DTT_deleted'] = (bool) $input['isTrashed']; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + // Likewise the other fields... |
|
| 67 | + |
|
| 68 | + return $args; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * Sets the related tickets for the given datetime. |
|
| 74 | + * |
|
| 75 | + * @param EE_Datetime $entity The datetime instance. |
|
| 76 | + * @param array $tickets Array of ticket IDs to relate. |
|
| 77 | + * @throws EE_Error |
|
| 78 | + * @throws InvalidDataTypeException |
|
| 79 | + * @throws InvalidInterfaceException |
|
| 80 | + * @throws InvalidArgumentException |
|
| 81 | + * @throws ReflectionException |
|
| 82 | + */ |
|
| 83 | + public static function setRelatedTickets($entity, array $tickets) |
|
| 84 | + { |
|
| 85 | + $relationName = 'Ticket'; |
|
| 86 | + // Remove all the existing related tickets |
|
| 87 | + $entity->_remove_relations($relationName); |
|
| 88 | + |
|
| 89 | + foreach ($tickets as $ID) { |
|
| 90 | + $parts = Relay::fromGlobalId($ID); |
|
| 91 | + if (! empty($parts['id']) && absint($parts['id'])) { |
|
| 92 | + $entity->_add_relation_to( |
|
| 93 | + $parts['id'], |
|
| 94 | + $relationName |
|
| 95 | + ); |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | + } |
|
| 99 | 99 | } |
@@ -25,209 +25,209 @@ |
||
| 25 | 25 | class Price extends TypeBase |
| 26 | 26 | { |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Price constructor. |
|
| 30 | - * |
|
| 31 | - * @param EEM_Price $price_model |
|
| 32 | - */ |
|
| 33 | - public function __construct(EEM_Price $price_model) |
|
| 34 | - { |
|
| 35 | - $this->model = $price_model; |
|
| 36 | - $this->setName($this->namespace . 'Price'); |
|
| 37 | - $this->setDescription(__('A price.', 'event_espresso')); |
|
| 38 | - $this->setIsCustomPostType(false); |
|
| 39 | - parent::__construct(); |
|
| 40 | - } |
|
| 28 | + /** |
|
| 29 | + * Price constructor. |
|
| 30 | + * |
|
| 31 | + * @param EEM_Price $price_model |
|
| 32 | + */ |
|
| 33 | + public function __construct(EEM_Price $price_model) |
|
| 34 | + { |
|
| 35 | + $this->model = $price_model; |
|
| 36 | + $this->setName($this->namespace . 'Price'); |
|
| 37 | + $this->setDescription(__('A price.', 'event_espresso')); |
|
| 38 | + $this->setIsCustomPostType(false); |
|
| 39 | + parent::__construct(); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @return GraphQLFieldInterface[] |
|
| 45 | - * @since $VID:$ |
|
| 46 | - */ |
|
| 47 | - public function getFields() |
|
| 48 | - { |
|
| 49 | - return [ |
|
| 50 | - new GraphQLField( |
|
| 51 | - 'id', |
|
| 52 | - ['non_null' => 'ID'], |
|
| 53 | - null, |
|
| 54 | - esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
| 55 | - ), |
|
| 56 | - new GraphQLOutputField( |
|
| 57 | - 'dbId', |
|
| 58 | - ['non_null' => 'Int'], |
|
| 59 | - 'ID', |
|
| 60 | - esc_html__('Price ID', 'event_espresso') |
|
| 61 | - ), |
|
| 62 | - new GraphQLField( |
|
| 63 | - 'name', |
|
| 64 | - 'String', |
|
| 65 | - 'name', |
|
| 66 | - esc_html__('Price Name', 'event_espresso') |
|
| 67 | - ), |
|
| 68 | - new GraphQLField( |
|
| 69 | - 'amount', |
|
| 70 | - 'Float', |
|
| 71 | - 'amount', |
|
| 72 | - esc_html__('Price Amount', 'event_espresso') |
|
| 73 | - ), |
|
| 74 | - new GraphQLField( |
|
| 75 | - 'desc', |
|
| 76 | - 'String', |
|
| 77 | - 'desc', |
|
| 78 | - esc_html__('Price description', 'event_espresso') |
|
| 79 | - ), |
|
| 80 | - new GraphQLField( |
|
| 81 | - 'overrides', |
|
| 82 | - 'Int', |
|
| 83 | - 'overrides', |
|
| 84 | - esc_html__('Price ID for a global Price that will be overridden by this Price.', 'event_espresso') |
|
| 85 | - ), |
|
| 86 | - new GraphQLField( |
|
| 87 | - 'order', |
|
| 88 | - 'Int', |
|
| 89 | - 'order', |
|
| 90 | - esc_html__('Order of Application of Price.', 'event_espresso') |
|
| 91 | - ), |
|
| 92 | - new GraphQLOutputField( |
|
| 93 | - 'parent', |
|
| 94 | - $this->name(), |
|
| 95 | - null, |
|
| 96 | - esc_html__('The parent price of the current price', 'event_espresso') |
|
| 97 | - ), |
|
| 98 | - new GraphQLInputField( |
|
| 99 | - 'parent', |
|
| 100 | - 'ID', |
|
| 101 | - null, |
|
| 102 | - esc_html__('The parent price ID', 'event_espresso') |
|
| 103 | - ), |
|
| 104 | - new GraphQLOutputField( |
|
| 105 | - 'priceType', |
|
| 106 | - $this->namespace . 'PriceType', |
|
| 107 | - 'type_obj', |
|
| 108 | - esc_html__('The related price type object.', 'event_espresso') |
|
| 109 | - ), |
|
| 110 | - new GraphQLInputField( |
|
| 111 | - 'priceType', |
|
| 112 | - 'ID', |
|
| 113 | - null, |
|
| 114 | - esc_html__('The price type ID', 'event_espresso') |
|
| 115 | - ), |
|
| 116 | - new GraphQLField( |
|
| 117 | - 'isTrashed', |
|
| 118 | - 'Boolean', |
|
| 119 | - 'deleted', |
|
| 120 | - esc_html__('Flag indicating price has been trashed.', 'event_espresso') |
|
| 121 | - ), |
|
| 122 | - new GraphQLField( |
|
| 123 | - 'isDefault', |
|
| 124 | - 'Boolean', |
|
| 125 | - 'is_default', |
|
| 126 | - esc_html__('Flag indicating price is the default one.', 'event_espresso') |
|
| 127 | - ), |
|
| 128 | - new GraphQLOutputField( |
|
| 129 | - 'isPercent', |
|
| 130 | - 'Boolean', |
|
| 131 | - 'is_percent', |
|
| 132 | - esc_html__('Flag indicating price is a percentage.', 'event_espresso') |
|
| 133 | - ), |
|
| 134 | - new GraphQLOutputField( |
|
| 135 | - 'isBasePrice', |
|
| 136 | - 'Boolean', |
|
| 137 | - 'is_base_price', |
|
| 138 | - esc_html__('Flag indicating price is a base price type.', 'event_espresso') |
|
| 139 | - ), |
|
| 140 | - new GraphQLOutputField( |
|
| 141 | - 'isDiscount', |
|
| 142 | - 'Boolean', |
|
| 143 | - 'is_discount', |
|
| 144 | - esc_html__('Flag indicating price is a discount.', 'event_espresso') |
|
| 145 | - ), |
|
| 146 | - new GraphQLOutputField( |
|
| 147 | - 'isTax', |
|
| 148 | - 'Boolean', |
|
| 149 | - 'is_tax', |
|
| 150 | - esc_html__('Flag indicating price is a tax.', 'event_espresso') |
|
| 151 | - ), |
|
| 152 | - new GraphQLOutputField( |
|
| 153 | - 'wpUser', |
|
| 154 | - 'User', |
|
| 155 | - null, |
|
| 156 | - esc_html__('Price Creator', 'event_espresso') |
|
| 157 | - ), |
|
| 158 | - new GraphQLInputField( |
|
| 159 | - 'wpUser', |
|
| 160 | - 'Int', |
|
| 161 | - null, |
|
| 162 | - esc_html__('Price Creator ID', 'event_espresso') |
|
| 163 | - ), |
|
| 164 | - ]; |
|
| 165 | - } |
|
| 43 | + /** |
|
| 44 | + * @return GraphQLFieldInterface[] |
|
| 45 | + * @since $VID:$ |
|
| 46 | + */ |
|
| 47 | + public function getFields() |
|
| 48 | + { |
|
| 49 | + return [ |
|
| 50 | + new GraphQLField( |
|
| 51 | + 'id', |
|
| 52 | + ['non_null' => 'ID'], |
|
| 53 | + null, |
|
| 54 | + esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
| 55 | + ), |
|
| 56 | + new GraphQLOutputField( |
|
| 57 | + 'dbId', |
|
| 58 | + ['non_null' => 'Int'], |
|
| 59 | + 'ID', |
|
| 60 | + esc_html__('Price ID', 'event_espresso') |
|
| 61 | + ), |
|
| 62 | + new GraphQLField( |
|
| 63 | + 'name', |
|
| 64 | + 'String', |
|
| 65 | + 'name', |
|
| 66 | + esc_html__('Price Name', 'event_espresso') |
|
| 67 | + ), |
|
| 68 | + new GraphQLField( |
|
| 69 | + 'amount', |
|
| 70 | + 'Float', |
|
| 71 | + 'amount', |
|
| 72 | + esc_html__('Price Amount', 'event_espresso') |
|
| 73 | + ), |
|
| 74 | + new GraphQLField( |
|
| 75 | + 'desc', |
|
| 76 | + 'String', |
|
| 77 | + 'desc', |
|
| 78 | + esc_html__('Price description', 'event_espresso') |
|
| 79 | + ), |
|
| 80 | + new GraphQLField( |
|
| 81 | + 'overrides', |
|
| 82 | + 'Int', |
|
| 83 | + 'overrides', |
|
| 84 | + esc_html__('Price ID for a global Price that will be overridden by this Price.', 'event_espresso') |
|
| 85 | + ), |
|
| 86 | + new GraphQLField( |
|
| 87 | + 'order', |
|
| 88 | + 'Int', |
|
| 89 | + 'order', |
|
| 90 | + esc_html__('Order of Application of Price.', 'event_espresso') |
|
| 91 | + ), |
|
| 92 | + new GraphQLOutputField( |
|
| 93 | + 'parent', |
|
| 94 | + $this->name(), |
|
| 95 | + null, |
|
| 96 | + esc_html__('The parent price of the current price', 'event_espresso') |
|
| 97 | + ), |
|
| 98 | + new GraphQLInputField( |
|
| 99 | + 'parent', |
|
| 100 | + 'ID', |
|
| 101 | + null, |
|
| 102 | + esc_html__('The parent price ID', 'event_espresso') |
|
| 103 | + ), |
|
| 104 | + new GraphQLOutputField( |
|
| 105 | + 'priceType', |
|
| 106 | + $this->namespace . 'PriceType', |
|
| 107 | + 'type_obj', |
|
| 108 | + esc_html__('The related price type object.', 'event_espresso') |
|
| 109 | + ), |
|
| 110 | + new GraphQLInputField( |
|
| 111 | + 'priceType', |
|
| 112 | + 'ID', |
|
| 113 | + null, |
|
| 114 | + esc_html__('The price type ID', 'event_espresso') |
|
| 115 | + ), |
|
| 116 | + new GraphQLField( |
|
| 117 | + 'isTrashed', |
|
| 118 | + 'Boolean', |
|
| 119 | + 'deleted', |
|
| 120 | + esc_html__('Flag indicating price has been trashed.', 'event_espresso') |
|
| 121 | + ), |
|
| 122 | + new GraphQLField( |
|
| 123 | + 'isDefault', |
|
| 124 | + 'Boolean', |
|
| 125 | + 'is_default', |
|
| 126 | + esc_html__('Flag indicating price is the default one.', 'event_espresso') |
|
| 127 | + ), |
|
| 128 | + new GraphQLOutputField( |
|
| 129 | + 'isPercent', |
|
| 130 | + 'Boolean', |
|
| 131 | + 'is_percent', |
|
| 132 | + esc_html__('Flag indicating price is a percentage.', 'event_espresso') |
|
| 133 | + ), |
|
| 134 | + new GraphQLOutputField( |
|
| 135 | + 'isBasePrice', |
|
| 136 | + 'Boolean', |
|
| 137 | + 'is_base_price', |
|
| 138 | + esc_html__('Flag indicating price is a base price type.', 'event_espresso') |
|
| 139 | + ), |
|
| 140 | + new GraphQLOutputField( |
|
| 141 | + 'isDiscount', |
|
| 142 | + 'Boolean', |
|
| 143 | + 'is_discount', |
|
| 144 | + esc_html__('Flag indicating price is a discount.', 'event_espresso') |
|
| 145 | + ), |
|
| 146 | + new GraphQLOutputField( |
|
| 147 | + 'isTax', |
|
| 148 | + 'Boolean', |
|
| 149 | + 'is_tax', |
|
| 150 | + esc_html__('Flag indicating price is a tax.', 'event_espresso') |
|
| 151 | + ), |
|
| 152 | + new GraphQLOutputField( |
|
| 153 | + 'wpUser', |
|
| 154 | + 'User', |
|
| 155 | + null, |
|
| 156 | + esc_html__('Price Creator', 'event_espresso') |
|
| 157 | + ), |
|
| 158 | + new GraphQLInputField( |
|
| 159 | + 'wpUser', |
|
| 160 | + 'Int', |
|
| 161 | + null, |
|
| 162 | + esc_html__('Price Creator ID', 'event_espresso') |
|
| 163 | + ), |
|
| 164 | + ]; |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | 167 | |
| 168 | - /** |
|
| 169 | - * @param array $inputFields The mutation input fields. |
|
| 170 | - * @throws InvalidArgumentException |
|
| 171 | - * @throws ReflectionException |
|
| 172 | - * @since $VID:$ |
|
| 173 | - */ |
|
| 174 | - public function registerMutations(array $inputFields) |
|
| 175 | - { |
|
| 176 | - // Register mutation to update an entity. |
|
| 177 | - register_graphql_mutation( |
|
| 178 | - 'update' . $this->name(), |
|
| 179 | - [ |
|
| 180 | - 'inputFields' => $inputFields, |
|
| 181 | - 'outputFields' => [ |
|
| 182 | - lcfirst($this->name()) => [ |
|
| 183 | - 'type' => $this->name(), |
|
| 184 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
| 185 | - ], |
|
| 186 | - ], |
|
| 187 | - 'mutateAndGetPayload' => PriceUpdate::mutateAndGetPayload($this->model, $this), |
|
| 188 | - ] |
|
| 189 | - ); |
|
| 190 | - // Register mutation to delete an entity. |
|
| 191 | - register_graphql_mutation( |
|
| 192 | - 'delete' . $this->name(), |
|
| 193 | - [ |
|
| 194 | - 'inputFields' => [ |
|
| 195 | - 'id' => $inputFields['id'], |
|
| 196 | - 'deletePermanently' => [ |
|
| 197 | - 'type' => 'Boolean', |
|
| 198 | - 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
| 199 | - ], |
|
| 200 | - ], |
|
| 201 | - 'outputFields' => [ |
|
| 202 | - lcfirst($this->name()) => [ |
|
| 203 | - 'type' => $this->name(), |
|
| 204 | - 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
| 205 | - 'resolve' => static function ($payload) { |
|
| 206 | - $deleted = (object) $payload['deleted']; |
|
| 168 | + /** |
|
| 169 | + * @param array $inputFields The mutation input fields. |
|
| 170 | + * @throws InvalidArgumentException |
|
| 171 | + * @throws ReflectionException |
|
| 172 | + * @since $VID:$ |
|
| 173 | + */ |
|
| 174 | + public function registerMutations(array $inputFields) |
|
| 175 | + { |
|
| 176 | + // Register mutation to update an entity. |
|
| 177 | + register_graphql_mutation( |
|
| 178 | + 'update' . $this->name(), |
|
| 179 | + [ |
|
| 180 | + 'inputFields' => $inputFields, |
|
| 181 | + 'outputFields' => [ |
|
| 182 | + lcfirst($this->name()) => [ |
|
| 183 | + 'type' => $this->name(), |
|
| 184 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
| 185 | + ], |
|
| 186 | + ], |
|
| 187 | + 'mutateAndGetPayload' => PriceUpdate::mutateAndGetPayload($this->model, $this), |
|
| 188 | + ] |
|
| 189 | + ); |
|
| 190 | + // Register mutation to delete an entity. |
|
| 191 | + register_graphql_mutation( |
|
| 192 | + 'delete' . $this->name(), |
|
| 193 | + [ |
|
| 194 | + 'inputFields' => [ |
|
| 195 | + 'id' => $inputFields['id'], |
|
| 196 | + 'deletePermanently' => [ |
|
| 197 | + 'type' => 'Boolean', |
|
| 198 | + 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
| 199 | + ], |
|
| 200 | + ], |
|
| 201 | + 'outputFields' => [ |
|
| 202 | + lcfirst($this->name()) => [ |
|
| 203 | + 'type' => $this->name(), |
|
| 204 | + 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
| 205 | + 'resolve' => static function ($payload) { |
|
| 206 | + $deleted = (object) $payload['deleted']; |
|
| 207 | 207 | |
| 208 | - return ! empty($deleted) ? $deleted : null; |
|
| 209 | - }, |
|
| 210 | - ], |
|
| 211 | - ], |
|
| 212 | - 'mutateAndGetPayload' => PriceDelete::mutateAndGetPayload($this->model, $this), |
|
| 213 | - ] |
|
| 214 | - ); |
|
| 208 | + return ! empty($deleted) ? $deleted : null; |
|
| 209 | + }, |
|
| 210 | + ], |
|
| 211 | + ], |
|
| 212 | + 'mutateAndGetPayload' => PriceDelete::mutateAndGetPayload($this->model, $this), |
|
| 213 | + ] |
|
| 214 | + ); |
|
| 215 | 215 | |
| 216 | - // remove primary key from input. |
|
| 217 | - unset($inputFields['id']); |
|
| 218 | - // Register mutation to update an entity. |
|
| 219 | - register_graphql_mutation( |
|
| 220 | - 'create' . $this->name(), |
|
| 221 | - [ |
|
| 222 | - 'inputFields' => $inputFields, |
|
| 223 | - 'outputFields' => [ |
|
| 224 | - lcfirst($this->name()) => [ |
|
| 225 | - 'type' => $this->name(), |
|
| 226 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
| 227 | - ], |
|
| 228 | - ], |
|
| 229 | - 'mutateAndGetPayload' => PriceCreate::mutateAndGetPayload($this->model, $this), |
|
| 230 | - ] |
|
| 231 | - ); |
|
| 232 | - } |
|
| 216 | + // remove primary key from input. |
|
| 217 | + unset($inputFields['id']); |
|
| 218 | + // Register mutation to update an entity. |
|
| 219 | + register_graphql_mutation( |
|
| 220 | + 'create' . $this->name(), |
|
| 221 | + [ |
|
| 222 | + 'inputFields' => $inputFields, |
|
| 223 | + 'outputFields' => [ |
|
| 224 | + lcfirst($this->name()) => [ |
|
| 225 | + 'type' => $this->name(), |
|
| 226 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
| 227 | + ], |
|
| 228 | + ], |
|
| 229 | + 'mutateAndGetPayload' => PriceCreate::mutateAndGetPayload($this->model, $this), |
|
| 230 | + ] |
|
| 231 | + ); |
|
| 232 | + } |
|
| 233 | 233 | } |