@@ -13,69 +13,69 @@ |
||
| 13 | 13 | class DatetimeMutation |
| 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 | - { |
|
| 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 | 24 | |
| 25 | - $args = []; |
|
| 25 | + $args = []; |
|
| 26 | 26 | |
| 27 | - if (! empty($input['eventId'])) { |
|
| 28 | - $args['EVT_ID'] = absint($input['eventId']); |
|
| 29 | - } elseif (! empty($input['event'])) { |
|
| 30 | - $parts = Relay::fromGlobalId($input['event']); |
|
| 31 | - $args['EVT_ID'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
| 32 | - } |
|
| 27 | + if (! empty($input['eventId'])) { |
|
| 28 | + $args['EVT_ID'] = absint($input['eventId']); |
|
| 29 | + } elseif (! empty($input['event'])) { |
|
| 30 | + $parts = Relay::fromGlobalId($input['event']); |
|
| 31 | + $args['EVT_ID'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - if (! empty($input['name'])) { |
|
| 35 | - $args['DTT_name'] = sanitize_text_field($input['name']); |
|
| 36 | - } |
|
| 34 | + if (! empty($input['name'])) { |
|
| 35 | + $args['DTT_name'] = sanitize_text_field($input['name']); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - if (! empty($input['description'])) { |
|
| 39 | - $args['DTT_description'] = sanitize_text_field($input['description']); |
|
| 40 | - } |
|
| 38 | + if (! empty($input['description'])) { |
|
| 39 | + $args['DTT_description'] = sanitize_text_field($input['description']); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - if (! empty($input['startDate'])) { |
|
| 43 | - $args['DTT_EVT_start'] = sanitize_text_field($input['startDate']); |
|
| 44 | - } |
|
| 42 | + if (! empty($input['startDate'])) { |
|
| 43 | + $args['DTT_EVT_start'] = sanitize_text_field($input['startDate']); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - if (! empty($input['endDate'])) { |
|
| 47 | - $args['DTT_EVT_end'] = sanitize_text_field($input['endDate']); |
|
| 48 | - } |
|
| 46 | + if (! empty($input['endDate'])) { |
|
| 47 | + $args['DTT_EVT_end'] = sanitize_text_field($input['endDate']); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - if (! empty($input['tickets'])) { |
|
| 51 | - $args['tickets'] = array_map('sanitize_text_field', (array) $input['tickets']); |
|
| 52 | - } |
|
| 50 | + if (! empty($input['tickets'])) { |
|
| 51 | + $args['tickets'] = array_map('sanitize_text_field', (array) $input['tickets']); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - // Likewise the other fields... |
|
| 54 | + // Likewise the other fields... |
|
| 55 | 55 | |
| 56 | - return $args; |
|
| 57 | - } |
|
| 56 | + return $args; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Sets the related tickets for the given datetime. |
|
| 61 | - * |
|
| 62 | - * @param EE_Datetime $entity The datetime instance. |
|
| 63 | - * @param array $tickets Array of ticket IDs to relate. |
|
| 64 | - */ |
|
| 65 | - public static function setRelatedTickets($entity, array $tickets) |
|
| 66 | - { |
|
| 67 | - $relationName = 'Ticket'; |
|
| 68 | - // Remove all the existing related tickets |
|
| 69 | - $entity->_remove_relations($relationName); |
|
| 59 | + /** |
|
| 60 | + * Sets the related tickets for the given datetime. |
|
| 61 | + * |
|
| 62 | + * @param EE_Datetime $entity The datetime instance. |
|
| 63 | + * @param array $tickets Array of ticket IDs to relate. |
|
| 64 | + */ |
|
| 65 | + public static function setRelatedTickets($entity, array $tickets) |
|
| 66 | + { |
|
| 67 | + $relationName = 'Ticket'; |
|
| 68 | + // Remove all the existing related tickets |
|
| 69 | + $entity->_remove_relations($relationName); |
|
| 70 | 70 | |
| 71 | - foreach ($tickets as $ID) { |
|
| 72 | - $parts = Relay::fromGlobalId($ID); |
|
| 73 | - if (! empty($parts['id']) && absint($parts['id'])) { |
|
| 74 | - $entity->_add_relation_to( |
|
| 75 | - $parts['id'], |
|
| 76 | - $relationName |
|
| 77 | - ); |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - } |
|
| 71 | + foreach ($tickets as $ID) { |
|
| 72 | + $parts = Relay::fromGlobalId($ID); |
|
| 73 | + if (! empty($parts['id']) && absint($parts['id'])) { |
|
| 74 | + $entity->_add_relation_to( |
|
| 75 | + $parts['id'], |
|
| 76 | + $relationName |
|
| 77 | + ); |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + } |
|
| 81 | 81 | } |
@@ -24,30 +24,30 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | $args = []; |
| 26 | 26 | |
| 27 | - if (! empty($input['eventId'])) { |
|
| 27 | + if ( ! empty($input['eventId'])) { |
|
| 28 | 28 | $args['EVT_ID'] = absint($input['eventId']); |
| 29 | - } elseif (! empty($input['event'])) { |
|
| 29 | + } elseif ( ! empty($input['event'])) { |
|
| 30 | 30 | $parts = Relay::fromGlobalId($input['event']); |
| 31 | - $args['EVT_ID'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
| 31 | + $args['EVT_ID'] = ( ! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - if (! empty($input['name'])) { |
|
| 34 | + if ( ! empty($input['name'])) { |
|
| 35 | 35 | $args['DTT_name'] = sanitize_text_field($input['name']); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - if (! empty($input['description'])) { |
|
| 38 | + if ( ! empty($input['description'])) { |
|
| 39 | 39 | $args['DTT_description'] = sanitize_text_field($input['description']); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - if (! empty($input['startDate'])) { |
|
| 42 | + if ( ! empty($input['startDate'])) { |
|
| 43 | 43 | $args['DTT_EVT_start'] = sanitize_text_field($input['startDate']); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - if (! empty($input['endDate'])) { |
|
| 46 | + if ( ! empty($input['endDate'])) { |
|
| 47 | 47 | $args['DTT_EVT_end'] = sanitize_text_field($input['endDate']); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - if (! empty($input['tickets'])) { |
|
| 50 | + if ( ! empty($input['tickets'])) { |
|
| 51 | 51 | $args['tickets'] = array_map('sanitize_text_field', (array) $input['tickets']); |
| 52 | 52 | } |
| 53 | 53 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | foreach ($tickets as $ID) { |
| 72 | 72 | $parts = Relay::fromGlobalId($ID); |
| 73 | - if (! empty($parts['id']) && absint($parts['id'])) { |
|
| 73 | + if ( ! empty($parts['id']) && absint($parts['id'])) { |
|
| 74 | 74 | $entity->_add_relation_to( |
| 75 | 75 | $parts['id'], |
| 76 | 76 | $relationName |
@@ -13,58 +13,58 @@ |
||
| 13 | 13 | class TicketMutation |
| 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 | - { |
|
| 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 | 24 | |
| 25 | - $args = []; |
|
| 25 | + $args = []; |
|
| 26 | 26 | |
| 27 | - if (! empty($input['name'])) { |
|
| 28 | - $args['TKT_name'] = sanitize_text_field($input['name']); |
|
| 29 | - } |
|
| 27 | + if (! empty($input['name'])) { |
|
| 28 | + $args['TKT_name'] = sanitize_text_field($input['name']); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - if (! empty($input['description'])) { |
|
| 32 | - $args['TKT_description'] = sanitize_text_field($input['description']); |
|
| 33 | - } |
|
| 31 | + if (! empty($input['description'])) { |
|
| 32 | + $args['TKT_description'] = sanitize_text_field($input['description']); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - if (! empty($input['price'])) { |
|
| 36 | - $args['TKT_price'] = floatval($input['price']); |
|
| 37 | - } |
|
| 35 | + if (! empty($input['price'])) { |
|
| 36 | + $args['TKT_price'] = floatval($input['price']); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - if (! empty($input['datetimes'])) { |
|
| 40 | - $args['datetimes'] = array_map('sanitize_text_field', (array) $input['datetimes']); |
|
| 41 | - } |
|
| 39 | + if (! empty($input['datetimes'])) { |
|
| 40 | + $args['datetimes'] = array_map('sanitize_text_field', (array) $input['datetimes']); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - // Likewise the other fields... |
|
| 43 | + // Likewise the other fields... |
|
| 44 | 44 | |
| 45 | - return $args; |
|
| 46 | - } |
|
| 45 | + return $args; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * Sets the related tickets for the given datetime. |
|
| 50 | - * |
|
| 51 | - * @param EE_Ticket $entity The Ticket instance. |
|
| 52 | - * @param array $datetimes Array of datetime IDs to relate. |
|
| 53 | - */ |
|
| 54 | - public static function setRelatedDatetimes($entity, array $datetimes) |
|
| 55 | - { |
|
| 56 | - $relationName = 'Datetime'; |
|
| 57 | - // Remove all the existing related datetimes |
|
| 58 | - $entity->_remove_relations($relationName); |
|
| 48 | + /** |
|
| 49 | + * Sets the related tickets for the given datetime. |
|
| 50 | + * |
|
| 51 | + * @param EE_Ticket $entity The Ticket instance. |
|
| 52 | + * @param array $datetimes Array of datetime IDs to relate. |
|
| 53 | + */ |
|
| 54 | + public static function setRelatedDatetimes($entity, array $datetimes) |
|
| 55 | + { |
|
| 56 | + $relationName = 'Datetime'; |
|
| 57 | + // Remove all the existing related datetimes |
|
| 58 | + $entity->_remove_relations($relationName); |
|
| 59 | 59 | |
| 60 | - foreach ($datetimes as $ID) { |
|
| 61 | - $parts = Relay::fromGlobalId($ID); |
|
| 62 | - if (! empty($parts['id']) && absint($parts['id'])) { |
|
| 63 | - $entity->_add_relation_to( |
|
| 64 | - $parts['id'], |
|
| 65 | - $relationName |
|
| 66 | - ); |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - } |
|
| 60 | + foreach ($datetimes as $ID) { |
|
| 61 | + $parts = Relay::fromGlobalId($ID); |
|
| 62 | + if (! empty($parts['id']) && absint($parts['id'])) { |
|
| 63 | + $entity->_add_relation_to( |
|
| 64 | + $parts['id'], |
|
| 65 | + $relationName |
|
| 66 | + ); |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | 70 | } |
@@ -24,19 +24,19 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | $args = []; |
| 26 | 26 | |
| 27 | - if (! empty($input['name'])) { |
|
| 27 | + if ( ! empty($input['name'])) { |
|
| 28 | 28 | $args['TKT_name'] = sanitize_text_field($input['name']); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - if (! empty($input['description'])) { |
|
| 31 | + if ( ! empty($input['description'])) { |
|
| 32 | 32 | $args['TKT_description'] = sanitize_text_field($input['description']); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if (! empty($input['price'])) { |
|
| 35 | + if ( ! empty($input['price'])) { |
|
| 36 | 36 | $args['TKT_price'] = floatval($input['price']); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - if (! empty($input['datetimes'])) { |
|
| 39 | + if ( ! empty($input['datetimes'])) { |
|
| 40 | 40 | $args['datetimes'] = array_map('sanitize_text_field', (array) $input['datetimes']); |
| 41 | 41 | } |
| 42 | 42 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | foreach ($datetimes as $ID) { |
| 61 | 61 | $parts = Relay::fromGlobalId($ID); |
| 62 | - if (! empty($parts['id']) && absint($parts['id'])) { |
|
| 62 | + if ( ! empty($parts['id']) && absint($parts['id'])) { |
|
| 63 | 63 | $entity->_add_relation_to( |
| 64 | 64 | $parts['id'], |
| 65 | 65 | $relationName |
@@ -25,265 +25,265 @@ |
||
| 25 | 25 | class Datetime extends TypeBase |
| 26 | 26 | { |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * EventDate constructor. |
|
| 30 | - * |
|
| 31 | - * @param EEM_Datetime $datetime_model |
|
| 32 | - */ |
|
| 33 | - public function __construct(EEM_Datetime $datetime_model) |
|
| 34 | - { |
|
| 35 | - $this->model = $datetime_model; |
|
| 36 | - $this->setName('Datetime'); |
|
| 37 | - $this->setDescription(__('An event date', 'event_espresso')); |
|
| 38 | - $this->setIsCustomPostType(false); |
|
| 39 | - parent::__construct(); |
|
| 40 | - } |
|
| 28 | + /** |
|
| 29 | + * EventDate constructor. |
|
| 30 | + * |
|
| 31 | + * @param EEM_Datetime $datetime_model |
|
| 32 | + */ |
|
| 33 | + public function __construct(EEM_Datetime $datetime_model) |
|
| 34 | + { |
|
| 35 | + $this->model = $datetime_model; |
|
| 36 | + $this->setName('Datetime'); |
|
| 37 | + $this->setDescription(__('An event date', '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 | - lcfirst($this->name()) . 'Id', |
|
| 58 | - ['non_null' => 'Int'], |
|
| 59 | - 'ID', |
|
| 60 | - esc_html__('The datetime ID.', 'event_espresso') |
|
| 61 | - ), |
|
| 62 | - new GraphQLField( |
|
| 63 | - 'name', |
|
| 64 | - 'String', |
|
| 65 | - 'name', |
|
| 66 | - esc_html__('Datetime Name', 'event_espresso') |
|
| 67 | - ), |
|
| 68 | - new GraphQLField( |
|
| 69 | - 'description', |
|
| 70 | - 'String', |
|
| 71 | - 'description', |
|
| 72 | - esc_html__('Description for Datetime', 'event_espresso') |
|
| 73 | - ), |
|
| 74 | - new GraphQLField( |
|
| 75 | - 'start', |
|
| 76 | - 'String', |
|
| 77 | - 'start', |
|
| 78 | - esc_html__('Start timestamp of Event', 'event_espresso') |
|
| 79 | - ), |
|
| 80 | - new GraphQLField( |
|
| 81 | - 'startDate', |
|
| 82 | - 'String', |
|
| 83 | - 'start_date', |
|
| 84 | - esc_html__('Start time/date of Event', 'event_espresso') |
|
| 85 | - ), |
|
| 86 | - new GraphQLField( |
|
| 87 | - 'end', |
|
| 88 | - 'String', |
|
| 89 | - 'end', |
|
| 90 | - esc_html__('End timestamp of Event', 'event_espresso') |
|
| 91 | - ), |
|
| 92 | - new GraphQLField( |
|
| 93 | - 'endDate', |
|
| 94 | - 'String', |
|
| 95 | - 'end_date', |
|
| 96 | - esc_html__('End time/date of Event', 'event_espresso') |
|
| 97 | - ), |
|
| 98 | - new GraphQLField( |
|
| 99 | - 'startTime', |
|
| 100 | - 'String', |
|
| 101 | - 'start_time', |
|
| 102 | - esc_html__('Start time of Event', 'event_espresso') |
|
| 103 | - ), |
|
| 104 | - new GraphQLField( |
|
| 105 | - 'endTime', |
|
| 106 | - 'String', |
|
| 107 | - 'end_time', |
|
| 108 | - esc_html__('End time of Event', 'event_espresso') |
|
| 109 | - ), |
|
| 110 | - new GraphQLField( |
|
| 111 | - 'capacity', |
|
| 112 | - 'Int', |
|
| 113 | - 'reg_limit', |
|
| 114 | - esc_html__('Registration Limit for this time', 'event_espresso'), |
|
| 115 | - [$this, 'parseInfiniteValue'] |
|
| 116 | - ), |
|
| 117 | - new GraphQLField( |
|
| 118 | - 'sold', |
|
| 119 | - 'Int', |
|
| 120 | - 'sold', |
|
| 121 | - esc_html__('How many sales for this Datetime that have occurred', 'event_espresso') |
|
| 122 | - ), |
|
| 123 | - new GraphQLField( |
|
| 124 | - 'reserved', |
|
| 125 | - 'Int', |
|
| 126 | - 'reserved', |
|
| 127 | - esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso') |
|
| 128 | - ), |
|
| 129 | - new GraphQLField( |
|
| 130 | - 'order', |
|
| 131 | - 'Int', |
|
| 132 | - 'order', |
|
| 133 | - esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
| 134 | - ), |
|
| 135 | - new GraphQLField( |
|
| 136 | - 'length', |
|
| 137 | - 'Int', |
|
| 138 | - 'length', |
|
| 139 | - esc_html__('The length of the event (start to end time) in seconds', 'event_espresso') |
|
| 140 | - ), |
|
| 141 | - new GraphQLOutputField( |
|
| 142 | - 'parent', |
|
| 143 | - 'Datetime', |
|
| 144 | - null, |
|
| 145 | - esc_html__('The parent datetime of the current datetime', 'event_espresso') |
|
| 146 | - ), |
|
| 147 | - new GraphQLInputField( |
|
| 148 | - 'parent', |
|
| 149 | - 'Int', |
|
| 150 | - null, |
|
| 151 | - esc_html__('The parent datetime ID', 'event_espresso') |
|
| 152 | - ), |
|
| 153 | - new GraphQLField( |
|
| 154 | - 'isPrimary', |
|
| 155 | - 'Boolean', |
|
| 156 | - 'is_primary', |
|
| 157 | - esc_html__('Flag indicating datetime is primary one for event', 'event_espresso') |
|
| 158 | - ), |
|
| 159 | - new GraphQLField( |
|
| 160 | - 'isSoldOut', |
|
| 161 | - 'Boolean', |
|
| 162 | - 'sold_out', |
|
| 163 | - esc_html__( |
|
| 164 | - 'Flag indicating whether the tickets sold for this datetime, met or exceed the registration limit', |
|
| 165 | - 'event_espresso' |
|
| 166 | - ) |
|
| 167 | - ), |
|
| 168 | - new GraphQLField( |
|
| 169 | - 'isUpcoming', |
|
| 170 | - 'Boolean', |
|
| 171 | - 'is_upcoming', |
|
| 172 | - esc_html__('Whether the date is upcoming', 'event_espresso') |
|
| 173 | - ), |
|
| 174 | - new GraphQLField( |
|
| 175 | - 'isActive', |
|
| 176 | - 'Boolean', |
|
| 177 | - 'is_active', |
|
| 178 | - esc_html__('Flag indicating datetime is active', 'event_espresso') |
|
| 179 | - ), |
|
| 180 | - new GraphQLField( |
|
| 181 | - 'isExpired', |
|
| 182 | - 'Boolean', |
|
| 183 | - 'is_expired', |
|
| 184 | - esc_html__('Flag indicating datetime is expired or not', 'event_espresso') |
|
| 185 | - ), |
|
| 186 | - new GraphQLOutputField( |
|
| 187 | - 'event', |
|
| 188 | - 'Event', |
|
| 189 | - null, |
|
| 190 | - esc_html__('Event of the datetime.', 'event_espresso') |
|
| 191 | - ), |
|
| 192 | - new GraphQLInputField( |
|
| 193 | - 'eventId', |
|
| 194 | - 'Int', |
|
| 195 | - null, |
|
| 196 | - esc_html__('Event ID of the datetime.', 'event_espresso') |
|
| 197 | - ), |
|
| 198 | - new GraphQLInputField( |
|
| 199 | - 'event', |
|
| 200 | - 'ID', |
|
| 201 | - null, |
|
| 202 | - esc_html__('Globally uqinue event ID of the datetime.', 'event_espresso') |
|
| 203 | - ), |
|
| 204 | - new GraphQLInputField( |
|
| 205 | - 'tickets', |
|
| 206 | - ['list_of' => 'ID'], |
|
| 207 | - null, |
|
| 208 | - sprintf( |
|
| 209 | - '%1$s %2$s', |
|
| 210 | - esc_html__('Globally uqinue IDs of the tickets related to the datetime.', 'event_espresso'), |
|
| 211 | - esc_html__('Ignored if empty.', 'event_espresso') |
|
| 212 | - ) |
|
| 213 | - ), |
|
| 214 | - new GraphQLOutputField( |
|
| 215 | - 'relatedTickets', |
|
| 216 | - ['list_of' => 'ID'], |
|
| 217 | - null, |
|
| 218 | - esc_html__('Globally unique IDs of teh related tickets.', 'event_espresso') |
|
| 219 | - ), |
|
| 220 | - ]; |
|
| 221 | - } |
|
| 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 | + lcfirst($this->name()) . 'Id', |
|
| 58 | + ['non_null' => 'Int'], |
|
| 59 | + 'ID', |
|
| 60 | + esc_html__('The datetime ID.', 'event_espresso') |
|
| 61 | + ), |
|
| 62 | + new GraphQLField( |
|
| 63 | + 'name', |
|
| 64 | + 'String', |
|
| 65 | + 'name', |
|
| 66 | + esc_html__('Datetime Name', 'event_espresso') |
|
| 67 | + ), |
|
| 68 | + new GraphQLField( |
|
| 69 | + 'description', |
|
| 70 | + 'String', |
|
| 71 | + 'description', |
|
| 72 | + esc_html__('Description for Datetime', 'event_espresso') |
|
| 73 | + ), |
|
| 74 | + new GraphQLField( |
|
| 75 | + 'start', |
|
| 76 | + 'String', |
|
| 77 | + 'start', |
|
| 78 | + esc_html__('Start timestamp of Event', 'event_espresso') |
|
| 79 | + ), |
|
| 80 | + new GraphQLField( |
|
| 81 | + 'startDate', |
|
| 82 | + 'String', |
|
| 83 | + 'start_date', |
|
| 84 | + esc_html__('Start time/date of Event', 'event_espresso') |
|
| 85 | + ), |
|
| 86 | + new GraphQLField( |
|
| 87 | + 'end', |
|
| 88 | + 'String', |
|
| 89 | + 'end', |
|
| 90 | + esc_html__('End timestamp of Event', 'event_espresso') |
|
| 91 | + ), |
|
| 92 | + new GraphQLField( |
|
| 93 | + 'endDate', |
|
| 94 | + 'String', |
|
| 95 | + 'end_date', |
|
| 96 | + esc_html__('End time/date of Event', 'event_espresso') |
|
| 97 | + ), |
|
| 98 | + new GraphQLField( |
|
| 99 | + 'startTime', |
|
| 100 | + 'String', |
|
| 101 | + 'start_time', |
|
| 102 | + esc_html__('Start time of Event', 'event_espresso') |
|
| 103 | + ), |
|
| 104 | + new GraphQLField( |
|
| 105 | + 'endTime', |
|
| 106 | + 'String', |
|
| 107 | + 'end_time', |
|
| 108 | + esc_html__('End time of Event', 'event_espresso') |
|
| 109 | + ), |
|
| 110 | + new GraphQLField( |
|
| 111 | + 'capacity', |
|
| 112 | + 'Int', |
|
| 113 | + 'reg_limit', |
|
| 114 | + esc_html__('Registration Limit for this time', 'event_espresso'), |
|
| 115 | + [$this, 'parseInfiniteValue'] |
|
| 116 | + ), |
|
| 117 | + new GraphQLField( |
|
| 118 | + 'sold', |
|
| 119 | + 'Int', |
|
| 120 | + 'sold', |
|
| 121 | + esc_html__('How many sales for this Datetime that have occurred', 'event_espresso') |
|
| 122 | + ), |
|
| 123 | + new GraphQLField( |
|
| 124 | + 'reserved', |
|
| 125 | + 'Int', |
|
| 126 | + 'reserved', |
|
| 127 | + esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso') |
|
| 128 | + ), |
|
| 129 | + new GraphQLField( |
|
| 130 | + 'order', |
|
| 131 | + 'Int', |
|
| 132 | + 'order', |
|
| 133 | + esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
| 134 | + ), |
|
| 135 | + new GraphQLField( |
|
| 136 | + 'length', |
|
| 137 | + 'Int', |
|
| 138 | + 'length', |
|
| 139 | + esc_html__('The length of the event (start to end time) in seconds', 'event_espresso') |
|
| 140 | + ), |
|
| 141 | + new GraphQLOutputField( |
|
| 142 | + 'parent', |
|
| 143 | + 'Datetime', |
|
| 144 | + null, |
|
| 145 | + esc_html__('The parent datetime of the current datetime', 'event_espresso') |
|
| 146 | + ), |
|
| 147 | + new GraphQLInputField( |
|
| 148 | + 'parent', |
|
| 149 | + 'Int', |
|
| 150 | + null, |
|
| 151 | + esc_html__('The parent datetime ID', 'event_espresso') |
|
| 152 | + ), |
|
| 153 | + new GraphQLField( |
|
| 154 | + 'isPrimary', |
|
| 155 | + 'Boolean', |
|
| 156 | + 'is_primary', |
|
| 157 | + esc_html__('Flag indicating datetime is primary one for event', 'event_espresso') |
|
| 158 | + ), |
|
| 159 | + new GraphQLField( |
|
| 160 | + 'isSoldOut', |
|
| 161 | + 'Boolean', |
|
| 162 | + 'sold_out', |
|
| 163 | + esc_html__( |
|
| 164 | + 'Flag indicating whether the tickets sold for this datetime, met or exceed the registration limit', |
|
| 165 | + 'event_espresso' |
|
| 166 | + ) |
|
| 167 | + ), |
|
| 168 | + new GraphQLField( |
|
| 169 | + 'isUpcoming', |
|
| 170 | + 'Boolean', |
|
| 171 | + 'is_upcoming', |
|
| 172 | + esc_html__('Whether the date is upcoming', 'event_espresso') |
|
| 173 | + ), |
|
| 174 | + new GraphQLField( |
|
| 175 | + 'isActive', |
|
| 176 | + 'Boolean', |
|
| 177 | + 'is_active', |
|
| 178 | + esc_html__('Flag indicating datetime is active', 'event_espresso') |
|
| 179 | + ), |
|
| 180 | + new GraphQLField( |
|
| 181 | + 'isExpired', |
|
| 182 | + 'Boolean', |
|
| 183 | + 'is_expired', |
|
| 184 | + esc_html__('Flag indicating datetime is expired or not', 'event_espresso') |
|
| 185 | + ), |
|
| 186 | + new GraphQLOutputField( |
|
| 187 | + 'event', |
|
| 188 | + 'Event', |
|
| 189 | + null, |
|
| 190 | + esc_html__('Event of the datetime.', 'event_espresso') |
|
| 191 | + ), |
|
| 192 | + new GraphQLInputField( |
|
| 193 | + 'eventId', |
|
| 194 | + 'Int', |
|
| 195 | + null, |
|
| 196 | + esc_html__('Event ID of the datetime.', 'event_espresso') |
|
| 197 | + ), |
|
| 198 | + new GraphQLInputField( |
|
| 199 | + 'event', |
|
| 200 | + 'ID', |
|
| 201 | + null, |
|
| 202 | + esc_html__('Globally uqinue event ID of the datetime.', 'event_espresso') |
|
| 203 | + ), |
|
| 204 | + new GraphQLInputField( |
|
| 205 | + 'tickets', |
|
| 206 | + ['list_of' => 'ID'], |
|
| 207 | + null, |
|
| 208 | + sprintf( |
|
| 209 | + '%1$s %2$s', |
|
| 210 | + esc_html__('Globally uqinue IDs of the tickets related to the datetime.', 'event_espresso'), |
|
| 211 | + esc_html__('Ignored if empty.', 'event_espresso') |
|
| 212 | + ) |
|
| 213 | + ), |
|
| 214 | + new GraphQLOutputField( |
|
| 215 | + 'relatedTickets', |
|
| 216 | + ['list_of' => 'ID'], |
|
| 217 | + null, |
|
| 218 | + esc_html__('Globally unique IDs of teh related tickets.', 'event_espresso') |
|
| 219 | + ), |
|
| 220 | + ]; |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | 223 | |
| 224 | - /** |
|
| 225 | - * @param array $inputFields The mutation input fields. |
|
| 226 | - * @throws InvalidArgumentException |
|
| 227 | - * @throws ReflectionException |
|
| 228 | - * @since $VID:$ |
|
| 229 | - */ |
|
| 230 | - public function registerMutations(array $inputFields) |
|
| 231 | - { |
|
| 232 | - // Register mutation to update an entity. |
|
| 233 | - register_graphql_mutation( |
|
| 234 | - 'update' . $this->name(), |
|
| 235 | - [ |
|
| 236 | - 'inputFields' => $inputFields, |
|
| 237 | - 'outputFields' => [ |
|
| 238 | - lcfirst($this->name()) => [ |
|
| 239 | - 'type' => $this->name(), |
|
| 240 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
| 241 | - ], |
|
| 242 | - ], |
|
| 243 | - 'mutateAndGetPayload' => DatetimeUpdate::mutateAndGetPayload($this->model, $this), |
|
| 244 | - ] |
|
| 245 | - ); |
|
| 246 | - // Register mutation to delete an entity. |
|
| 247 | - register_graphql_mutation( |
|
| 248 | - 'delete' . $this->name(), |
|
| 249 | - [ |
|
| 250 | - 'inputFields' => [ |
|
| 251 | - 'id' => $inputFields['id'], |
|
| 252 | - 'deletePermanently' => [ |
|
| 253 | - 'type' => 'Boolean', |
|
| 254 | - 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
| 255 | - ], |
|
| 256 | - ], |
|
| 257 | - 'outputFields' => [ |
|
| 258 | - lcfirst($this->name()) => [ |
|
| 259 | - 'type' => $this->name(), |
|
| 260 | - 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
| 261 | - 'resolve' => static function ($payload) { |
|
| 262 | - $deleted = (object) $payload['deleted']; |
|
| 224 | + /** |
|
| 225 | + * @param array $inputFields The mutation input fields. |
|
| 226 | + * @throws InvalidArgumentException |
|
| 227 | + * @throws ReflectionException |
|
| 228 | + * @since $VID:$ |
|
| 229 | + */ |
|
| 230 | + public function registerMutations(array $inputFields) |
|
| 231 | + { |
|
| 232 | + // Register mutation to update an entity. |
|
| 233 | + register_graphql_mutation( |
|
| 234 | + 'update' . $this->name(), |
|
| 235 | + [ |
|
| 236 | + 'inputFields' => $inputFields, |
|
| 237 | + 'outputFields' => [ |
|
| 238 | + lcfirst($this->name()) => [ |
|
| 239 | + 'type' => $this->name(), |
|
| 240 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
| 241 | + ], |
|
| 242 | + ], |
|
| 243 | + 'mutateAndGetPayload' => DatetimeUpdate::mutateAndGetPayload($this->model, $this), |
|
| 244 | + ] |
|
| 245 | + ); |
|
| 246 | + // Register mutation to delete an entity. |
|
| 247 | + register_graphql_mutation( |
|
| 248 | + 'delete' . $this->name(), |
|
| 249 | + [ |
|
| 250 | + 'inputFields' => [ |
|
| 251 | + 'id' => $inputFields['id'], |
|
| 252 | + 'deletePermanently' => [ |
|
| 253 | + 'type' => 'Boolean', |
|
| 254 | + 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
| 255 | + ], |
|
| 256 | + ], |
|
| 257 | + 'outputFields' => [ |
|
| 258 | + lcfirst($this->name()) => [ |
|
| 259 | + 'type' => $this->name(), |
|
| 260 | + 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
| 261 | + 'resolve' => static function ($payload) { |
|
| 262 | + $deleted = (object) $payload['deleted']; |
|
| 263 | 263 | |
| 264 | - return ! empty($deleted) ? $deleted : null; |
|
| 265 | - }, |
|
| 266 | - ], |
|
| 267 | - ], |
|
| 268 | - 'mutateAndGetPayload' => DatetimeDelete::mutateAndGetPayload($this->model, $this), |
|
| 269 | - ] |
|
| 270 | - ); |
|
| 264 | + return ! empty($deleted) ? $deleted : null; |
|
| 265 | + }, |
|
| 266 | + ], |
|
| 267 | + ], |
|
| 268 | + 'mutateAndGetPayload' => DatetimeDelete::mutateAndGetPayload($this->model, $this), |
|
| 269 | + ] |
|
| 270 | + ); |
|
| 271 | 271 | |
| 272 | - // remove primary key from input. |
|
| 273 | - unset($inputFields['id']); |
|
| 274 | - // Register mutation to update an entity. |
|
| 275 | - register_graphql_mutation( |
|
| 276 | - 'create' . $this->name(), |
|
| 277 | - [ |
|
| 278 | - 'inputFields' => $inputFields, |
|
| 279 | - 'outputFields' => [ |
|
| 280 | - lcfirst($this->name()) => [ |
|
| 281 | - 'type' => $this->name(), |
|
| 282 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
| 283 | - ], |
|
| 284 | - ], |
|
| 285 | - 'mutateAndGetPayload' => DatetimeCreate::mutateAndGetPayload($this->model, $this), |
|
| 286 | - ] |
|
| 287 | - ); |
|
| 288 | - } |
|
| 272 | + // remove primary key from input. |
|
| 273 | + unset($inputFields['id']); |
|
| 274 | + // Register mutation to update an entity. |
|
| 275 | + register_graphql_mutation( |
|
| 276 | + 'create' . $this->name(), |
|
| 277 | + [ |
|
| 278 | + 'inputFields' => $inputFields, |
|
| 279 | + 'outputFields' => [ |
|
| 280 | + lcfirst($this->name()) => [ |
|
| 281 | + 'type' => $this->name(), |
|
| 282 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
| 283 | + ], |
|
| 284 | + ], |
|
| 285 | + 'mutateAndGetPayload' => DatetimeCreate::mutateAndGetPayload($this->model, $this), |
|
| 286 | + ] |
|
| 287 | + ); |
|
| 288 | + } |
|
| 289 | 289 | } |