@@ -8,17 +8,17 @@ |
||
| 8 | 8 | class DatetimeBulkUpdate extends EntityMutator |
| 9 | 9 | { |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * Defines the mutation data modification closure. |
|
| 13 | - * |
|
| 14 | - * @param EEM_Datetime $model |
|
| 15 | - * @param Datetime $type |
|
| 16 | - * @return callable |
|
| 17 | - */ |
|
| 18 | - public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type) |
|
| 19 | - { |
|
| 20 | - $entityMutator = DatetimeUpdate::mutateAndGetPayload($model, $type); |
|
| 21 | - $bulkMutator = new BulkEntityMutator($entityMutator); |
|
| 22 | - return array($bulkMutator, 'updateEntities'); |
|
| 23 | - } |
|
| 11 | + /** |
|
| 12 | + * Defines the mutation data modification closure. |
|
| 13 | + * |
|
| 14 | + * @param EEM_Datetime $model |
|
| 15 | + * @param Datetime $type |
|
| 16 | + * @return callable |
|
| 17 | + */ |
|
| 18 | + public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type) |
|
| 19 | + { |
|
| 20 | + $entityMutator = DatetimeUpdate::mutateAndGetPayload($model, $type); |
|
| 21 | + $bulkMutator = new BulkEntityMutator($entityMutator); |
|
| 22 | + return array($bulkMutator, 'updateEntities'); |
|
| 23 | + } |
|
| 24 | 24 | } |
@@ -10,69 +10,69 @@ |
||
| 10 | 10 | class BulkEntityMutator extends EntityMutator |
| 11 | 11 | { |
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * @var callable $entity_mutator . |
|
| 15 | - */ |
|
| 16 | - protected $entity_mutator; |
|
| 13 | + /** |
|
| 14 | + * @var callable $entity_mutator . |
|
| 15 | + */ |
|
| 16 | + protected $entity_mutator; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * BulkEntityMutator constructor. |
|
| 20 | - * |
|
| 21 | - * @param array $entity_mutator The mutator for an entity. |
|
| 22 | - */ |
|
| 23 | - public function __construct(callable $entity_mutator) |
|
| 24 | - { |
|
| 25 | - $this->entity_mutator = $entity_mutator; |
|
| 26 | - } |
|
| 27 | - /** |
|
| 28 | - * Bulk updates entities. |
|
| 29 | - * |
|
| 30 | - * @param array $input The input for the mutation |
|
| 31 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
| 32 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
| 33 | - * @return array |
|
| 34 | - */ |
|
| 35 | - public function updateEntities($input, AppContext $context, ResolveInfo $info) |
|
| 36 | - { |
|
| 18 | + /** |
|
| 19 | + * BulkEntityMutator constructor. |
|
| 20 | + * |
|
| 21 | + * @param array $entity_mutator The mutator for an entity. |
|
| 22 | + */ |
|
| 23 | + public function __construct(callable $entity_mutator) |
|
| 24 | + { |
|
| 25 | + $this->entity_mutator = $entity_mutator; |
|
| 26 | + } |
|
| 27 | + /** |
|
| 28 | + * Bulk updates entities. |
|
| 29 | + * |
|
| 30 | + * @param array $input The input for the mutation |
|
| 31 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
| 32 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
| 33 | + * @return array |
|
| 34 | + */ |
|
| 35 | + public function updateEntities($input, AppContext $context, ResolveInfo $info) |
|
| 36 | + { |
|
| 37 | 37 | |
| 38 | - $updated = []; |
|
| 39 | - $failed = []; |
|
| 40 | - // TODO Add meaningful error messages for every failure. |
|
| 41 | - // $errors = []; |
|
| 38 | + $updated = []; |
|
| 39 | + $failed = []; |
|
| 40 | + // TODO Add meaningful error messages for every failure. |
|
| 41 | + // $errors = []; |
|
| 42 | 42 | |
| 43 | - try { |
|
| 44 | - if (empty($input['uniqueInputs']) || !is_array($input['uniqueInputs'])) { |
|
| 45 | - throw new OutOfBoundsException( |
|
| 46 | - esc_html__('A valid input was not provided.', 'event_espresso') |
|
| 47 | - ); |
|
| 48 | - } |
|
| 43 | + try { |
|
| 44 | + if (empty($input['uniqueInputs']) || !is_array($input['uniqueInputs'])) { |
|
| 45 | + throw new OutOfBoundsException( |
|
| 46 | + esc_html__('A valid input was not provided.', 'event_espresso') |
|
| 47 | + ); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - $sharedInput = ! empty($input['sharedInput']) ? $input['sharedInput'] : []; |
|
| 50 | + $sharedInput = ! empty($input['sharedInput']) ? $input['sharedInput'] : []; |
|
| 51 | 51 | |
| 52 | - foreach ($input['uniqueInputs'] as $uniqueInput) { |
|
| 53 | - try { |
|
| 54 | - // values in $uniqueInput will override those in $sharedInput |
|
| 55 | - $finalInput = array_merge($sharedInput, $uniqueInput); |
|
| 56 | - // mutate the individual entity. |
|
| 57 | - $mutator = $this->entity_mutator; |
|
| 58 | - $mutator($finalInput, $context, $info); |
|
| 59 | - // we are here it means the update was successful. |
|
| 60 | - $updated[] = $uniqueInput['id']; |
|
| 61 | - } catch (Exception $e) { |
|
| 62 | - // sorry mate, couldn't help you :( |
|
| 63 | - $failed[] = $uniqueInput['id']; |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - } catch (Exception $exception) { |
|
| 67 | - EntityMutator::handleExceptions( |
|
| 68 | - $exception, |
|
| 69 | - esc_html__( |
|
| 70 | - 'Could not perform the update because of the following error(s)', |
|
| 71 | - 'event_espresso' |
|
| 72 | - ) |
|
| 73 | - ); |
|
| 74 | - } |
|
| 52 | + foreach ($input['uniqueInputs'] as $uniqueInput) { |
|
| 53 | + try { |
|
| 54 | + // values in $uniqueInput will override those in $sharedInput |
|
| 55 | + $finalInput = array_merge($sharedInput, $uniqueInput); |
|
| 56 | + // mutate the individual entity. |
|
| 57 | + $mutator = $this->entity_mutator; |
|
| 58 | + $mutator($finalInput, $context, $info); |
|
| 59 | + // we are here it means the update was successful. |
|
| 60 | + $updated[] = $uniqueInput['id']; |
|
| 61 | + } catch (Exception $e) { |
|
| 62 | + // sorry mate, couldn't help you :( |
|
| 63 | + $failed[] = $uniqueInput['id']; |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + } catch (Exception $exception) { |
|
| 67 | + EntityMutator::handleExceptions( |
|
| 68 | + $exception, |
|
| 69 | + esc_html__( |
|
| 70 | + 'Could not perform the update because of the following error(s)', |
|
| 71 | + 'event_espresso' |
|
| 72 | + ) |
|
| 73 | + ); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - return compact('updated', 'failed'); |
|
| 77 | - } |
|
| 76 | + return compact('updated', 'failed'); |
|
| 77 | + } |
|
| 78 | 78 | } |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | // $errors = []; |
| 42 | 42 | |
| 43 | 43 | try { |
| 44 | - if (empty($input['uniqueInputs']) || !is_array($input['uniqueInputs'])) { |
|
| 44 | + if (empty($input['uniqueInputs']) || ! is_array($input['uniqueInputs'])) { |
|
| 45 | 45 | throw new OutOfBoundsException( |
| 46 | 46 | esc_html__('A valid input was not provided.', 'event_espresso') |
| 47 | 47 | ); |
@@ -8,17 +8,17 @@ |
||
| 8 | 8 | class TicketBulkUpdate extends EntityMutator |
| 9 | 9 | { |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * Defines the mutation data modification closure. |
|
| 13 | - * |
|
| 14 | - * @param EEM_Ticket $model |
|
| 15 | - * @param Ticket $type |
|
| 16 | - * @return callable |
|
| 17 | - */ |
|
| 18 | - public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
| 19 | - { |
|
| 20 | - $entityMutator = TicketUpdate::mutateAndGetPayload($model, $type); |
|
| 21 | - $bulkMutator = new BulkEntityMutator($entityMutator); |
|
| 22 | - return array($bulkMutator, 'updateEntities'); |
|
| 23 | - } |
|
| 11 | + /** |
|
| 12 | + * Defines the mutation data modification closure. |
|
| 13 | + * |
|
| 14 | + * @param EEM_Ticket $model |
|
| 15 | + * @param Ticket $type |
|
| 16 | + * @return callable |
|
| 17 | + */ |
|
| 18 | + public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
| 19 | + { |
|
| 20 | + $entityMutator = TicketUpdate::mutateAndGetPayload($model, $type); |
|
| 21 | + $bulkMutator = new BulkEntityMutator($entityMutator); |
|
| 22 | + return array($bulkMutator, 'updateEntities'); |
|
| 23 | + } |
|
| 24 | 24 | } |
@@ -35,378 +35,378 @@ |
||
| 35 | 35 | class Datetime extends TypeBase |
| 36 | 36 | { |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * EventDate constructor. |
|
| 40 | - * |
|
| 41 | - * @param EEM_Datetime $datetime_model |
|
| 42 | - */ |
|
| 43 | - public function __construct(EEM_Datetime $datetime_model) |
|
| 44 | - { |
|
| 45 | - $this->model = $datetime_model; |
|
| 46 | - $this->setName($this->namespace . 'Datetime'); |
|
| 47 | - $this->setDescription(__('An event date', 'event_espresso')); |
|
| 48 | - $this->setIsCustomPostType(false); |
|
| 49 | - parent::__construct(); |
|
| 50 | - } |
|
| 38 | + /** |
|
| 39 | + * EventDate constructor. |
|
| 40 | + * |
|
| 41 | + * @param EEM_Datetime $datetime_model |
|
| 42 | + */ |
|
| 43 | + public function __construct(EEM_Datetime $datetime_model) |
|
| 44 | + { |
|
| 45 | + $this->model = $datetime_model; |
|
| 46 | + $this->setName($this->namespace . 'Datetime'); |
|
| 47 | + $this->setDescription(__('An event date', 'event_espresso')); |
|
| 48 | + $this->setIsCustomPostType(false); |
|
| 49 | + parent::__construct(); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * @return GraphQLFieldInterface[] |
|
| 55 | - * @since $VID:$ |
|
| 56 | - */ |
|
| 57 | - public function getFields() |
|
| 58 | - { |
|
| 59 | - $fields = [ |
|
| 60 | - new GraphQLField( |
|
| 61 | - 'id', |
|
| 62 | - ['non_null' => 'ID'], |
|
| 63 | - null, |
|
| 64 | - esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
| 65 | - ), |
|
| 66 | - new GraphQLOutputField( |
|
| 67 | - 'dbId', |
|
| 68 | - ['non_null' => 'Int'], |
|
| 69 | - 'ID', |
|
| 70 | - esc_html__('The datetime ID.', 'event_espresso') |
|
| 71 | - ), |
|
| 72 | - new GraphQLOutputField( |
|
| 73 | - 'cacheId', |
|
| 74 | - ['non_null' => 'String'], |
|
| 75 | - null, |
|
| 76 | - esc_html__('The cache ID of the object.', 'event_espresso') |
|
| 77 | - ), |
|
| 78 | - new GraphQLField( |
|
| 79 | - 'capacity', |
|
| 80 | - 'Int', |
|
| 81 | - 'reg_limit', |
|
| 82 | - esc_html__('Registration Limit for this time', 'event_espresso'), |
|
| 83 | - [$this, 'parseInfiniteValue'] |
|
| 84 | - ), |
|
| 85 | - new GraphQLField( |
|
| 86 | - 'description', |
|
| 87 | - 'String', |
|
| 88 | - 'description', |
|
| 89 | - esc_html__('Description for Datetime', 'event_espresso') |
|
| 90 | - ), |
|
| 91 | - new GraphQLField( |
|
| 92 | - 'endDate', |
|
| 93 | - 'String', |
|
| 94 | - 'end_date_and_time', |
|
| 95 | - esc_html__('End date and time of the Event', 'event_espresso'), |
|
| 96 | - [$this, 'formatDatetime'] |
|
| 97 | - ), |
|
| 98 | - new GraphQLOutputField( |
|
| 99 | - 'event', |
|
| 100 | - $this->namespace . 'Event', |
|
| 101 | - null, |
|
| 102 | - esc_html__('Event of the datetime.', 'event_espresso') |
|
| 103 | - ), |
|
| 104 | - new GraphQLInputField( |
|
| 105 | - 'event', |
|
| 106 | - 'ID', |
|
| 107 | - null, |
|
| 108 | - esc_html__('Globally unique event ID of the datetime.', 'event_espresso') |
|
| 109 | - ), |
|
| 110 | - new GraphQLInputField( |
|
| 111 | - 'eventId', |
|
| 112 | - 'Int', |
|
| 113 | - null, |
|
| 114 | - esc_html__('Event ID of the datetime.', 'event_espresso') |
|
| 115 | - ), |
|
| 116 | - new GraphQLOutputField( |
|
| 117 | - 'isActive', |
|
| 118 | - 'Boolean', |
|
| 119 | - 'is_active', |
|
| 120 | - esc_html__('Flag indicating datetime is active', 'event_espresso') |
|
| 121 | - ), |
|
| 122 | - new GraphQLOutputField( |
|
| 123 | - 'isExpired', |
|
| 124 | - 'Boolean', |
|
| 125 | - 'is_expired', |
|
| 126 | - esc_html__('Flag indicating datetime is expired or not', 'event_espresso') |
|
| 127 | - ), |
|
| 128 | - new GraphQLField( |
|
| 129 | - 'isPrimary', |
|
| 130 | - 'Boolean', |
|
| 131 | - 'is_primary', |
|
| 132 | - esc_html__('Flag indicating datetime is primary one for event', 'event_espresso') |
|
| 133 | - ), |
|
| 134 | - new GraphQLOutputField( |
|
| 135 | - 'isSoldOut', |
|
| 136 | - 'Boolean', |
|
| 137 | - 'sold_out', |
|
| 138 | - esc_html__( |
|
| 139 | - 'Flag indicating whether the tickets sold for this datetime, met or exceed the registration limit', |
|
| 140 | - 'event_espresso' |
|
| 141 | - ) |
|
| 142 | - ), |
|
| 143 | - new GraphQLField( |
|
| 144 | - 'isTrashed', |
|
| 145 | - 'Boolean', |
|
| 146 | - null, |
|
| 147 | - esc_html__('Flag indicating datetime has been trashed.', 'event_espresso'), |
|
| 148 | - null, |
|
| 149 | - [$this, 'getIsTrashed'] |
|
| 150 | - ), |
|
| 151 | - new GraphQLOutputField( |
|
| 152 | - 'isUpcoming', |
|
| 153 | - 'Boolean', |
|
| 154 | - 'is_upcoming', |
|
| 155 | - esc_html__('Whether the date is upcoming', 'event_espresso') |
|
| 156 | - ), |
|
| 157 | - new GraphQLOutputField( |
|
| 158 | - 'length', |
|
| 159 | - 'Int', |
|
| 160 | - 'length', |
|
| 161 | - esc_html__('The length of the event (start to end time) in seconds', 'event_espresso') |
|
| 162 | - ), |
|
| 163 | - new GraphQLField( |
|
| 164 | - 'name', |
|
| 165 | - 'String', |
|
| 166 | - 'name', |
|
| 167 | - esc_html__('Datetime Name', 'event_espresso') |
|
| 168 | - ), |
|
| 169 | - new GraphQLField( |
|
| 170 | - 'order', |
|
| 171 | - 'Int', |
|
| 172 | - 'order', |
|
| 173 | - esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
| 174 | - ), |
|
| 175 | - new GraphQLOutputField( |
|
| 176 | - 'parent', |
|
| 177 | - $this->name(), |
|
| 178 | - null, |
|
| 179 | - esc_html__('The parent datetime of the current datetime', 'event_espresso') |
|
| 180 | - ), |
|
| 181 | - new GraphQLInputField( |
|
| 182 | - 'parent', |
|
| 183 | - 'ID', |
|
| 184 | - null, |
|
| 185 | - esc_html__('The parent datetime ID', 'event_espresso') |
|
| 186 | - ), |
|
| 187 | - new GraphQLField( |
|
| 188 | - 'reserved', |
|
| 189 | - 'Int', |
|
| 190 | - 'reserved', |
|
| 191 | - esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso') |
|
| 192 | - ), |
|
| 193 | - new GraphQLField( |
|
| 194 | - 'startDate', |
|
| 195 | - 'String', |
|
| 196 | - 'start_date_and_time', |
|
| 197 | - esc_html__('Start date and time of the Event', 'event_espresso'), |
|
| 198 | - [$this, 'formatDatetime'] |
|
| 199 | - ), |
|
| 200 | - new GraphQLField( |
|
| 201 | - 'sold', |
|
| 202 | - 'Int', |
|
| 203 | - 'sold', |
|
| 204 | - esc_html__('How many sales for this Datetime that have occurred', 'event_espresso') |
|
| 205 | - ), |
|
| 206 | - new GraphQLOutputField( |
|
| 207 | - 'status', |
|
| 208 | - $this->namespace . 'DatetimeStatusEnum', |
|
| 209 | - 'get_active_status', |
|
| 210 | - esc_html__('Datetime status', 'event_espresso') |
|
| 211 | - ), |
|
| 212 | - new GraphQLInputField( |
|
| 213 | - 'tickets', |
|
| 214 | - ['list_of' => 'ID'], |
|
| 215 | - null, |
|
| 216 | - sprintf( |
|
| 217 | - '%1$s %2$s', |
|
| 218 | - esc_html__('Globally unique IDs of the tickets related to the datetime.', 'event_espresso'), |
|
| 219 | - esc_html__('Ignored if empty.', 'event_espresso') |
|
| 220 | - ) |
|
| 221 | - ), |
|
| 222 | - ]; |
|
| 53 | + /** |
|
| 54 | + * @return GraphQLFieldInterface[] |
|
| 55 | + * @since $VID:$ |
|
| 56 | + */ |
|
| 57 | + public function getFields() |
|
| 58 | + { |
|
| 59 | + $fields = [ |
|
| 60 | + new GraphQLField( |
|
| 61 | + 'id', |
|
| 62 | + ['non_null' => 'ID'], |
|
| 63 | + null, |
|
| 64 | + esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
| 65 | + ), |
|
| 66 | + new GraphQLOutputField( |
|
| 67 | + 'dbId', |
|
| 68 | + ['non_null' => 'Int'], |
|
| 69 | + 'ID', |
|
| 70 | + esc_html__('The datetime ID.', 'event_espresso') |
|
| 71 | + ), |
|
| 72 | + new GraphQLOutputField( |
|
| 73 | + 'cacheId', |
|
| 74 | + ['non_null' => 'String'], |
|
| 75 | + null, |
|
| 76 | + esc_html__('The cache ID of the object.', 'event_espresso') |
|
| 77 | + ), |
|
| 78 | + new GraphQLField( |
|
| 79 | + 'capacity', |
|
| 80 | + 'Int', |
|
| 81 | + 'reg_limit', |
|
| 82 | + esc_html__('Registration Limit for this time', 'event_espresso'), |
|
| 83 | + [$this, 'parseInfiniteValue'] |
|
| 84 | + ), |
|
| 85 | + new GraphQLField( |
|
| 86 | + 'description', |
|
| 87 | + 'String', |
|
| 88 | + 'description', |
|
| 89 | + esc_html__('Description for Datetime', 'event_espresso') |
|
| 90 | + ), |
|
| 91 | + new GraphQLField( |
|
| 92 | + 'endDate', |
|
| 93 | + 'String', |
|
| 94 | + 'end_date_and_time', |
|
| 95 | + esc_html__('End date and time of the Event', 'event_espresso'), |
|
| 96 | + [$this, 'formatDatetime'] |
|
| 97 | + ), |
|
| 98 | + new GraphQLOutputField( |
|
| 99 | + 'event', |
|
| 100 | + $this->namespace . 'Event', |
|
| 101 | + null, |
|
| 102 | + esc_html__('Event of the datetime.', 'event_espresso') |
|
| 103 | + ), |
|
| 104 | + new GraphQLInputField( |
|
| 105 | + 'event', |
|
| 106 | + 'ID', |
|
| 107 | + null, |
|
| 108 | + esc_html__('Globally unique event ID of the datetime.', 'event_espresso') |
|
| 109 | + ), |
|
| 110 | + new GraphQLInputField( |
|
| 111 | + 'eventId', |
|
| 112 | + 'Int', |
|
| 113 | + null, |
|
| 114 | + esc_html__('Event ID of the datetime.', 'event_espresso') |
|
| 115 | + ), |
|
| 116 | + new GraphQLOutputField( |
|
| 117 | + 'isActive', |
|
| 118 | + 'Boolean', |
|
| 119 | + 'is_active', |
|
| 120 | + esc_html__('Flag indicating datetime is active', 'event_espresso') |
|
| 121 | + ), |
|
| 122 | + new GraphQLOutputField( |
|
| 123 | + 'isExpired', |
|
| 124 | + 'Boolean', |
|
| 125 | + 'is_expired', |
|
| 126 | + esc_html__('Flag indicating datetime is expired or not', 'event_espresso') |
|
| 127 | + ), |
|
| 128 | + new GraphQLField( |
|
| 129 | + 'isPrimary', |
|
| 130 | + 'Boolean', |
|
| 131 | + 'is_primary', |
|
| 132 | + esc_html__('Flag indicating datetime is primary one for event', 'event_espresso') |
|
| 133 | + ), |
|
| 134 | + new GraphQLOutputField( |
|
| 135 | + 'isSoldOut', |
|
| 136 | + 'Boolean', |
|
| 137 | + 'sold_out', |
|
| 138 | + esc_html__( |
|
| 139 | + 'Flag indicating whether the tickets sold for this datetime, met or exceed the registration limit', |
|
| 140 | + 'event_espresso' |
|
| 141 | + ) |
|
| 142 | + ), |
|
| 143 | + new GraphQLField( |
|
| 144 | + 'isTrashed', |
|
| 145 | + 'Boolean', |
|
| 146 | + null, |
|
| 147 | + esc_html__('Flag indicating datetime has been trashed.', 'event_espresso'), |
|
| 148 | + null, |
|
| 149 | + [$this, 'getIsTrashed'] |
|
| 150 | + ), |
|
| 151 | + new GraphQLOutputField( |
|
| 152 | + 'isUpcoming', |
|
| 153 | + 'Boolean', |
|
| 154 | + 'is_upcoming', |
|
| 155 | + esc_html__('Whether the date is upcoming', 'event_espresso') |
|
| 156 | + ), |
|
| 157 | + new GraphQLOutputField( |
|
| 158 | + 'length', |
|
| 159 | + 'Int', |
|
| 160 | + 'length', |
|
| 161 | + esc_html__('The length of the event (start to end time) in seconds', 'event_espresso') |
|
| 162 | + ), |
|
| 163 | + new GraphQLField( |
|
| 164 | + 'name', |
|
| 165 | + 'String', |
|
| 166 | + 'name', |
|
| 167 | + esc_html__('Datetime Name', 'event_espresso') |
|
| 168 | + ), |
|
| 169 | + new GraphQLField( |
|
| 170 | + 'order', |
|
| 171 | + 'Int', |
|
| 172 | + 'order', |
|
| 173 | + esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
| 174 | + ), |
|
| 175 | + new GraphQLOutputField( |
|
| 176 | + 'parent', |
|
| 177 | + $this->name(), |
|
| 178 | + null, |
|
| 179 | + esc_html__('The parent datetime of the current datetime', 'event_espresso') |
|
| 180 | + ), |
|
| 181 | + new GraphQLInputField( |
|
| 182 | + 'parent', |
|
| 183 | + 'ID', |
|
| 184 | + null, |
|
| 185 | + esc_html__('The parent datetime ID', 'event_espresso') |
|
| 186 | + ), |
|
| 187 | + new GraphQLField( |
|
| 188 | + 'reserved', |
|
| 189 | + 'Int', |
|
| 190 | + 'reserved', |
|
| 191 | + esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso') |
|
| 192 | + ), |
|
| 193 | + new GraphQLField( |
|
| 194 | + 'startDate', |
|
| 195 | + 'String', |
|
| 196 | + 'start_date_and_time', |
|
| 197 | + esc_html__('Start date and time of the Event', 'event_espresso'), |
|
| 198 | + [$this, 'formatDatetime'] |
|
| 199 | + ), |
|
| 200 | + new GraphQLField( |
|
| 201 | + 'sold', |
|
| 202 | + 'Int', |
|
| 203 | + 'sold', |
|
| 204 | + esc_html__('How many sales for this Datetime that have occurred', 'event_espresso') |
|
| 205 | + ), |
|
| 206 | + new GraphQLOutputField( |
|
| 207 | + 'status', |
|
| 208 | + $this->namespace . 'DatetimeStatusEnum', |
|
| 209 | + 'get_active_status', |
|
| 210 | + esc_html__('Datetime status', 'event_espresso') |
|
| 211 | + ), |
|
| 212 | + new GraphQLInputField( |
|
| 213 | + 'tickets', |
|
| 214 | + ['list_of' => 'ID'], |
|
| 215 | + null, |
|
| 216 | + sprintf( |
|
| 217 | + '%1$s %2$s', |
|
| 218 | + esc_html__('Globally unique IDs of the tickets related to the datetime.', 'event_espresso'), |
|
| 219 | + esc_html__('Ignored if empty.', 'event_espresso') |
|
| 220 | + ) |
|
| 221 | + ), |
|
| 222 | + ]; |
|
| 223 | 223 | |
| 224 | - return apply_filters( |
|
| 225 | - 'FHEE__EventEspresso_core_domain_services_graphql_types__datetime_fields', |
|
| 226 | - $fields, |
|
| 227 | - $this->name, |
|
| 228 | - $this->model |
|
| 229 | - ); |
|
| 230 | - } |
|
| 224 | + return apply_filters( |
|
| 225 | + 'FHEE__EventEspresso_core_domain_services_graphql_types__datetime_fields', |
|
| 226 | + $fields, |
|
| 227 | + $this->name, |
|
| 228 | + $this->model |
|
| 229 | + ); |
|
| 230 | + } |
|
| 231 | 231 | |
| 232 | 232 | |
| 233 | - /** |
|
| 234 | - * @param EE_Datetime $source The source that's passed down the GraphQL queries |
|
| 235 | - * @param array $args The inputArgs on the field |
|
| 236 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
| 237 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
| 238 | - * @return string |
|
| 239 | - * @throws Exception |
|
| 240 | - * @throws InvalidArgumentException |
|
| 241 | - * @throws InvalidDataTypeException |
|
| 242 | - * @throws InvalidInterfaceException |
|
| 243 | - * @throws ReflectionException |
|
| 244 | - * @throws UserError |
|
| 245 | - * @throws UnexpectedEntityException |
|
| 246 | - * @since $VID:$ |
|
| 247 | - */ |
|
| 248 | - public function getIsTrashed(EE_Datetime $source, array $args, AppContext $context, ResolveInfo $info) |
|
| 249 | - { |
|
| 250 | - return (bool) $source->get('DTT_deleted'); |
|
| 251 | - } |
|
| 233 | + /** |
|
| 234 | + * @param EE_Datetime $source The source that's passed down the GraphQL queries |
|
| 235 | + * @param array $args The inputArgs on the field |
|
| 236 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
| 237 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
| 238 | + * @return string |
|
| 239 | + * @throws Exception |
|
| 240 | + * @throws InvalidArgumentException |
|
| 241 | + * @throws InvalidDataTypeException |
|
| 242 | + * @throws InvalidInterfaceException |
|
| 243 | + * @throws ReflectionException |
|
| 244 | + * @throws UserError |
|
| 245 | + * @throws UnexpectedEntityException |
|
| 246 | + * @since $VID:$ |
|
| 247 | + */ |
|
| 248 | + public function getIsTrashed(EE_Datetime $source, array $args, AppContext $context, ResolveInfo $info) |
|
| 249 | + { |
|
| 250 | + return (bool) $source->get('DTT_deleted'); |
|
| 251 | + } |
|
| 252 | 252 | |
| 253 | - /** |
|
| 254 | - * Return the base mutation config for bulk update. |
|
| 255 | - * |
|
| 256 | - * @param string $base_input |
|
| 257 | - * @return array |
|
| 258 | - */ |
|
| 259 | - public static function bulkUpdateBaseConfig($base_input) |
|
| 260 | - { |
|
| 261 | - return [ |
|
| 262 | - 'inputFields' => [ |
|
| 263 | - /** |
|
| 264 | - * represents the input that is unique for each entity |
|
| 265 | - * e.g. dates may be unique for dateimes and tickets |
|
| 266 | - */ |
|
| 267 | - 'uniqueInputs' => [ |
|
| 268 | - 'type' => [ |
|
| 269 | - 'non_null' => ['list_of' => $base_input], |
|
| 270 | - ], |
|
| 271 | - 'description' => esc_html__( |
|
| 272 | - 'List of unique inputs for each entity in bulk update', |
|
| 273 | - 'event_espresso' |
|
| 274 | - ), |
|
| 275 | - ], |
|
| 276 | - /** |
|
| 277 | - * represents the common input for all entities |
|
| 278 | - * e.g. capacity or quantity may be same for all dates/tickets |
|
| 279 | - */ |
|
| 280 | - 'sharedInput' => [ |
|
| 281 | - 'type' => $base_input, |
|
| 282 | - 'description' => esc_html__( |
|
| 283 | - 'Shared input for all entities in bulk update', |
|
| 284 | - 'event_espresso' |
|
| 285 | - ), |
|
| 286 | - ], |
|
| 287 | - ], |
|
| 288 | - 'outputFields' => [ |
|
| 289 | - 'updated' => [ |
|
| 290 | - 'type' => ['list_of' => 'ID'], |
|
| 291 | - ], |
|
| 292 | - 'failed' => [ |
|
| 293 | - 'type' => ['list_of' => 'ID'], |
|
| 294 | - ], |
|
| 295 | - ], |
|
| 296 | - ]; |
|
| 297 | - } |
|
| 253 | + /** |
|
| 254 | + * Return the base mutation config for bulk update. |
|
| 255 | + * |
|
| 256 | + * @param string $base_input |
|
| 257 | + * @return array |
|
| 258 | + */ |
|
| 259 | + public static function bulkUpdateBaseConfig($base_input) |
|
| 260 | + { |
|
| 261 | + return [ |
|
| 262 | + 'inputFields' => [ |
|
| 263 | + /** |
|
| 264 | + * represents the input that is unique for each entity |
|
| 265 | + * e.g. dates may be unique for dateimes and tickets |
|
| 266 | + */ |
|
| 267 | + 'uniqueInputs' => [ |
|
| 268 | + 'type' => [ |
|
| 269 | + 'non_null' => ['list_of' => $base_input], |
|
| 270 | + ], |
|
| 271 | + 'description' => esc_html__( |
|
| 272 | + 'List of unique inputs for each entity in bulk update', |
|
| 273 | + 'event_espresso' |
|
| 274 | + ), |
|
| 275 | + ], |
|
| 276 | + /** |
|
| 277 | + * represents the common input for all entities |
|
| 278 | + * e.g. capacity or quantity may be same for all dates/tickets |
|
| 279 | + */ |
|
| 280 | + 'sharedInput' => [ |
|
| 281 | + 'type' => $base_input, |
|
| 282 | + 'description' => esc_html__( |
|
| 283 | + 'Shared input for all entities in bulk update', |
|
| 284 | + 'event_espresso' |
|
| 285 | + ), |
|
| 286 | + ], |
|
| 287 | + ], |
|
| 288 | + 'outputFields' => [ |
|
| 289 | + 'updated' => [ |
|
| 290 | + 'type' => ['list_of' => 'ID'], |
|
| 291 | + ], |
|
| 292 | + 'failed' => [ |
|
| 293 | + 'type' => ['list_of' => 'ID'], |
|
| 294 | + ], |
|
| 295 | + ], |
|
| 296 | + ]; |
|
| 297 | + } |
|
| 298 | 298 | |
| 299 | 299 | |
| 300 | - /** |
|
| 301 | - * @param array $inputFields The mutation input fields. |
|
| 302 | - * @throws InvalidArgumentException |
|
| 303 | - * @throws ReflectionException |
|
| 304 | - * @since $VID:$ |
|
| 305 | - */ |
|
| 306 | - public function registerMutations(array $inputFields) |
|
| 307 | - { |
|
| 308 | - register_graphql_input_type( |
|
| 309 | - 'Update' . $this->name() . 'BaseInput', |
|
| 310 | - [ |
|
| 311 | - 'fields' => $inputFields, |
|
| 312 | - ] |
|
| 313 | - ); |
|
| 314 | - // Register mutation to update an entity. |
|
| 315 | - register_graphql_mutation( |
|
| 316 | - 'update' . $this->name(), |
|
| 317 | - [ |
|
| 318 | - 'inputFields' => $inputFields, |
|
| 319 | - 'outputFields' => [ |
|
| 320 | - lcfirst($this->name()) => [ |
|
| 321 | - 'type' => $this->name(), |
|
| 322 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
| 323 | - ], |
|
| 324 | - ], |
|
| 325 | - 'mutateAndGetPayload' => DatetimeUpdate::mutateAndGetPayload($this->model, $this), |
|
| 326 | - ] |
|
| 327 | - ); |
|
| 328 | - $base_input = 'Update' . $this->name() . 'BaseInput'; |
|
| 329 | - // Register mutation to update an entity. |
|
| 330 | - register_graphql_mutation( |
|
| 331 | - 'bulkUpdate' . $this->name(), |
|
| 332 | - array_merge( |
|
| 333 | - Datetime::bulkUpdateBaseConfig($base_input), |
|
| 334 | - [ |
|
| 335 | - 'mutateAndGetPayload' => DatetimeBulkUpdate::mutateAndGetPayload($this->model, $this), |
|
| 336 | - ] |
|
| 337 | - ) |
|
| 338 | - ); |
|
| 339 | - // Register mutation to delete an entity. |
|
| 340 | - register_graphql_mutation( |
|
| 341 | - 'delete' . $this->name(), |
|
| 342 | - [ |
|
| 343 | - 'inputFields' => [ |
|
| 344 | - 'id' => $inputFields['id'], |
|
| 345 | - 'deletePermanently' => [ |
|
| 346 | - 'type' => 'Boolean', |
|
| 347 | - 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
| 348 | - ], |
|
| 349 | - ], |
|
| 350 | - 'outputFields' => [ |
|
| 351 | - lcfirst($this->name()) => [ |
|
| 352 | - 'type' => $this->name(), |
|
| 353 | - 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
| 354 | - 'resolve' => static function ($payload) { |
|
| 355 | - $deleted = (object) $payload['deleted']; |
|
| 300 | + /** |
|
| 301 | + * @param array $inputFields The mutation input fields. |
|
| 302 | + * @throws InvalidArgumentException |
|
| 303 | + * @throws ReflectionException |
|
| 304 | + * @since $VID:$ |
|
| 305 | + */ |
|
| 306 | + public function registerMutations(array $inputFields) |
|
| 307 | + { |
|
| 308 | + register_graphql_input_type( |
|
| 309 | + 'Update' . $this->name() . 'BaseInput', |
|
| 310 | + [ |
|
| 311 | + 'fields' => $inputFields, |
|
| 312 | + ] |
|
| 313 | + ); |
|
| 314 | + // Register mutation to update an entity. |
|
| 315 | + register_graphql_mutation( |
|
| 316 | + 'update' . $this->name(), |
|
| 317 | + [ |
|
| 318 | + 'inputFields' => $inputFields, |
|
| 319 | + 'outputFields' => [ |
|
| 320 | + lcfirst($this->name()) => [ |
|
| 321 | + 'type' => $this->name(), |
|
| 322 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
| 323 | + ], |
|
| 324 | + ], |
|
| 325 | + 'mutateAndGetPayload' => DatetimeUpdate::mutateAndGetPayload($this->model, $this), |
|
| 326 | + ] |
|
| 327 | + ); |
|
| 328 | + $base_input = 'Update' . $this->name() . 'BaseInput'; |
|
| 329 | + // Register mutation to update an entity. |
|
| 330 | + register_graphql_mutation( |
|
| 331 | + 'bulkUpdate' . $this->name(), |
|
| 332 | + array_merge( |
|
| 333 | + Datetime::bulkUpdateBaseConfig($base_input), |
|
| 334 | + [ |
|
| 335 | + 'mutateAndGetPayload' => DatetimeBulkUpdate::mutateAndGetPayload($this->model, $this), |
|
| 336 | + ] |
|
| 337 | + ) |
|
| 338 | + ); |
|
| 339 | + // Register mutation to delete an entity. |
|
| 340 | + register_graphql_mutation( |
|
| 341 | + 'delete' . $this->name(), |
|
| 342 | + [ |
|
| 343 | + 'inputFields' => [ |
|
| 344 | + 'id' => $inputFields['id'], |
|
| 345 | + 'deletePermanently' => [ |
|
| 346 | + 'type' => 'Boolean', |
|
| 347 | + 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
| 348 | + ], |
|
| 349 | + ], |
|
| 350 | + 'outputFields' => [ |
|
| 351 | + lcfirst($this->name()) => [ |
|
| 352 | + 'type' => $this->name(), |
|
| 353 | + 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
| 354 | + 'resolve' => static function ($payload) { |
|
| 355 | + $deleted = (object) $payload['deleted']; |
|
| 356 | 356 | |
| 357 | - return ! empty($deleted) ? $deleted : null; |
|
| 358 | - }, |
|
| 359 | - ], |
|
| 360 | - ], |
|
| 361 | - 'mutateAndGetPayload' => DatetimeDelete::mutateAndGetPayload($this->model, $this), |
|
| 362 | - ] |
|
| 363 | - ); |
|
| 357 | + return ! empty($deleted) ? $deleted : null; |
|
| 358 | + }, |
|
| 359 | + ], |
|
| 360 | + ], |
|
| 361 | + 'mutateAndGetPayload' => DatetimeDelete::mutateAndGetPayload($this->model, $this), |
|
| 362 | + ] |
|
| 363 | + ); |
|
| 364 | 364 | |
| 365 | - // remove primary key from input. |
|
| 366 | - unset($inputFields['id']); |
|
| 367 | - // Register mutation to update an entity. |
|
| 368 | - register_graphql_mutation( |
|
| 369 | - 'create' . $this->name(), |
|
| 370 | - [ |
|
| 371 | - 'inputFields' => $inputFields, |
|
| 372 | - 'outputFields' => [ |
|
| 373 | - lcfirst($this->name()) => [ |
|
| 374 | - 'type' => $this->name(), |
|
| 375 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
| 376 | - ], |
|
| 377 | - ], |
|
| 378 | - 'mutateAndGetPayload' => DatetimeCreate::mutateAndGetPayload($this->model, $this), |
|
| 379 | - ] |
|
| 380 | - ); |
|
| 365 | + // remove primary key from input. |
|
| 366 | + unset($inputFields['id']); |
|
| 367 | + // Register mutation to update an entity. |
|
| 368 | + register_graphql_mutation( |
|
| 369 | + 'create' . $this->name(), |
|
| 370 | + [ |
|
| 371 | + 'inputFields' => $inputFields, |
|
| 372 | + 'outputFields' => [ |
|
| 373 | + lcfirst($this->name()) => [ |
|
| 374 | + 'type' => $this->name(), |
|
| 375 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
| 376 | + ], |
|
| 377 | + ], |
|
| 378 | + 'mutateAndGetPayload' => DatetimeCreate::mutateAndGetPayload($this->model, $this), |
|
| 379 | + ] |
|
| 380 | + ); |
|
| 381 | 381 | |
| 382 | - // Register mutation to update an entity. |
|
| 383 | - register_graphql_mutation( |
|
| 384 | - 'reorder' . $this->namespace . 'Entities', |
|
| 385 | - [ |
|
| 386 | - 'inputFields' => [ |
|
| 387 | - 'entityIds' => [ |
|
| 388 | - 'type' => [ |
|
| 389 | - 'non_null' => ['list_of' => 'ID'], |
|
| 390 | - ], |
|
| 391 | - 'description' => esc_html__('The reordered list of entity GUIDs.', 'event_espresso'), |
|
| 392 | - ], |
|
| 393 | - 'entityType' => [ |
|
| 394 | - 'type' => [ |
|
| 395 | - 'non_null' => $this->namespace . 'ModelNameEnum', |
|
| 396 | - ], |
|
| 397 | - 'description' => esc_html__('The entity type for the IDs', 'event_espresso'), |
|
| 398 | - ], |
|
| 399 | - ], |
|
| 400 | - 'outputFields' => [ |
|
| 401 | - 'ok' => [ |
|
| 402 | - 'type' => 'Boolean', |
|
| 403 | - 'resolve' => function ($payload) { |
|
| 404 | - return (bool) $payload['ok']; |
|
| 405 | - }, |
|
| 406 | - ], |
|
| 407 | - ], |
|
| 408 | - 'mutateAndGetPayload' => EntityReorder::mutateAndGetPayload(), |
|
| 409 | - ] |
|
| 410 | - ); |
|
| 411 | - } |
|
| 382 | + // Register mutation to update an entity. |
|
| 383 | + register_graphql_mutation( |
|
| 384 | + 'reorder' . $this->namespace . 'Entities', |
|
| 385 | + [ |
|
| 386 | + 'inputFields' => [ |
|
| 387 | + 'entityIds' => [ |
|
| 388 | + 'type' => [ |
|
| 389 | + 'non_null' => ['list_of' => 'ID'], |
|
| 390 | + ], |
|
| 391 | + 'description' => esc_html__('The reordered list of entity GUIDs.', 'event_espresso'), |
|
| 392 | + ], |
|
| 393 | + 'entityType' => [ |
|
| 394 | + 'type' => [ |
|
| 395 | + 'non_null' => $this->namespace . 'ModelNameEnum', |
|
| 396 | + ], |
|
| 397 | + 'description' => esc_html__('The entity type for the IDs', 'event_espresso'), |
|
| 398 | + ], |
|
| 399 | + ], |
|
| 400 | + 'outputFields' => [ |
|
| 401 | + 'ok' => [ |
|
| 402 | + 'type' => 'Boolean', |
|
| 403 | + 'resolve' => function ($payload) { |
|
| 404 | + return (bool) $payload['ok']; |
|
| 405 | + }, |
|
| 406 | + ], |
|
| 407 | + ], |
|
| 408 | + 'mutateAndGetPayload' => EntityReorder::mutateAndGetPayload(), |
|
| 409 | + ] |
|
| 410 | + ); |
|
| 411 | + } |
|
| 412 | 412 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | public function __construct(EEM_Datetime $datetime_model) |
| 44 | 44 | { |
| 45 | 45 | $this->model = $datetime_model; |
| 46 | - $this->setName($this->namespace . 'Datetime'); |
|
| 46 | + $this->setName($this->namespace.'Datetime'); |
|
| 47 | 47 | $this->setDescription(__('An event date', 'event_espresso')); |
| 48 | 48 | $this->setIsCustomPostType(false); |
| 49 | 49 | parent::__construct(); |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | ), |
| 98 | 98 | new GraphQLOutputField( |
| 99 | 99 | 'event', |
| 100 | - $this->namespace . 'Event', |
|
| 100 | + $this->namespace.'Event', |
|
| 101 | 101 | null, |
| 102 | 102 | esc_html__('Event of the datetime.', 'event_espresso') |
| 103 | 103 | ), |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | ), |
| 206 | 206 | new GraphQLOutputField( |
| 207 | 207 | 'status', |
| 208 | - $this->namespace . 'DatetimeStatusEnum', |
|
| 208 | + $this->namespace.'DatetimeStatusEnum', |
|
| 209 | 209 | 'get_active_status', |
| 210 | 210 | esc_html__('Datetime status', 'event_espresso') |
| 211 | 211 | ), |
@@ -306,14 +306,14 @@ discard block |
||
| 306 | 306 | public function registerMutations(array $inputFields) |
| 307 | 307 | { |
| 308 | 308 | register_graphql_input_type( |
| 309 | - 'Update' . $this->name() . 'BaseInput', |
|
| 309 | + 'Update'.$this->name().'BaseInput', |
|
| 310 | 310 | [ |
| 311 | 311 | 'fields' => $inputFields, |
| 312 | 312 | ] |
| 313 | 313 | ); |
| 314 | 314 | // Register mutation to update an entity. |
| 315 | 315 | register_graphql_mutation( |
| 316 | - 'update' . $this->name(), |
|
| 316 | + 'update'.$this->name(), |
|
| 317 | 317 | [ |
| 318 | 318 | 'inputFields' => $inputFields, |
| 319 | 319 | 'outputFields' => [ |
@@ -325,10 +325,10 @@ discard block |
||
| 325 | 325 | 'mutateAndGetPayload' => DatetimeUpdate::mutateAndGetPayload($this->model, $this), |
| 326 | 326 | ] |
| 327 | 327 | ); |
| 328 | - $base_input = 'Update' . $this->name() . 'BaseInput'; |
|
| 328 | + $base_input = 'Update'.$this->name().'BaseInput'; |
|
| 329 | 329 | // Register mutation to update an entity. |
| 330 | 330 | register_graphql_mutation( |
| 331 | - 'bulkUpdate' . $this->name(), |
|
| 331 | + 'bulkUpdate'.$this->name(), |
|
| 332 | 332 | array_merge( |
| 333 | 333 | Datetime::bulkUpdateBaseConfig($base_input), |
| 334 | 334 | [ |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | ); |
| 339 | 339 | // Register mutation to delete an entity. |
| 340 | 340 | register_graphql_mutation( |
| 341 | - 'delete' . $this->name(), |
|
| 341 | + 'delete'.$this->name(), |
|
| 342 | 342 | [ |
| 343 | 343 | 'inputFields' => [ |
| 344 | 344 | 'id' => $inputFields['id'], |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | lcfirst($this->name()) => [ |
| 352 | 352 | 'type' => $this->name(), |
| 353 | 353 | 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
| 354 | - 'resolve' => static function ($payload) { |
|
| 354 | + 'resolve' => static function($payload) { |
|
| 355 | 355 | $deleted = (object) $payload['deleted']; |
| 356 | 356 | |
| 357 | 357 | return ! empty($deleted) ? $deleted : null; |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | unset($inputFields['id']); |
| 367 | 367 | // Register mutation to update an entity. |
| 368 | 368 | register_graphql_mutation( |
| 369 | - 'create' . $this->name(), |
|
| 369 | + 'create'.$this->name(), |
|
| 370 | 370 | [ |
| 371 | 371 | 'inputFields' => $inputFields, |
| 372 | 372 | 'outputFields' => [ |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | |
| 382 | 382 | // Register mutation to update an entity. |
| 383 | 383 | register_graphql_mutation( |
| 384 | - 'reorder' . $this->namespace . 'Entities', |
|
| 384 | + 'reorder'.$this->namespace.'Entities', |
|
| 385 | 385 | [ |
| 386 | 386 | 'inputFields' => [ |
| 387 | 387 | 'entityIds' => [ |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | ], |
| 393 | 393 | 'entityType' => [ |
| 394 | 394 | 'type' => [ |
| 395 | - 'non_null' => $this->namespace . 'ModelNameEnum', |
|
| 395 | + 'non_null' => $this->namespace.'ModelNameEnum', |
|
| 396 | 396 | ], |
| 397 | 397 | 'description' => esc_html__('The entity type for the IDs', 'event_espresso'), |
| 398 | 398 | ], |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | 'outputFields' => [ |
| 401 | 401 | 'ok' => [ |
| 402 | 402 | 'type' => 'Boolean', |
| 403 | - 'resolve' => function ($payload) { |
|
| 403 | + 'resolve' => function($payload) { |
|
| 404 | 404 | return (bool) $payload['ok']; |
| 405 | 405 | }, |
| 406 | 406 | ], |
@@ -34,380 +34,380 @@ |
||
| 34 | 34 | class Ticket extends TypeBase |
| 35 | 35 | { |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Ticket constructor. |
|
| 39 | - * |
|
| 40 | - * @param EEM_Ticket $ticket_model |
|
| 41 | - */ |
|
| 42 | - public function __construct(EEM_Ticket $ticket_model) |
|
| 43 | - { |
|
| 44 | - $this->model = $ticket_model; |
|
| 45 | - $this->setName($this->namespace . 'Ticket'); |
|
| 46 | - $this->setDescription(__('A ticket for an event date', 'event_espresso')); |
|
| 47 | - $this->setIsCustomPostType(false); |
|
| 48 | - parent::__construct(); |
|
| 49 | - } |
|
| 37 | + /** |
|
| 38 | + * Ticket constructor. |
|
| 39 | + * |
|
| 40 | + * @param EEM_Ticket $ticket_model |
|
| 41 | + */ |
|
| 42 | + public function __construct(EEM_Ticket $ticket_model) |
|
| 43 | + { |
|
| 44 | + $this->model = $ticket_model; |
|
| 45 | + $this->setName($this->namespace . 'Ticket'); |
|
| 46 | + $this->setDescription(__('A ticket for an event date', 'event_espresso')); |
|
| 47 | + $this->setIsCustomPostType(false); |
|
| 48 | + parent::__construct(); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * @return GraphQLFieldInterface[] |
|
| 54 | - * @since $VID:$ |
|
| 55 | - */ |
|
| 56 | - public function getFields() |
|
| 57 | - { |
|
| 58 | - $fields = [ |
|
| 59 | - new GraphQLField( |
|
| 60 | - 'id', |
|
| 61 | - ['non_null' => 'ID'], |
|
| 62 | - null, |
|
| 63 | - esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
| 64 | - ), |
|
| 65 | - new GraphQLOutputField( |
|
| 66 | - 'dbId', |
|
| 67 | - ['non_null' => 'Int'], |
|
| 68 | - 'ID', |
|
| 69 | - esc_html__('Ticket ID', 'event_espresso') |
|
| 70 | - ), |
|
| 71 | - new GraphQLOutputField( |
|
| 72 | - 'cacheId', |
|
| 73 | - ['non_null' => 'String'], |
|
| 74 | - null, |
|
| 75 | - esc_html__('The cache ID of the object.', 'event_espresso') |
|
| 76 | - ), |
|
| 77 | - new GraphQLInputField( |
|
| 78 | - 'datetimes', |
|
| 79 | - ['list_of' => 'ID'], |
|
| 80 | - null, |
|
| 81 | - sprintf( |
|
| 82 | - '%1$s %2$s', |
|
| 83 | - esc_html__('Globally unique IDs of the datetimes related to the ticket.', 'event_espresso'), |
|
| 84 | - esc_html__('Ignored if empty.', 'event_espresso') |
|
| 85 | - ) |
|
| 86 | - ), |
|
| 87 | - new GraphQLField( |
|
| 88 | - 'description', |
|
| 89 | - 'String', |
|
| 90 | - 'description', |
|
| 91 | - esc_html__('Description of Ticket', 'event_espresso') |
|
| 92 | - ), |
|
| 93 | - new GraphQLField( |
|
| 94 | - 'endDate', |
|
| 95 | - 'String', |
|
| 96 | - 'end_date', |
|
| 97 | - esc_html__('End date and time of the Ticket', 'event_espresso'), |
|
| 98 | - [$this, 'formatDatetime'] |
|
| 99 | - ), |
|
| 100 | - new GraphQLOutputField( |
|
| 101 | - 'event', |
|
| 102 | - $this->namespace . 'Event', |
|
| 103 | - null, |
|
| 104 | - esc_html__('Event of the ticket.', 'event_espresso') |
|
| 105 | - ), |
|
| 106 | - new GraphQLField( |
|
| 107 | - 'isDefault', |
|
| 108 | - 'Boolean', |
|
| 109 | - 'is_default', |
|
| 110 | - esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso') |
|
| 111 | - ), |
|
| 112 | - new GraphQLOutputField( |
|
| 113 | - 'isExpired', |
|
| 114 | - 'Boolean', |
|
| 115 | - 'is_expired', |
|
| 116 | - esc_html__('Flag indicating ticket is no longer available because its available dates have expired', 'event_espresso') |
|
| 117 | - ), |
|
| 118 | - new GraphQLOutputField( |
|
| 119 | - 'isFree', |
|
| 120 | - 'Boolean', |
|
| 121 | - 'is_free', |
|
| 122 | - esc_html__('Flag indicating whether the ticket is free.', 'event_espresso') |
|
| 123 | - ), |
|
| 124 | - new GraphQLOutputField( |
|
| 125 | - 'isOnSale', |
|
| 126 | - 'Boolean', |
|
| 127 | - 'is_on_sale', |
|
| 128 | - esc_html__('Flag indicating ticket ticket is on sale or not', 'event_espresso') |
|
| 129 | - ), |
|
| 130 | - new GraphQLOutputField( |
|
| 131 | - 'isPending', |
|
| 132 | - 'Boolean', |
|
| 133 | - 'is_pending', |
|
| 134 | - esc_html__('Flag indicating ticket is yet to go on sale or not', 'event_espresso') |
|
| 135 | - ), |
|
| 136 | - new GraphQLField( |
|
| 137 | - 'isRequired', |
|
| 138 | - 'Boolean', |
|
| 139 | - 'required', |
|
| 140 | - esc_html__( |
|
| 141 | - 'Flag indicating whether this ticket must be purchased with a transaction', |
|
| 142 | - 'event_espresso' |
|
| 143 | - ) |
|
| 144 | - ), |
|
| 145 | - new GraphQLOutputField( |
|
| 146 | - 'isSoldOut', |
|
| 147 | - 'Boolean', |
|
| 148 | - null, |
|
| 149 | - esc_html__('Flag indicating whether the ticket is sold out', 'event_espresso'), |
|
| 150 | - null, |
|
| 151 | - [$this, 'getIsSoldOut'] |
|
| 152 | - ), |
|
| 153 | - new GraphQLField( |
|
| 154 | - 'isTaxable', |
|
| 155 | - 'Boolean', |
|
| 156 | - 'taxable', |
|
| 157 | - esc_html__( |
|
| 158 | - 'Flag indicating whether there is tax applied on this ticket', |
|
| 159 | - 'event_espresso' |
|
| 160 | - ) |
|
| 161 | - ), |
|
| 162 | - new GraphQLField( |
|
| 163 | - 'isTrashed', |
|
| 164 | - 'Boolean', |
|
| 165 | - 'deleted', |
|
| 166 | - esc_html__('Flag indicating ticket has been trashed.', 'event_espresso') |
|
| 167 | - ), |
|
| 168 | - new GraphQLField( |
|
| 169 | - 'max', |
|
| 170 | - 'Int', |
|
| 171 | - 'max', |
|
| 172 | - esc_html__( |
|
| 173 | - 'Maximum quantity of this ticket that can be purchased in one transaction', |
|
| 174 | - 'event_espresso' |
|
| 175 | - ), |
|
| 176 | - [$this, 'parseInfiniteValue'] |
|
| 177 | - ), |
|
| 178 | - new GraphQLField( |
|
| 179 | - 'min', |
|
| 180 | - 'Int', |
|
| 181 | - 'min', |
|
| 182 | - esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso') |
|
| 183 | - ), |
|
| 184 | - new GraphQLField( |
|
| 185 | - 'name', |
|
| 186 | - 'String', |
|
| 187 | - 'name', |
|
| 188 | - esc_html__('Ticket Name', 'event_espresso') |
|
| 189 | - ), |
|
| 190 | - new GraphQLField( |
|
| 191 | - 'order', |
|
| 192 | - 'Int', |
|
| 193 | - 'order', |
|
| 194 | - esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
| 195 | - ), |
|
| 196 | - new GraphQLOutputField( |
|
| 197 | - 'parent', |
|
| 198 | - $this->name(), |
|
| 199 | - null, |
|
| 200 | - esc_html__('The parent ticket of the current ticket', 'event_espresso') |
|
| 201 | - ), |
|
| 202 | - new GraphQLInputField( |
|
| 203 | - 'parent', |
|
| 204 | - 'ID', |
|
| 205 | - null, |
|
| 206 | - esc_html__('The parent ticket ID', 'event_espresso') |
|
| 207 | - ), |
|
| 208 | - new GraphQLField( |
|
| 209 | - 'price', |
|
| 210 | - 'Float', |
|
| 211 | - 'price', |
|
| 212 | - esc_html__('Final calculated price for ticket', 'event_espresso') |
|
| 213 | - ), |
|
| 214 | - new GraphQLInputField( |
|
| 215 | - 'prices', |
|
| 216 | - ['list_of' => 'ID'], |
|
| 217 | - null, |
|
| 218 | - sprintf( |
|
| 219 | - '%1$s %2$s', |
|
| 220 | - esc_html__('Globally unique IDs of the prices related to the ticket.', 'event_espresso'), |
|
| 221 | - esc_html__('Ignored if empty.', 'event_espresso') |
|
| 222 | - ) |
|
| 223 | - ), |
|
| 224 | - new GraphQLField( |
|
| 225 | - 'quantity', |
|
| 226 | - 'Int', |
|
| 227 | - 'qty', |
|
| 228 | - esc_html__('Quantity of this ticket that is available', 'event_espresso'), |
|
| 229 | - [$this, 'parseInfiniteValue'] |
|
| 230 | - ), |
|
| 231 | - new GraphQLOutputField( |
|
| 232 | - 'registrationCount', |
|
| 233 | - 'Int', |
|
| 234 | - 'count_registrations', |
|
| 235 | - esc_html__('Number of registrations for the ticket', 'event_espresso') |
|
| 236 | - ), |
|
| 237 | - new GraphQLField( |
|
| 238 | - 'reserved', |
|
| 239 | - 'Int', |
|
| 240 | - 'reserved', |
|
| 241 | - esc_html__( |
|
| 242 | - 'Quantity of this ticket that is reserved, but not yet fully purchased', |
|
| 243 | - 'event_espresso' |
|
| 244 | - ) |
|
| 245 | - ), |
|
| 246 | - new GraphQLField( |
|
| 247 | - 'reverseCalculate', |
|
| 248 | - 'Boolean', |
|
| 249 | - 'reverse_calculate', |
|
| 250 | - esc_html__( |
|
| 251 | - 'Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.', |
|
| 252 | - 'event_espresso' |
|
| 253 | - ) |
|
| 254 | - ), |
|
| 255 | - new GraphQLField( |
|
| 256 | - 'row', |
|
| 257 | - 'Int', |
|
| 258 | - 'row', |
|
| 259 | - esc_html__('How tickets are displayed in the ui', 'event_espresso') |
|
| 260 | - ), |
|
| 261 | - new GraphQLField( |
|
| 262 | - 'sold', |
|
| 263 | - 'Int', |
|
| 264 | - 'sold', |
|
| 265 | - esc_html__('Number of this ticket sold', 'event_espresso') |
|
| 266 | - ), |
|
| 267 | - new GraphQLOutputField( |
|
| 268 | - 'status', |
|
| 269 | - $this->namespace . 'TicketStatusEnum', |
|
| 270 | - 'ticket_status', |
|
| 271 | - esc_html__('Ticket status', 'event_espresso') |
|
| 272 | - ), |
|
| 273 | - new GraphQLField( |
|
| 274 | - 'startDate', |
|
| 275 | - 'String', |
|
| 276 | - 'start_date', |
|
| 277 | - esc_html__('Start date and time of the Ticket', 'event_espresso'), |
|
| 278 | - [$this, 'formatDatetime'] |
|
| 279 | - ), |
|
| 280 | - new GraphQLField( |
|
| 281 | - 'uses', |
|
| 282 | - 'Int', |
|
| 283 | - 'uses', |
|
| 284 | - esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'), |
|
| 285 | - [$this, 'parseInfiniteValue'] |
|
| 286 | - ), |
|
| 287 | - new GraphQLOutputField( |
|
| 288 | - 'wpUser', |
|
| 289 | - 'User', |
|
| 290 | - null, |
|
| 291 | - esc_html__('Ticket Creator', 'event_espresso') |
|
| 292 | - ), |
|
| 293 | - new GraphQLInputField( |
|
| 294 | - 'wpUser', |
|
| 295 | - 'Int', |
|
| 296 | - null, |
|
| 297 | - esc_html__('Ticket Creator ID', 'event_espresso') |
|
| 298 | - ), |
|
| 299 | - ]; |
|
| 52 | + /** |
|
| 53 | + * @return GraphQLFieldInterface[] |
|
| 54 | + * @since $VID:$ |
|
| 55 | + */ |
|
| 56 | + public function getFields() |
|
| 57 | + { |
|
| 58 | + $fields = [ |
|
| 59 | + new GraphQLField( |
|
| 60 | + 'id', |
|
| 61 | + ['non_null' => 'ID'], |
|
| 62 | + null, |
|
| 63 | + esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
| 64 | + ), |
|
| 65 | + new GraphQLOutputField( |
|
| 66 | + 'dbId', |
|
| 67 | + ['non_null' => 'Int'], |
|
| 68 | + 'ID', |
|
| 69 | + esc_html__('Ticket ID', 'event_espresso') |
|
| 70 | + ), |
|
| 71 | + new GraphQLOutputField( |
|
| 72 | + 'cacheId', |
|
| 73 | + ['non_null' => 'String'], |
|
| 74 | + null, |
|
| 75 | + esc_html__('The cache ID of the object.', 'event_espresso') |
|
| 76 | + ), |
|
| 77 | + new GraphQLInputField( |
|
| 78 | + 'datetimes', |
|
| 79 | + ['list_of' => 'ID'], |
|
| 80 | + null, |
|
| 81 | + sprintf( |
|
| 82 | + '%1$s %2$s', |
|
| 83 | + esc_html__('Globally unique IDs of the datetimes related to the ticket.', 'event_espresso'), |
|
| 84 | + esc_html__('Ignored if empty.', 'event_espresso') |
|
| 85 | + ) |
|
| 86 | + ), |
|
| 87 | + new GraphQLField( |
|
| 88 | + 'description', |
|
| 89 | + 'String', |
|
| 90 | + 'description', |
|
| 91 | + esc_html__('Description of Ticket', 'event_espresso') |
|
| 92 | + ), |
|
| 93 | + new GraphQLField( |
|
| 94 | + 'endDate', |
|
| 95 | + 'String', |
|
| 96 | + 'end_date', |
|
| 97 | + esc_html__('End date and time of the Ticket', 'event_espresso'), |
|
| 98 | + [$this, 'formatDatetime'] |
|
| 99 | + ), |
|
| 100 | + new GraphQLOutputField( |
|
| 101 | + 'event', |
|
| 102 | + $this->namespace . 'Event', |
|
| 103 | + null, |
|
| 104 | + esc_html__('Event of the ticket.', 'event_espresso') |
|
| 105 | + ), |
|
| 106 | + new GraphQLField( |
|
| 107 | + 'isDefault', |
|
| 108 | + 'Boolean', |
|
| 109 | + 'is_default', |
|
| 110 | + esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso') |
|
| 111 | + ), |
|
| 112 | + new GraphQLOutputField( |
|
| 113 | + 'isExpired', |
|
| 114 | + 'Boolean', |
|
| 115 | + 'is_expired', |
|
| 116 | + esc_html__('Flag indicating ticket is no longer available because its available dates have expired', 'event_espresso') |
|
| 117 | + ), |
|
| 118 | + new GraphQLOutputField( |
|
| 119 | + 'isFree', |
|
| 120 | + 'Boolean', |
|
| 121 | + 'is_free', |
|
| 122 | + esc_html__('Flag indicating whether the ticket is free.', 'event_espresso') |
|
| 123 | + ), |
|
| 124 | + new GraphQLOutputField( |
|
| 125 | + 'isOnSale', |
|
| 126 | + 'Boolean', |
|
| 127 | + 'is_on_sale', |
|
| 128 | + esc_html__('Flag indicating ticket ticket is on sale or not', 'event_espresso') |
|
| 129 | + ), |
|
| 130 | + new GraphQLOutputField( |
|
| 131 | + 'isPending', |
|
| 132 | + 'Boolean', |
|
| 133 | + 'is_pending', |
|
| 134 | + esc_html__('Flag indicating ticket is yet to go on sale or not', 'event_espresso') |
|
| 135 | + ), |
|
| 136 | + new GraphQLField( |
|
| 137 | + 'isRequired', |
|
| 138 | + 'Boolean', |
|
| 139 | + 'required', |
|
| 140 | + esc_html__( |
|
| 141 | + 'Flag indicating whether this ticket must be purchased with a transaction', |
|
| 142 | + 'event_espresso' |
|
| 143 | + ) |
|
| 144 | + ), |
|
| 145 | + new GraphQLOutputField( |
|
| 146 | + 'isSoldOut', |
|
| 147 | + 'Boolean', |
|
| 148 | + null, |
|
| 149 | + esc_html__('Flag indicating whether the ticket is sold out', 'event_espresso'), |
|
| 150 | + null, |
|
| 151 | + [$this, 'getIsSoldOut'] |
|
| 152 | + ), |
|
| 153 | + new GraphQLField( |
|
| 154 | + 'isTaxable', |
|
| 155 | + 'Boolean', |
|
| 156 | + 'taxable', |
|
| 157 | + esc_html__( |
|
| 158 | + 'Flag indicating whether there is tax applied on this ticket', |
|
| 159 | + 'event_espresso' |
|
| 160 | + ) |
|
| 161 | + ), |
|
| 162 | + new GraphQLField( |
|
| 163 | + 'isTrashed', |
|
| 164 | + 'Boolean', |
|
| 165 | + 'deleted', |
|
| 166 | + esc_html__('Flag indicating ticket has been trashed.', 'event_espresso') |
|
| 167 | + ), |
|
| 168 | + new GraphQLField( |
|
| 169 | + 'max', |
|
| 170 | + 'Int', |
|
| 171 | + 'max', |
|
| 172 | + esc_html__( |
|
| 173 | + 'Maximum quantity of this ticket that can be purchased in one transaction', |
|
| 174 | + 'event_espresso' |
|
| 175 | + ), |
|
| 176 | + [$this, 'parseInfiniteValue'] |
|
| 177 | + ), |
|
| 178 | + new GraphQLField( |
|
| 179 | + 'min', |
|
| 180 | + 'Int', |
|
| 181 | + 'min', |
|
| 182 | + esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso') |
|
| 183 | + ), |
|
| 184 | + new GraphQLField( |
|
| 185 | + 'name', |
|
| 186 | + 'String', |
|
| 187 | + 'name', |
|
| 188 | + esc_html__('Ticket Name', 'event_espresso') |
|
| 189 | + ), |
|
| 190 | + new GraphQLField( |
|
| 191 | + 'order', |
|
| 192 | + 'Int', |
|
| 193 | + 'order', |
|
| 194 | + esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
| 195 | + ), |
|
| 196 | + new GraphQLOutputField( |
|
| 197 | + 'parent', |
|
| 198 | + $this->name(), |
|
| 199 | + null, |
|
| 200 | + esc_html__('The parent ticket of the current ticket', 'event_espresso') |
|
| 201 | + ), |
|
| 202 | + new GraphQLInputField( |
|
| 203 | + 'parent', |
|
| 204 | + 'ID', |
|
| 205 | + null, |
|
| 206 | + esc_html__('The parent ticket ID', 'event_espresso') |
|
| 207 | + ), |
|
| 208 | + new GraphQLField( |
|
| 209 | + 'price', |
|
| 210 | + 'Float', |
|
| 211 | + 'price', |
|
| 212 | + esc_html__('Final calculated price for ticket', 'event_espresso') |
|
| 213 | + ), |
|
| 214 | + new GraphQLInputField( |
|
| 215 | + 'prices', |
|
| 216 | + ['list_of' => 'ID'], |
|
| 217 | + null, |
|
| 218 | + sprintf( |
|
| 219 | + '%1$s %2$s', |
|
| 220 | + esc_html__('Globally unique IDs of the prices related to the ticket.', 'event_espresso'), |
|
| 221 | + esc_html__('Ignored if empty.', 'event_espresso') |
|
| 222 | + ) |
|
| 223 | + ), |
|
| 224 | + new GraphQLField( |
|
| 225 | + 'quantity', |
|
| 226 | + 'Int', |
|
| 227 | + 'qty', |
|
| 228 | + esc_html__('Quantity of this ticket that is available', 'event_espresso'), |
|
| 229 | + [$this, 'parseInfiniteValue'] |
|
| 230 | + ), |
|
| 231 | + new GraphQLOutputField( |
|
| 232 | + 'registrationCount', |
|
| 233 | + 'Int', |
|
| 234 | + 'count_registrations', |
|
| 235 | + esc_html__('Number of registrations for the ticket', 'event_espresso') |
|
| 236 | + ), |
|
| 237 | + new GraphQLField( |
|
| 238 | + 'reserved', |
|
| 239 | + 'Int', |
|
| 240 | + 'reserved', |
|
| 241 | + esc_html__( |
|
| 242 | + 'Quantity of this ticket that is reserved, but not yet fully purchased', |
|
| 243 | + 'event_espresso' |
|
| 244 | + ) |
|
| 245 | + ), |
|
| 246 | + new GraphQLField( |
|
| 247 | + 'reverseCalculate', |
|
| 248 | + 'Boolean', |
|
| 249 | + 'reverse_calculate', |
|
| 250 | + esc_html__( |
|
| 251 | + 'Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.', |
|
| 252 | + 'event_espresso' |
|
| 253 | + ) |
|
| 254 | + ), |
|
| 255 | + new GraphQLField( |
|
| 256 | + 'row', |
|
| 257 | + 'Int', |
|
| 258 | + 'row', |
|
| 259 | + esc_html__('How tickets are displayed in the ui', 'event_espresso') |
|
| 260 | + ), |
|
| 261 | + new GraphQLField( |
|
| 262 | + 'sold', |
|
| 263 | + 'Int', |
|
| 264 | + 'sold', |
|
| 265 | + esc_html__('Number of this ticket sold', 'event_espresso') |
|
| 266 | + ), |
|
| 267 | + new GraphQLOutputField( |
|
| 268 | + 'status', |
|
| 269 | + $this->namespace . 'TicketStatusEnum', |
|
| 270 | + 'ticket_status', |
|
| 271 | + esc_html__('Ticket status', 'event_espresso') |
|
| 272 | + ), |
|
| 273 | + new GraphQLField( |
|
| 274 | + 'startDate', |
|
| 275 | + 'String', |
|
| 276 | + 'start_date', |
|
| 277 | + esc_html__('Start date and time of the Ticket', 'event_espresso'), |
|
| 278 | + [$this, 'formatDatetime'] |
|
| 279 | + ), |
|
| 280 | + new GraphQLField( |
|
| 281 | + 'uses', |
|
| 282 | + 'Int', |
|
| 283 | + 'uses', |
|
| 284 | + esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'), |
|
| 285 | + [$this, 'parseInfiniteValue'] |
|
| 286 | + ), |
|
| 287 | + new GraphQLOutputField( |
|
| 288 | + 'wpUser', |
|
| 289 | + 'User', |
|
| 290 | + null, |
|
| 291 | + esc_html__('Ticket Creator', 'event_espresso') |
|
| 292 | + ), |
|
| 293 | + new GraphQLInputField( |
|
| 294 | + 'wpUser', |
|
| 295 | + 'Int', |
|
| 296 | + null, |
|
| 297 | + esc_html__('Ticket Creator ID', 'event_espresso') |
|
| 298 | + ), |
|
| 299 | + ]; |
|
| 300 | 300 | |
| 301 | - return apply_filters( |
|
| 302 | - 'FHEE__EventEspresso_core_domain_services_graphql_types__ticket_fields', |
|
| 303 | - $fields, |
|
| 304 | - $this->name, |
|
| 305 | - $this->model |
|
| 306 | - ); |
|
| 307 | - } |
|
| 301 | + return apply_filters( |
|
| 302 | + 'FHEE__EventEspresso_core_domain_services_graphql_types__ticket_fields', |
|
| 303 | + $fields, |
|
| 304 | + $this->name, |
|
| 305 | + $this->model |
|
| 306 | + ); |
|
| 307 | + } |
|
| 308 | 308 | |
| 309 | 309 | |
| 310 | - /** |
|
| 311 | - * @param EE_Ticket $source The source that's passed down the GraphQL queries |
|
| 312 | - * @param array $args The inputArgs on the field |
|
| 313 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
| 314 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
| 315 | - * @return string |
|
| 316 | - * @throws Exception |
|
| 317 | - * @throws InvalidArgumentException |
|
| 318 | - * @throws InvalidDataTypeException |
|
| 319 | - * @throws InvalidInterfaceException |
|
| 320 | - * @throws ReflectionException |
|
| 321 | - * @throws UserError |
|
| 322 | - * @throws UnexpectedEntityException |
|
| 323 | - * @since $VID:$ |
|
| 324 | - */ |
|
| 325 | - public function getIsSoldOut(EE_Ticket $source, array $args, AppContext $context, ResolveInfo $info) |
|
| 326 | - { |
|
| 327 | - return $source->ticket_status() === EE_Ticket::sold_out; |
|
| 328 | - } |
|
| 310 | + /** |
|
| 311 | + * @param EE_Ticket $source The source that's passed down the GraphQL queries |
|
| 312 | + * @param array $args The inputArgs on the field |
|
| 313 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
| 314 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
| 315 | + * @return string |
|
| 316 | + * @throws Exception |
|
| 317 | + * @throws InvalidArgumentException |
|
| 318 | + * @throws InvalidDataTypeException |
|
| 319 | + * @throws InvalidInterfaceException |
|
| 320 | + * @throws ReflectionException |
|
| 321 | + * @throws UserError |
|
| 322 | + * @throws UnexpectedEntityException |
|
| 323 | + * @since $VID:$ |
|
| 324 | + */ |
|
| 325 | + public function getIsSoldOut(EE_Ticket $source, array $args, AppContext $context, ResolveInfo $info) |
|
| 326 | + { |
|
| 327 | + return $source->ticket_status() === EE_Ticket::sold_out; |
|
| 328 | + } |
|
| 329 | 329 | |
| 330 | 330 | |
| 331 | - /** |
|
| 332 | - * @param array $inputFields The mutation input fields. |
|
| 333 | - * @throws InvalidArgumentException |
|
| 334 | - * @throws ReflectionException |
|
| 335 | - * @since $VID:$ |
|
| 336 | - */ |
|
| 337 | - public function registerMutations(array $inputFields) |
|
| 338 | - { |
|
| 339 | - register_graphql_input_type( |
|
| 340 | - 'Update' . $this->name() . 'BaseInput', |
|
| 341 | - [ |
|
| 342 | - 'fields' => $inputFields, |
|
| 343 | - ] |
|
| 344 | - ); |
|
| 345 | - // Register mutation to update an entity. |
|
| 346 | - register_graphql_mutation( |
|
| 347 | - 'update' . $this->name(), |
|
| 348 | - [ |
|
| 349 | - 'inputFields' => $inputFields, |
|
| 350 | - 'outputFields' => [ |
|
| 351 | - lcfirst($this->name()) => [ |
|
| 352 | - 'type' => $this->name(), |
|
| 353 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
| 354 | - ], |
|
| 355 | - ], |
|
| 356 | - 'mutateAndGetPayload' => TicketUpdate::mutateAndGetPayload($this->model, $this), |
|
| 357 | - ] |
|
| 358 | - ); |
|
| 359 | - $base_input = 'Update' . $this->name() . 'BaseInput'; |
|
| 360 | - // Register mutation to update an entity. |
|
| 361 | - register_graphql_mutation( |
|
| 362 | - 'bulkUpdate' . $this->name(), |
|
| 363 | - array_merge( |
|
| 364 | - Datetime::bulkUpdateBaseConfig($base_input), |
|
| 365 | - [ |
|
| 366 | - 'mutateAndGetPayload' => TicketBulkUpdate::mutateAndGetPayload($this->model, $this), |
|
| 367 | - ] |
|
| 368 | - ) |
|
| 369 | - ); |
|
| 370 | - // Register mutation to delete an entity. |
|
| 371 | - register_graphql_mutation( |
|
| 372 | - 'delete' . $this->name(), |
|
| 373 | - [ |
|
| 374 | - 'inputFields' => [ |
|
| 375 | - 'id' => $inputFields['id'], |
|
| 376 | - 'deletePermanently' => [ |
|
| 377 | - 'type' => 'Boolean', |
|
| 378 | - 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
| 379 | - ], |
|
| 380 | - ], |
|
| 381 | - 'outputFields' => [ |
|
| 382 | - lcfirst($this->name()) => [ |
|
| 383 | - 'type' => $this->name(), |
|
| 384 | - 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
| 385 | - 'resolve' => static function ($payload) { |
|
| 386 | - $deleted = (object) $payload['deleted']; |
|
| 331 | + /** |
|
| 332 | + * @param array $inputFields The mutation input fields. |
|
| 333 | + * @throws InvalidArgumentException |
|
| 334 | + * @throws ReflectionException |
|
| 335 | + * @since $VID:$ |
|
| 336 | + */ |
|
| 337 | + public function registerMutations(array $inputFields) |
|
| 338 | + { |
|
| 339 | + register_graphql_input_type( |
|
| 340 | + 'Update' . $this->name() . 'BaseInput', |
|
| 341 | + [ |
|
| 342 | + 'fields' => $inputFields, |
|
| 343 | + ] |
|
| 344 | + ); |
|
| 345 | + // Register mutation to update an entity. |
|
| 346 | + register_graphql_mutation( |
|
| 347 | + 'update' . $this->name(), |
|
| 348 | + [ |
|
| 349 | + 'inputFields' => $inputFields, |
|
| 350 | + 'outputFields' => [ |
|
| 351 | + lcfirst($this->name()) => [ |
|
| 352 | + 'type' => $this->name(), |
|
| 353 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
| 354 | + ], |
|
| 355 | + ], |
|
| 356 | + 'mutateAndGetPayload' => TicketUpdate::mutateAndGetPayload($this->model, $this), |
|
| 357 | + ] |
|
| 358 | + ); |
|
| 359 | + $base_input = 'Update' . $this->name() . 'BaseInput'; |
|
| 360 | + // Register mutation to update an entity. |
|
| 361 | + register_graphql_mutation( |
|
| 362 | + 'bulkUpdate' . $this->name(), |
|
| 363 | + array_merge( |
|
| 364 | + Datetime::bulkUpdateBaseConfig($base_input), |
|
| 365 | + [ |
|
| 366 | + 'mutateAndGetPayload' => TicketBulkUpdate::mutateAndGetPayload($this->model, $this), |
|
| 367 | + ] |
|
| 368 | + ) |
|
| 369 | + ); |
|
| 370 | + // Register mutation to delete an entity. |
|
| 371 | + register_graphql_mutation( |
|
| 372 | + 'delete' . $this->name(), |
|
| 373 | + [ |
|
| 374 | + 'inputFields' => [ |
|
| 375 | + 'id' => $inputFields['id'], |
|
| 376 | + 'deletePermanently' => [ |
|
| 377 | + 'type' => 'Boolean', |
|
| 378 | + 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
| 379 | + ], |
|
| 380 | + ], |
|
| 381 | + 'outputFields' => [ |
|
| 382 | + lcfirst($this->name()) => [ |
|
| 383 | + 'type' => $this->name(), |
|
| 384 | + 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
| 385 | + 'resolve' => static function ($payload) { |
|
| 386 | + $deleted = (object) $payload['deleted']; |
|
| 387 | 387 | |
| 388 | - return ! empty($deleted) ? $deleted : null; |
|
| 389 | - }, |
|
| 390 | - ], |
|
| 391 | - ], |
|
| 392 | - 'mutateAndGetPayload' => TicketDelete::mutateAndGetPayload($this->model, $this), |
|
| 393 | - ] |
|
| 394 | - ); |
|
| 388 | + return ! empty($deleted) ? $deleted : null; |
|
| 389 | + }, |
|
| 390 | + ], |
|
| 391 | + ], |
|
| 392 | + 'mutateAndGetPayload' => TicketDelete::mutateAndGetPayload($this->model, $this), |
|
| 393 | + ] |
|
| 394 | + ); |
|
| 395 | 395 | |
| 396 | - // remove primary key from input. |
|
| 397 | - unset($inputFields['id']); |
|
| 398 | - // Register mutation to update an entity. |
|
| 399 | - register_graphql_mutation( |
|
| 400 | - 'create' . $this->name(), |
|
| 401 | - [ |
|
| 402 | - 'inputFields' => $inputFields, |
|
| 403 | - 'outputFields' => [ |
|
| 404 | - lcfirst($this->name()) => [ |
|
| 405 | - 'type' => $this->name(), |
|
| 406 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
| 407 | - ], |
|
| 408 | - ], |
|
| 409 | - 'mutateAndGetPayload' => TicketCreate::mutateAndGetPayload($this->model, $this), |
|
| 410 | - ] |
|
| 411 | - ); |
|
| 412 | - } |
|
| 396 | + // remove primary key from input. |
|
| 397 | + unset($inputFields['id']); |
|
| 398 | + // Register mutation to update an entity. |
|
| 399 | + register_graphql_mutation( |
|
| 400 | + 'create' . $this->name(), |
|
| 401 | + [ |
|
| 402 | + 'inputFields' => $inputFields, |
|
| 403 | + 'outputFields' => [ |
|
| 404 | + lcfirst($this->name()) => [ |
|
| 405 | + 'type' => $this->name(), |
|
| 406 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
| 407 | + ], |
|
| 408 | + ], |
|
| 409 | + 'mutateAndGetPayload' => TicketCreate::mutateAndGetPayload($this->model, $this), |
|
| 410 | + ] |
|
| 411 | + ); |
|
| 412 | + } |
|
| 413 | 413 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | public function __construct(EEM_Ticket $ticket_model) |
| 43 | 43 | { |
| 44 | 44 | $this->model = $ticket_model; |
| 45 | - $this->setName($this->namespace . 'Ticket'); |
|
| 45 | + $this->setName($this->namespace.'Ticket'); |
|
| 46 | 46 | $this->setDescription(__('A ticket for an event date', 'event_espresso')); |
| 47 | 47 | $this->setIsCustomPostType(false); |
| 48 | 48 | parent::__construct(); |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | ), |
| 100 | 100 | new GraphQLOutputField( |
| 101 | 101 | 'event', |
| 102 | - $this->namespace . 'Event', |
|
| 102 | + $this->namespace.'Event', |
|
| 103 | 103 | null, |
| 104 | 104 | esc_html__('Event of the ticket.', 'event_espresso') |
| 105 | 105 | ), |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | ), |
| 267 | 267 | new GraphQLOutputField( |
| 268 | 268 | 'status', |
| 269 | - $this->namespace . 'TicketStatusEnum', |
|
| 269 | + $this->namespace.'TicketStatusEnum', |
|
| 270 | 270 | 'ticket_status', |
| 271 | 271 | esc_html__('Ticket status', 'event_espresso') |
| 272 | 272 | ), |
@@ -337,14 +337,14 @@ discard block |
||
| 337 | 337 | public function registerMutations(array $inputFields) |
| 338 | 338 | { |
| 339 | 339 | register_graphql_input_type( |
| 340 | - 'Update' . $this->name() . 'BaseInput', |
|
| 340 | + 'Update'.$this->name().'BaseInput', |
|
| 341 | 341 | [ |
| 342 | 342 | 'fields' => $inputFields, |
| 343 | 343 | ] |
| 344 | 344 | ); |
| 345 | 345 | // Register mutation to update an entity. |
| 346 | 346 | register_graphql_mutation( |
| 347 | - 'update' . $this->name(), |
|
| 347 | + 'update'.$this->name(), |
|
| 348 | 348 | [ |
| 349 | 349 | 'inputFields' => $inputFields, |
| 350 | 350 | 'outputFields' => [ |
@@ -356,10 +356,10 @@ discard block |
||
| 356 | 356 | 'mutateAndGetPayload' => TicketUpdate::mutateAndGetPayload($this->model, $this), |
| 357 | 357 | ] |
| 358 | 358 | ); |
| 359 | - $base_input = 'Update' . $this->name() . 'BaseInput'; |
|
| 359 | + $base_input = 'Update'.$this->name().'BaseInput'; |
|
| 360 | 360 | // Register mutation to update an entity. |
| 361 | 361 | register_graphql_mutation( |
| 362 | - 'bulkUpdate' . $this->name(), |
|
| 362 | + 'bulkUpdate'.$this->name(), |
|
| 363 | 363 | array_merge( |
| 364 | 364 | Datetime::bulkUpdateBaseConfig($base_input), |
| 365 | 365 | [ |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | ); |
| 370 | 370 | // Register mutation to delete an entity. |
| 371 | 371 | register_graphql_mutation( |
| 372 | - 'delete' . $this->name(), |
|
| 372 | + 'delete'.$this->name(), |
|
| 373 | 373 | [ |
| 374 | 374 | 'inputFields' => [ |
| 375 | 375 | 'id' => $inputFields['id'], |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | lcfirst($this->name()) => [ |
| 383 | 383 | 'type' => $this->name(), |
| 384 | 384 | 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
| 385 | - 'resolve' => static function ($payload) { |
|
| 385 | + 'resolve' => static function($payload) { |
|
| 386 | 386 | $deleted = (object) $payload['deleted']; |
| 387 | 387 | |
| 388 | 388 | return ! empty($deleted) ? $deleted : null; |
@@ -397,7 +397,7 @@ discard block |
||
| 397 | 397 | unset($inputFields['id']); |
| 398 | 398 | // Register mutation to update an entity. |
| 399 | 399 | register_graphql_mutation( |
| 400 | - 'create' . $this->name(), |
|
| 400 | + 'create'.$this->name(), |
|
| 401 | 401 | [ |
| 402 | 402 | 'inputFields' => $inputFields, |
| 403 | 403 | 'outputFields' => [ |