| @@ -33,356 +33,356 @@ | ||
| 33 | 33 | class Ticket extends TypeBase | 
| 34 | 34 |  { | 
| 35 | 35 | |
| 36 | - /** | |
| 37 | - * Ticket constructor. | |
| 38 | - * | |
| 39 | - * @param EEM_Ticket $ticket_model | |
| 40 | - */ | |
| 41 | - public function __construct(EEM_Ticket $ticket_model) | |
| 42 | -    { | |
| 43 | - $this->model = $ticket_model; | |
| 44 | - $this->setName($this->namespace . 'Ticket'); | |
| 45 | -        $this->setDescription(__('A ticket for an event date', 'event_espresso')); | |
| 46 | - $this->setIsCustomPostType(false); | |
| 47 | - parent::__construct(); | |
| 48 | - } | |
| 36 | + /** | |
| 37 | + * Ticket constructor. | |
| 38 | + * | |
| 39 | + * @param EEM_Ticket $ticket_model | |
| 40 | + */ | |
| 41 | + public function __construct(EEM_Ticket $ticket_model) | |
| 42 | +	{ | |
| 43 | + $this->model = $ticket_model; | |
| 44 | + $this->setName($this->namespace . 'Ticket'); | |
| 45 | +		$this->setDescription(__('A ticket for an event date', 'event_espresso')); | |
| 46 | + $this->setIsCustomPostType(false); | |
| 47 | + parent::__construct(); | |
| 48 | + } | |
| 49 | 49 | |
| 50 | 50 | |
| 51 | - /** | |
| 52 | - * @return GraphQLFieldInterface[] | |
| 53 | - * @since $VID:$ | |
| 54 | - */ | |
| 55 | - public function getFields() | |
| 56 | -    { | |
| 57 | - return [ | |
| 58 | - new GraphQLField( | |
| 59 | - 'id', | |
| 60 | - ['non_null' => 'ID'], | |
| 61 | - null, | |
| 62 | -                esc_html__('The globally unique ID for the object.', 'event_espresso') | |
| 63 | - ), | |
| 64 | - new GraphQLOutputField( | |
| 65 | - 'dbId', | |
| 66 | - ['non_null' => 'Int'], | |
| 67 | - 'ID', | |
| 68 | -                esc_html__('Ticket ID', 'event_espresso') | |
| 69 | - ), | |
| 70 | - new GraphQLOutputField( | |
| 71 | - 'cacheId', | |
| 72 | - ['non_null' => 'String'], | |
| 73 | - null, | |
| 74 | -                esc_html__('The cache ID of the object.', 'event_espresso') | |
| 75 | - ), | |
| 76 | - new GraphQLInputField( | |
| 77 | - 'datetimes', | |
| 78 | - ['list_of' => 'ID'], | |
| 79 | - null, | |
| 80 | - sprintf( | |
| 81 | - '%1$s %2$s', | |
| 82 | -                    esc_html__('Globally unique IDs of the datetimes related to the ticket.', 'event_espresso'), | |
| 83 | -                    esc_html__('Ignored if empty.', 'event_espresso') | |
| 84 | - ) | |
| 85 | - ), | |
| 86 | - new GraphQLField( | |
| 87 | - 'description', | |
| 88 | - 'String', | |
| 89 | - 'description', | |
| 90 | -                esc_html__('Description of Ticket', 'event_espresso') | |
| 91 | - ), | |
| 92 | - new GraphQLField( | |
| 93 | - 'endDate', | |
| 94 | - 'String', | |
| 95 | - 'end_date', | |
| 96 | -                esc_html__('End date and time of the Ticket', 'event_espresso'), | |
| 97 | - [$this, 'formatDatetime'] | |
| 98 | - ), | |
| 99 | - new GraphQLOutputField( | |
| 100 | - 'event', | |
| 101 | - $this->namespace . 'Event', | |
| 102 | - null, | |
| 103 | -                esc_html__('Event of the ticket.', 'event_espresso') | |
| 104 | - ), | |
| 105 | - new GraphQLField( | |
| 106 | - 'isDefault', | |
| 107 | - 'Boolean', | |
| 108 | - 'is_default', | |
| 109 | -                esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso') | |
| 110 | - ), | |
| 111 | - new GraphQLOutputField( | |
| 112 | - 'isExpired', | |
| 113 | - 'Boolean', | |
| 114 | - 'is_expired', | |
| 115 | -                esc_html__('Flag indicating ticket is no longer available because its available dates have expired', 'event_espresso') | |
| 116 | - ), | |
| 117 | - new GraphQLOutputField( | |
| 118 | - 'isFree', | |
| 119 | - 'Boolean', | |
| 120 | - 'is_free', | |
| 121 | -                esc_html__('Flag indicating whether the ticket is free.', 'event_espresso') | |
| 122 | - ), | |
| 123 | - new GraphQLOutputField( | |
| 124 | - 'isOnSale', | |
| 125 | - 'Boolean', | |
| 126 | - 'is_on_sale', | |
| 127 | -                esc_html__('Flag indicating ticket ticket is on sale or not', 'event_espresso') | |
| 128 | - ), | |
| 129 | - new GraphQLOutputField( | |
| 130 | - 'isPending', | |
| 131 | - 'Boolean', | |
| 132 | - 'is_pending', | |
| 133 | -                esc_html__('Flag indicating ticket is yet to go on sale or not', 'event_espresso') | |
| 134 | - ), | |
| 135 | - new GraphQLField( | |
| 136 | - 'isRequired', | |
| 137 | - 'Boolean', | |
| 138 | - 'required', | |
| 139 | - esc_html__( | |
| 140 | - 'Flag indicating whether this ticket must be purchased with a transaction', | |
| 141 | - 'event_espresso' | |
| 142 | - ) | |
| 143 | - ), | |
| 144 | - new GraphQLOutputField( | |
| 145 | - 'isSoldOut', | |
| 146 | - 'Boolean', | |
| 147 | - null, | |
| 148 | -                esc_html__('Flag indicating whether the ticket is sold out', 'event_espresso'), | |
| 149 | - null, | |
| 150 | - [$this, 'getIsSoldOut'] | |
| 151 | - ), | |
| 152 | - new GraphQLField( | |
| 153 | - 'isTaxable', | |
| 154 | - 'Boolean', | |
| 155 | - 'taxable', | |
| 156 | - esc_html__( | |
| 157 | - 'Flag indicating whether there is tax applied on this ticket', | |
| 158 | - 'event_espresso' | |
| 159 | - ) | |
| 160 | - ), | |
| 161 | - new GraphQLField( | |
| 162 | - 'isTrashed', | |
| 163 | - 'Boolean', | |
| 164 | - 'deleted', | |
| 165 | -                esc_html__('Flag indicating ticket has been trashed.', 'event_espresso') | |
| 166 | - ), | |
| 167 | - new GraphQLField( | |
| 168 | - 'max', | |
| 169 | - 'Int', | |
| 170 | - 'max', | |
| 171 | - esc_html__( | |
| 172 | - 'Maximum quantity of this ticket that can be purchased in one transaction', | |
| 173 | - 'event_espresso' | |
| 174 | - ), | |
| 175 | - [$this, 'parseInfiniteValue'] | |
| 176 | - ), | |
| 177 | - new GraphQLField( | |
| 178 | - 'min', | |
| 179 | - 'Int', | |
| 180 | - 'min', | |
| 181 | -                esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso') | |
| 182 | - ), | |
| 183 | - new GraphQLField( | |
| 184 | - 'name', | |
| 185 | - 'String', | |
| 186 | - 'name', | |
| 187 | -                esc_html__('Ticket Name', 'event_espresso') | |
| 188 | - ), | |
| 189 | - new GraphQLField( | |
| 190 | - 'order', | |
| 191 | - 'Int', | |
| 192 | - 'order', | |
| 193 | -                esc_html__('The order in which the Datetime is displayed', 'event_espresso') | |
| 194 | - ), | |
| 195 | - new GraphQLOutputField( | |
| 196 | - 'parent', | |
| 197 | - $this->name(), | |
| 198 | - null, | |
| 199 | -                esc_html__('The parent ticket of the current ticket', 'event_espresso') | |
| 200 | - ), | |
| 201 | - new GraphQLInputField( | |
| 202 | - 'parent', | |
| 203 | - 'ID', | |
| 204 | - null, | |
| 205 | -                esc_html__('The parent ticket ID', 'event_espresso') | |
| 206 | - ), | |
| 207 | - new GraphQLField( | |
| 208 | - 'price', | |
| 209 | - 'Float', | |
| 210 | - 'price', | |
| 211 | -                esc_html__('Final calculated price for ticket', 'event_espresso') | |
| 212 | - ), | |
| 213 | - new GraphQLInputField( | |
| 214 | - 'prices', | |
| 215 | - ['list_of' => 'ID'], | |
| 216 | - null, | |
| 217 | - sprintf( | |
| 218 | - '%1$s %2$s', | |
| 219 | -                    esc_html__('Globally unique IDs of the prices related to the ticket.', 'event_espresso'), | |
| 220 | -                    esc_html__('Ignored if empty.', 'event_espresso') | |
| 221 | - ) | |
| 222 | - ), | |
| 223 | - new GraphQLField( | |
| 224 | - 'quantity', | |
| 225 | - 'Int', | |
| 226 | - 'qty', | |
| 227 | -                esc_html__('Quantity of this ticket that is available', 'event_espresso'), | |
| 228 | - [$this, 'parseInfiniteValue'] | |
| 229 | - ), | |
| 230 | - new GraphQLOutputField( | |
| 231 | - 'registrationCount', | |
| 232 | - 'Int', | |
| 233 | - 'count_registrations', | |
| 234 | -                esc_html__('Number of registrations for the ticket', 'event_espresso') | |
| 235 | - ), | |
| 236 | - new GraphQLField( | |
| 237 | - 'reserved', | |
| 238 | - 'Int', | |
| 239 | - 'reserved', | |
| 240 | - esc_html__( | |
| 241 | - 'Quantity of this ticket that is reserved, but not yet fully purchased', | |
| 242 | - 'event_espresso' | |
| 243 | - ) | |
| 244 | - ), | |
| 245 | - new GraphQLField( | |
| 246 | - 'reverseCalculate', | |
| 247 | - 'Boolean', | |
| 248 | - 'reverse_calculate', | |
| 249 | - esc_html__( | |
| 250 | - 'Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.', | |
| 251 | - 'event_espresso' | |
| 252 | - ) | |
| 253 | - ), | |
| 254 | - new GraphQLField( | |
| 255 | - 'row', | |
| 256 | - 'Int', | |
| 257 | - 'row', | |
| 258 | -                esc_html__('How tickets are displayed in the ui', 'event_espresso') | |
| 259 | - ), | |
| 260 | - new GraphQLField( | |
| 261 | - 'sold', | |
| 262 | - 'Int', | |
| 263 | - 'sold', | |
| 264 | -                esc_html__('Number of this ticket sold', 'event_espresso') | |
| 265 | - ), | |
| 266 | - new GraphQLOutputField( | |
| 267 | - 'status', | |
| 268 | - $this->namespace . 'TicketStatusEnum', | |
| 269 | - 'ticket_status', | |
| 270 | -                esc_html__('Ticket status', 'event_espresso') | |
| 271 | - ), | |
| 272 | - new GraphQLField( | |
| 273 | - 'startDate', | |
| 274 | - 'String', | |
| 275 | - 'start_date', | |
| 276 | -                esc_html__('Start date and time of the Ticket', 'event_espresso'), | |
| 277 | - [$this, 'formatDatetime'] | |
| 278 | - ), | |
| 279 | - new GraphQLField( | |
| 280 | - 'uses', | |
| 281 | - 'Int', | |
| 282 | - 'uses', | |
| 283 | -                esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'), | |
| 284 | - [$this, 'parseInfiniteValue'] | |
| 285 | - ), | |
| 286 | - new GraphQLOutputField( | |
| 287 | - 'wpUser', | |
| 288 | - 'User', | |
| 289 | - null, | |
| 290 | -                esc_html__('Ticket Creator', 'event_espresso') | |
| 291 | - ), | |
| 292 | - new GraphQLInputField( | |
| 293 | - 'wpUser', | |
| 294 | - 'Int', | |
| 295 | - null, | |
| 296 | -                esc_html__('Ticket Creator ID', 'event_espresso') | |
| 297 | - ), | |
| 298 | - ]; | |
| 299 | - } | |
| 51 | + /** | |
| 52 | + * @return GraphQLFieldInterface[] | |
| 53 | + * @since $VID:$ | |
| 54 | + */ | |
| 55 | + public function getFields() | |
| 56 | +	{ | |
| 57 | + return [ | |
| 58 | + new GraphQLField( | |
| 59 | + 'id', | |
| 60 | + ['non_null' => 'ID'], | |
| 61 | + null, | |
| 62 | +				esc_html__('The globally unique ID for the object.', 'event_espresso') | |
| 63 | + ), | |
| 64 | + new GraphQLOutputField( | |
| 65 | + 'dbId', | |
| 66 | + ['non_null' => 'Int'], | |
| 67 | + 'ID', | |
| 68 | +				esc_html__('Ticket ID', 'event_espresso') | |
| 69 | + ), | |
| 70 | + new GraphQLOutputField( | |
| 71 | + 'cacheId', | |
| 72 | + ['non_null' => 'String'], | |
| 73 | + null, | |
| 74 | +				esc_html__('The cache ID of the object.', 'event_espresso') | |
| 75 | + ), | |
| 76 | + new GraphQLInputField( | |
| 77 | + 'datetimes', | |
| 78 | + ['list_of' => 'ID'], | |
| 79 | + null, | |
| 80 | + sprintf( | |
| 81 | + '%1$s %2$s', | |
| 82 | +					esc_html__('Globally unique IDs of the datetimes related to the ticket.', 'event_espresso'), | |
| 83 | +					esc_html__('Ignored if empty.', 'event_espresso') | |
| 84 | + ) | |
| 85 | + ), | |
| 86 | + new GraphQLField( | |
| 87 | + 'description', | |
| 88 | + 'String', | |
| 89 | + 'description', | |
| 90 | +				esc_html__('Description of Ticket', 'event_espresso') | |
| 91 | + ), | |
| 92 | + new GraphQLField( | |
| 93 | + 'endDate', | |
| 94 | + 'String', | |
| 95 | + 'end_date', | |
| 96 | +				esc_html__('End date and time of the Ticket', 'event_espresso'), | |
| 97 | + [$this, 'formatDatetime'] | |
| 98 | + ), | |
| 99 | + new GraphQLOutputField( | |
| 100 | + 'event', | |
| 101 | + $this->namespace . 'Event', | |
| 102 | + null, | |
| 103 | +				esc_html__('Event of the ticket.', 'event_espresso') | |
| 104 | + ), | |
| 105 | + new GraphQLField( | |
| 106 | + 'isDefault', | |
| 107 | + 'Boolean', | |
| 108 | + 'is_default', | |
| 109 | +				esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso') | |
| 110 | + ), | |
| 111 | + new GraphQLOutputField( | |
| 112 | + 'isExpired', | |
| 113 | + 'Boolean', | |
| 114 | + 'is_expired', | |
| 115 | +				esc_html__('Flag indicating ticket is no longer available because its available dates have expired', 'event_espresso') | |
| 116 | + ), | |
| 117 | + new GraphQLOutputField( | |
| 118 | + 'isFree', | |
| 119 | + 'Boolean', | |
| 120 | + 'is_free', | |
| 121 | +				esc_html__('Flag indicating whether the ticket is free.', 'event_espresso') | |
| 122 | + ), | |
| 123 | + new GraphQLOutputField( | |
| 124 | + 'isOnSale', | |
| 125 | + 'Boolean', | |
| 126 | + 'is_on_sale', | |
| 127 | +				esc_html__('Flag indicating ticket ticket is on sale or not', 'event_espresso') | |
| 128 | + ), | |
| 129 | + new GraphQLOutputField( | |
| 130 | + 'isPending', | |
| 131 | + 'Boolean', | |
| 132 | + 'is_pending', | |
| 133 | +				esc_html__('Flag indicating ticket is yet to go on sale or not', 'event_espresso') | |
| 134 | + ), | |
| 135 | + new GraphQLField( | |
| 136 | + 'isRequired', | |
| 137 | + 'Boolean', | |
| 138 | + 'required', | |
| 139 | + esc_html__( | |
| 140 | + 'Flag indicating whether this ticket must be purchased with a transaction', | |
| 141 | + 'event_espresso' | |
| 142 | + ) | |
| 143 | + ), | |
| 144 | + new GraphQLOutputField( | |
| 145 | + 'isSoldOut', | |
| 146 | + 'Boolean', | |
| 147 | + null, | |
| 148 | +				esc_html__('Flag indicating whether the ticket is sold out', 'event_espresso'), | |
| 149 | + null, | |
| 150 | + [$this, 'getIsSoldOut'] | |
| 151 | + ), | |
| 152 | + new GraphQLField( | |
| 153 | + 'isTaxable', | |
| 154 | + 'Boolean', | |
| 155 | + 'taxable', | |
| 156 | + esc_html__( | |
| 157 | + 'Flag indicating whether there is tax applied on this ticket', | |
| 158 | + 'event_espresso' | |
| 159 | + ) | |
| 160 | + ), | |
| 161 | + new GraphQLField( | |
| 162 | + 'isTrashed', | |
| 163 | + 'Boolean', | |
| 164 | + 'deleted', | |
| 165 | +				esc_html__('Flag indicating ticket has been trashed.', 'event_espresso') | |
| 166 | + ), | |
| 167 | + new GraphQLField( | |
| 168 | + 'max', | |
| 169 | + 'Int', | |
| 170 | + 'max', | |
| 171 | + esc_html__( | |
| 172 | + 'Maximum quantity of this ticket that can be purchased in one transaction', | |
| 173 | + 'event_espresso' | |
| 174 | + ), | |
| 175 | + [$this, 'parseInfiniteValue'] | |
| 176 | + ), | |
| 177 | + new GraphQLField( | |
| 178 | + 'min', | |
| 179 | + 'Int', | |
| 180 | + 'min', | |
| 181 | +				esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso') | |
| 182 | + ), | |
| 183 | + new GraphQLField( | |
| 184 | + 'name', | |
| 185 | + 'String', | |
| 186 | + 'name', | |
| 187 | +				esc_html__('Ticket Name', 'event_espresso') | |
| 188 | + ), | |
| 189 | + new GraphQLField( | |
| 190 | + 'order', | |
| 191 | + 'Int', | |
| 192 | + 'order', | |
| 193 | +				esc_html__('The order in which the Datetime is displayed', 'event_espresso') | |
| 194 | + ), | |
| 195 | + new GraphQLOutputField( | |
| 196 | + 'parent', | |
| 197 | + $this->name(), | |
| 198 | + null, | |
| 199 | +				esc_html__('The parent ticket of the current ticket', 'event_espresso') | |
| 200 | + ), | |
| 201 | + new GraphQLInputField( | |
| 202 | + 'parent', | |
| 203 | + 'ID', | |
| 204 | + null, | |
| 205 | +				esc_html__('The parent ticket ID', 'event_espresso') | |
| 206 | + ), | |
| 207 | + new GraphQLField( | |
| 208 | + 'price', | |
| 209 | + 'Float', | |
| 210 | + 'price', | |
| 211 | +				esc_html__('Final calculated price for ticket', 'event_espresso') | |
| 212 | + ), | |
| 213 | + new GraphQLInputField( | |
| 214 | + 'prices', | |
| 215 | + ['list_of' => 'ID'], | |
| 216 | + null, | |
| 217 | + sprintf( | |
| 218 | + '%1$s %2$s', | |
| 219 | +					esc_html__('Globally unique IDs of the prices related to the ticket.', 'event_espresso'), | |
| 220 | +					esc_html__('Ignored if empty.', 'event_espresso') | |
| 221 | + ) | |
| 222 | + ), | |
| 223 | + new GraphQLField( | |
| 224 | + 'quantity', | |
| 225 | + 'Int', | |
| 226 | + 'qty', | |
| 227 | +				esc_html__('Quantity of this ticket that is available', 'event_espresso'), | |
| 228 | + [$this, 'parseInfiniteValue'] | |
| 229 | + ), | |
| 230 | + new GraphQLOutputField( | |
| 231 | + 'registrationCount', | |
| 232 | + 'Int', | |
| 233 | + 'count_registrations', | |
| 234 | +				esc_html__('Number of registrations for the ticket', 'event_espresso') | |
| 235 | + ), | |
| 236 | + new GraphQLField( | |
| 237 | + 'reserved', | |
| 238 | + 'Int', | |
| 239 | + 'reserved', | |
| 240 | + esc_html__( | |
| 241 | + 'Quantity of this ticket that is reserved, but not yet fully purchased', | |
| 242 | + 'event_espresso' | |
| 243 | + ) | |
| 244 | + ), | |
| 245 | + new GraphQLField( | |
| 246 | + 'reverseCalculate', | |
| 247 | + 'Boolean', | |
| 248 | + 'reverse_calculate', | |
| 249 | + esc_html__( | |
| 250 | + 'Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.', | |
| 251 | + 'event_espresso' | |
| 252 | + ) | |
| 253 | + ), | |
| 254 | + new GraphQLField( | |
| 255 | + 'row', | |
| 256 | + 'Int', | |
| 257 | + 'row', | |
| 258 | +				esc_html__('How tickets are displayed in the ui', 'event_espresso') | |
| 259 | + ), | |
| 260 | + new GraphQLField( | |
| 261 | + 'sold', | |
| 262 | + 'Int', | |
| 263 | + 'sold', | |
| 264 | +				esc_html__('Number of this ticket sold', 'event_espresso') | |
| 265 | + ), | |
| 266 | + new GraphQLOutputField( | |
| 267 | + 'status', | |
| 268 | + $this->namespace . 'TicketStatusEnum', | |
| 269 | + 'ticket_status', | |
| 270 | +				esc_html__('Ticket status', 'event_espresso') | |
| 271 | + ), | |
| 272 | + new GraphQLField( | |
| 273 | + 'startDate', | |
| 274 | + 'String', | |
| 275 | + 'start_date', | |
| 276 | +				esc_html__('Start date and time of the Ticket', 'event_espresso'), | |
| 277 | + [$this, 'formatDatetime'] | |
| 278 | + ), | |
| 279 | + new GraphQLField( | |
| 280 | + 'uses', | |
| 281 | + 'Int', | |
| 282 | + 'uses', | |
| 283 | +				esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'), | |
| 284 | + [$this, 'parseInfiniteValue'] | |
| 285 | + ), | |
| 286 | + new GraphQLOutputField( | |
| 287 | + 'wpUser', | |
| 288 | + 'User', | |
| 289 | + null, | |
| 290 | +				esc_html__('Ticket Creator', 'event_espresso') | |
| 291 | + ), | |
| 292 | + new GraphQLInputField( | |
| 293 | + 'wpUser', | |
| 294 | + 'Int', | |
| 295 | + null, | |
| 296 | +				esc_html__('Ticket Creator ID', 'event_espresso') | |
| 297 | + ), | |
| 298 | + ]; | |
| 299 | + } | |
| 300 | 300 | |
| 301 | 301 | |
| 302 | - /** | |
| 303 | - * @param EE_Ticket $source The source that's passed down the GraphQL queries | |
| 304 | - * @param array $args The inputArgs on the field | |
| 305 | - * @param AppContext $context The AppContext passed down the GraphQL tree | |
| 306 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree | |
| 307 | - * @return string | |
| 308 | - * @throws Exception | |
| 309 | - * @throws InvalidArgumentException | |
| 310 | - * @throws InvalidDataTypeException | |
| 311 | - * @throws InvalidInterfaceException | |
| 312 | - * @throws ReflectionException | |
| 313 | - * @throws UserError | |
| 314 | - * @throws UnexpectedEntityException | |
| 315 | - * @since $VID:$ | |
| 316 | - */ | |
| 317 | - public function getIsSoldOut(EE_Ticket $source, array $args, AppContext $context, ResolveInfo $info) | |
| 318 | -    { | |
| 319 | - return $source->ticket_status() === EE_Ticket::sold_out; | |
| 320 | - } | |
| 302 | + /** | |
| 303 | + * @param EE_Ticket $source The source that's passed down the GraphQL queries | |
| 304 | + * @param array $args The inputArgs on the field | |
| 305 | + * @param AppContext $context The AppContext passed down the GraphQL tree | |
| 306 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree | |
| 307 | + * @return string | |
| 308 | + * @throws Exception | |
| 309 | + * @throws InvalidArgumentException | |
| 310 | + * @throws InvalidDataTypeException | |
| 311 | + * @throws InvalidInterfaceException | |
| 312 | + * @throws ReflectionException | |
| 313 | + * @throws UserError | |
| 314 | + * @throws UnexpectedEntityException | |
| 315 | + * @since $VID:$ | |
| 316 | + */ | |
| 317 | + public function getIsSoldOut(EE_Ticket $source, array $args, AppContext $context, ResolveInfo $info) | |
| 318 | +	{ | |
| 319 | + return $source->ticket_status() === EE_Ticket::sold_out; | |
| 320 | + } | |
| 321 | 321 | |
| 322 | 322 | |
| 323 | - /** | |
| 324 | - * @param array $inputFields The mutation input fields. | |
| 325 | - * @throws InvalidArgumentException | |
| 326 | - * @throws ReflectionException | |
| 327 | - * @since $VID:$ | |
| 328 | - */ | |
| 329 | - public function registerMutations(array $inputFields) | |
| 330 | -    { | |
| 331 | - // Register mutation to update an entity. | |
| 332 | - register_graphql_mutation( | |
| 333 | - 'update' . $this->name(), | |
| 334 | - [ | |
| 335 | - 'inputFields' => $inputFields, | |
| 336 | - 'outputFields' => [ | |
| 337 | - lcfirst($this->name()) => [ | |
| 338 | - 'type' => $this->name(), | |
| 339 | - 'resolve' => [$this, 'resolveFromPayload'], | |
| 340 | - ], | |
| 341 | - ], | |
| 342 | - 'mutateAndGetPayload' => TicketUpdate::mutateAndGetPayload($this->model, $this), | |
| 343 | - ] | |
| 344 | - ); | |
| 345 | - // Register mutation to delete an entity. | |
| 346 | - register_graphql_mutation( | |
| 347 | - 'delete' . $this->name(), | |
| 348 | - [ | |
| 349 | - 'inputFields' => [ | |
| 350 | - 'id' => $inputFields['id'], | |
| 351 | - 'deletePermanently' => [ | |
| 352 | - 'type' => 'Boolean', | |
| 353 | -                        'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), | |
| 354 | - ], | |
| 355 | - ], | |
| 356 | - 'outputFields' => [ | |
| 357 | - lcfirst($this->name()) => [ | |
| 358 | - 'type' => $this->name(), | |
| 359 | -                        'description' => esc_html__('The object before it was deleted', 'event_espresso'), | |
| 360 | -                        'resolve'     => static function ($payload) { | |
| 361 | - $deleted = (object) $payload['deleted']; | |
| 323 | + /** | |
| 324 | + * @param array $inputFields The mutation input fields. | |
| 325 | + * @throws InvalidArgumentException | |
| 326 | + * @throws ReflectionException | |
| 327 | + * @since $VID:$ | |
| 328 | + */ | |
| 329 | + public function registerMutations(array $inputFields) | |
| 330 | +	{ | |
| 331 | + // Register mutation to update an entity. | |
| 332 | + register_graphql_mutation( | |
| 333 | + 'update' . $this->name(), | |
| 334 | + [ | |
| 335 | + 'inputFields' => $inputFields, | |
| 336 | + 'outputFields' => [ | |
| 337 | + lcfirst($this->name()) => [ | |
| 338 | + 'type' => $this->name(), | |
| 339 | + 'resolve' => [$this, 'resolveFromPayload'], | |
| 340 | + ], | |
| 341 | + ], | |
| 342 | + 'mutateAndGetPayload' => TicketUpdate::mutateAndGetPayload($this->model, $this), | |
| 343 | + ] | |
| 344 | + ); | |
| 345 | + // Register mutation to delete an entity. | |
| 346 | + register_graphql_mutation( | |
| 347 | + 'delete' . $this->name(), | |
| 348 | + [ | |
| 349 | + 'inputFields' => [ | |
| 350 | + 'id' => $inputFields['id'], | |
| 351 | + 'deletePermanently' => [ | |
| 352 | + 'type' => 'Boolean', | |
| 353 | +						'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), | |
| 354 | + ], | |
| 355 | + ], | |
| 356 | + 'outputFields' => [ | |
| 357 | + lcfirst($this->name()) => [ | |
| 358 | + 'type' => $this->name(), | |
| 359 | +						'description' => esc_html__('The object before it was deleted', 'event_espresso'), | |
| 360 | +						'resolve'     => static function ($payload) { | |
| 361 | + $deleted = (object) $payload['deleted']; | |
| 362 | 362 | |
| 363 | - return ! empty($deleted) ? $deleted : null; | |
| 364 | - }, | |
| 365 | - ], | |
| 366 | - ], | |
| 367 | - 'mutateAndGetPayload' => TicketDelete::mutateAndGetPayload($this->model, $this), | |
| 368 | - ] | |
| 369 | - ); | |
| 363 | + return ! empty($deleted) ? $deleted : null; | |
| 364 | + }, | |
| 365 | + ], | |
| 366 | + ], | |
| 367 | + 'mutateAndGetPayload' => TicketDelete::mutateAndGetPayload($this->model, $this), | |
| 368 | + ] | |
| 369 | + ); | |
| 370 | 370 | |
| 371 | - // remove primary key from input. | |
| 372 | - unset($inputFields['id']); | |
| 373 | - // Register mutation to update an entity. | |
| 374 | - register_graphql_mutation( | |
| 375 | - 'create' . $this->name(), | |
| 376 | - [ | |
| 377 | - 'inputFields' => $inputFields, | |
| 378 | - 'outputFields' => [ | |
| 379 | - lcfirst($this->name()) => [ | |
| 380 | - 'type' => $this->name(), | |
| 381 | - 'resolve' => [$this, 'resolveFromPayload'], | |
| 382 | - ], | |
| 383 | - ], | |
| 384 | - 'mutateAndGetPayload' => TicketCreate::mutateAndGetPayload($this->model, $this), | |
| 385 | - ] | |
| 386 | - ); | |
| 387 | - } | |
| 371 | + // remove primary key from input. | |
| 372 | + unset($inputFields['id']); | |
| 373 | + // Register mutation to update an entity. | |
| 374 | + register_graphql_mutation( | |
| 375 | + 'create' . $this->name(), | |
| 376 | + [ | |
| 377 | + 'inputFields' => $inputFields, | |
| 378 | + 'outputFields' => [ | |
| 379 | + lcfirst($this->name()) => [ | |
| 380 | + 'type' => $this->name(), | |
| 381 | + 'resolve' => [$this, 'resolveFromPayload'], | |
| 382 | + ], | |
| 383 | + ], | |
| 384 | + 'mutateAndGetPayload' => TicketCreate::mutateAndGetPayload($this->model, $this), | |
| 385 | + ] | |
| 386 | + ); | |
| 387 | + } | |
| 388 | 388 | } |