@@ -36,7 +36,7 @@ |
||
| 36 | 36 | |
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | - * @return GraphQLFieldInterface[] |
|
| 39 | + * @return GraphQLField[] |
|
| 40 | 40 | * @since $VID:$ |
| 41 | 41 | */ |
| 42 | 42 | public function getFields() |
@@ -21,188 +21,188 @@ |
||
| 21 | 21 | class Event extends TypeBase |
| 22 | 22 | { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Event constructor. |
|
| 26 | - * |
|
| 27 | - * @param EEM_Event $event_model |
|
| 28 | - */ |
|
| 29 | - public function __construct(EEM_Event $event_model) |
|
| 30 | - { |
|
| 31 | - $this->model = $event_model; |
|
| 32 | - $this->setName('Event'); |
|
| 33 | - $this->setIsCustomPostType(true); |
|
| 34 | - parent::__construct(); |
|
| 35 | - } |
|
| 24 | + /** |
|
| 25 | + * Event constructor. |
|
| 26 | + * |
|
| 27 | + * @param EEM_Event $event_model |
|
| 28 | + */ |
|
| 29 | + public function __construct(EEM_Event $event_model) |
|
| 30 | + { |
|
| 31 | + $this->model = $event_model; |
|
| 32 | + $this->setName('Event'); |
|
| 33 | + $this->setIsCustomPostType(true); |
|
| 34 | + parent::__construct(); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @return GraphQLFieldInterface[] |
|
| 40 | - * @since $VID:$ |
|
| 41 | - */ |
|
| 42 | - public function getFields() |
|
| 43 | - { |
|
| 44 | - return [ |
|
| 45 | - new GraphQLField( |
|
| 46 | - 'name', |
|
| 47 | - 'String', |
|
| 48 | - 'name', |
|
| 49 | - esc_html__('Event Name', 'event_espresso') |
|
| 50 | - ), |
|
| 51 | - new GraphQLField( |
|
| 52 | - 'desc', |
|
| 53 | - 'String', |
|
| 54 | - 'description', |
|
| 55 | - esc_html__('Event Description', 'event_espresso') |
|
| 56 | - ), |
|
| 57 | - new GraphQLField( |
|
| 58 | - 'shortDesc', |
|
| 59 | - 'String', |
|
| 60 | - 'short_description', |
|
| 61 | - esc_html__('Event Short Description', 'event_espresso') |
|
| 62 | - ), |
|
| 63 | - new GraphQLField( |
|
| 64 | - 'created', |
|
| 65 | - 'String', |
|
| 66 | - 'created', |
|
| 67 | - esc_html__('Date/Time Event Created', 'event_espresso') |
|
| 68 | - ), |
|
| 69 | - new GraphQLOutputField( |
|
| 70 | - 'wpUser', |
|
| 71 | - 'User', |
|
| 72 | - null, |
|
| 73 | - esc_html__('Event Creator', 'event_espresso') |
|
| 74 | - ), |
|
| 75 | - new GraphQLInputField( |
|
| 76 | - 'wpUser', |
|
| 77 | - 'Int', |
|
| 78 | - null, |
|
| 79 | - esc_html__('Event Creator ID', 'event_espresso') |
|
| 80 | - ), |
|
| 81 | - new GraphQLField( |
|
| 82 | - 'order', |
|
| 83 | - 'Int', |
|
| 84 | - 'order', |
|
| 85 | - esc_html__('Event Menu Order', 'event_espresso') |
|
| 86 | - ), |
|
| 87 | - new GraphQLField( |
|
| 88 | - 'displayDesc', |
|
| 89 | - 'Boolean', |
|
| 90 | - 'display_description', |
|
| 91 | - esc_html__('Display Description Flag', 'event_espresso') |
|
| 92 | - ), |
|
| 93 | - new GraphQLField( |
|
| 94 | - 'displayTicketSelector', |
|
| 95 | - 'Boolean', |
|
| 96 | - 'display_ticket_selector', |
|
| 97 | - esc_html__('Display Ticket Selector Flag', 'event_espresso') |
|
| 98 | - ), |
|
| 99 | - new GraphQLField( |
|
| 100 | - 'visibleOn', |
|
| 101 | - 'String', |
|
| 102 | - 'visible_on', |
|
| 103 | - esc_html__('Event Visible Date', 'event_espresso') |
|
| 104 | - ), |
|
| 105 | - new GraphQLField( |
|
| 106 | - 'additionalLimit', |
|
| 107 | - 'String', |
|
| 108 | - 'additional_limit', |
|
| 109 | - esc_html__('Limit of Additional Registrations on Same Transaction', 'event_espresso') |
|
| 110 | - ), |
|
| 111 | - new GraphQLField( |
|
| 112 | - 'phone', |
|
| 113 | - 'String', |
|
| 114 | - 'phone', |
|
| 115 | - esc_html__('Event Phone Number', 'event_espresso') |
|
| 116 | - ), |
|
| 117 | - new GraphQLField( |
|
| 118 | - 'memberOnly', |
|
| 119 | - 'Boolean', |
|
| 120 | - 'member_only', |
|
| 121 | - esc_html__('Member-Only Event Flag', 'event_espresso') |
|
| 122 | - ), |
|
| 123 | - new GraphQLField( |
|
| 124 | - 'allowOverflow', |
|
| 125 | - 'Boolean', |
|
| 126 | - 'allow_overflow', |
|
| 127 | - esc_html__('Allow Overflow on Event', 'event_espresso') |
|
| 128 | - ), |
|
| 129 | - new GraphQLField( |
|
| 130 | - 'timezoneString', |
|
| 131 | - 'String', |
|
| 132 | - 'timezone_string', |
|
| 133 | - esc_html__('Timezone (name) for Event times', 'event_espresso') |
|
| 134 | - ), |
|
| 135 | - new GraphQLField( |
|
| 136 | - 'externalUrl', |
|
| 137 | - 'String', |
|
| 138 | - 'external_url', |
|
| 139 | - esc_html__('URL of Event Page if hosted elsewhere', 'event_espresso') |
|
| 140 | - ), |
|
| 141 | - new GraphQLField( |
|
| 142 | - 'donations', |
|
| 143 | - 'Boolean', |
|
| 144 | - 'donations', |
|
| 145 | - esc_html__('Accept Donations?', 'event_espresso') |
|
| 146 | - ), |
|
| 147 | - new GraphQLField( |
|
| 148 | - 'isSoldOut', |
|
| 149 | - 'Boolean', |
|
| 150 | - 'is_sold_out', |
|
| 151 | - esc_html__('Flag indicating whether the tickets sold for the event, met or exceed the registration limit', |
|
| 152 | - 'event_espresso') |
|
| 153 | - ), |
|
| 154 | - new GraphQLField( |
|
| 155 | - 'isPostponed', |
|
| 156 | - 'Boolean', |
|
| 157 | - 'is_postponed', |
|
| 158 | - esc_html__('Flag indicating whether the event is marked as postponed', 'event_espresso') |
|
| 159 | - ), |
|
| 160 | - new GraphQLField( |
|
| 161 | - 'isCancelled', |
|
| 162 | - 'Boolean', |
|
| 163 | - 'is_cancelled', |
|
| 164 | - esc_html__('Flag indicating whether the event is marked as cancelled', 'event_espresso') |
|
| 165 | - ), |
|
| 166 | - new GraphQLField( |
|
| 167 | - 'isUpcoming', |
|
| 168 | - 'Boolean', |
|
| 169 | - 'is_upcoming', |
|
| 170 | - esc_html__('Whether the event is upcoming', 'event_espresso') |
|
| 171 | - ), |
|
| 172 | - new GraphQLField( |
|
| 173 | - 'isActive', |
|
| 174 | - 'Boolean', |
|
| 175 | - 'is_active', |
|
| 176 | - esc_html__('Flag indicating event is active', 'event_espresso') |
|
| 177 | - ), |
|
| 178 | - new GraphQLField( |
|
| 179 | - 'isInactive', |
|
| 180 | - 'Boolean', |
|
| 181 | - 'is_inactive', |
|
| 182 | - esc_html__('Flag indicating event is inactive', 'event_espresso') |
|
| 183 | - ), |
|
| 184 | - new GraphQLField( |
|
| 185 | - 'isExpired', |
|
| 186 | - 'Boolean', |
|
| 187 | - 'is_expired', |
|
| 188 | - esc_html__('Flag indicating event is expired or not', 'event_espresso') |
|
| 189 | - ), |
|
| 190 | - ]; |
|
| 191 | - } |
|
| 38 | + /** |
|
| 39 | + * @return GraphQLFieldInterface[] |
|
| 40 | + * @since $VID:$ |
|
| 41 | + */ |
|
| 42 | + public function getFields() |
|
| 43 | + { |
|
| 44 | + return [ |
|
| 45 | + new GraphQLField( |
|
| 46 | + 'name', |
|
| 47 | + 'String', |
|
| 48 | + 'name', |
|
| 49 | + esc_html__('Event Name', 'event_espresso') |
|
| 50 | + ), |
|
| 51 | + new GraphQLField( |
|
| 52 | + 'desc', |
|
| 53 | + 'String', |
|
| 54 | + 'description', |
|
| 55 | + esc_html__('Event Description', 'event_espresso') |
|
| 56 | + ), |
|
| 57 | + new GraphQLField( |
|
| 58 | + 'shortDesc', |
|
| 59 | + 'String', |
|
| 60 | + 'short_description', |
|
| 61 | + esc_html__('Event Short Description', 'event_espresso') |
|
| 62 | + ), |
|
| 63 | + new GraphQLField( |
|
| 64 | + 'created', |
|
| 65 | + 'String', |
|
| 66 | + 'created', |
|
| 67 | + esc_html__('Date/Time Event Created', 'event_espresso') |
|
| 68 | + ), |
|
| 69 | + new GraphQLOutputField( |
|
| 70 | + 'wpUser', |
|
| 71 | + 'User', |
|
| 72 | + null, |
|
| 73 | + esc_html__('Event Creator', 'event_espresso') |
|
| 74 | + ), |
|
| 75 | + new GraphQLInputField( |
|
| 76 | + 'wpUser', |
|
| 77 | + 'Int', |
|
| 78 | + null, |
|
| 79 | + esc_html__('Event Creator ID', 'event_espresso') |
|
| 80 | + ), |
|
| 81 | + new GraphQLField( |
|
| 82 | + 'order', |
|
| 83 | + 'Int', |
|
| 84 | + 'order', |
|
| 85 | + esc_html__('Event Menu Order', 'event_espresso') |
|
| 86 | + ), |
|
| 87 | + new GraphQLField( |
|
| 88 | + 'displayDesc', |
|
| 89 | + 'Boolean', |
|
| 90 | + 'display_description', |
|
| 91 | + esc_html__('Display Description Flag', 'event_espresso') |
|
| 92 | + ), |
|
| 93 | + new GraphQLField( |
|
| 94 | + 'displayTicketSelector', |
|
| 95 | + 'Boolean', |
|
| 96 | + 'display_ticket_selector', |
|
| 97 | + esc_html__('Display Ticket Selector Flag', 'event_espresso') |
|
| 98 | + ), |
|
| 99 | + new GraphQLField( |
|
| 100 | + 'visibleOn', |
|
| 101 | + 'String', |
|
| 102 | + 'visible_on', |
|
| 103 | + esc_html__('Event Visible Date', 'event_espresso') |
|
| 104 | + ), |
|
| 105 | + new GraphQLField( |
|
| 106 | + 'additionalLimit', |
|
| 107 | + 'String', |
|
| 108 | + 'additional_limit', |
|
| 109 | + esc_html__('Limit of Additional Registrations on Same Transaction', 'event_espresso') |
|
| 110 | + ), |
|
| 111 | + new GraphQLField( |
|
| 112 | + 'phone', |
|
| 113 | + 'String', |
|
| 114 | + 'phone', |
|
| 115 | + esc_html__('Event Phone Number', 'event_espresso') |
|
| 116 | + ), |
|
| 117 | + new GraphQLField( |
|
| 118 | + 'memberOnly', |
|
| 119 | + 'Boolean', |
|
| 120 | + 'member_only', |
|
| 121 | + esc_html__('Member-Only Event Flag', 'event_espresso') |
|
| 122 | + ), |
|
| 123 | + new GraphQLField( |
|
| 124 | + 'allowOverflow', |
|
| 125 | + 'Boolean', |
|
| 126 | + 'allow_overflow', |
|
| 127 | + esc_html__('Allow Overflow on Event', 'event_espresso') |
|
| 128 | + ), |
|
| 129 | + new GraphQLField( |
|
| 130 | + 'timezoneString', |
|
| 131 | + 'String', |
|
| 132 | + 'timezone_string', |
|
| 133 | + esc_html__('Timezone (name) for Event times', 'event_espresso') |
|
| 134 | + ), |
|
| 135 | + new GraphQLField( |
|
| 136 | + 'externalUrl', |
|
| 137 | + 'String', |
|
| 138 | + 'external_url', |
|
| 139 | + esc_html__('URL of Event Page if hosted elsewhere', 'event_espresso') |
|
| 140 | + ), |
|
| 141 | + new GraphQLField( |
|
| 142 | + 'donations', |
|
| 143 | + 'Boolean', |
|
| 144 | + 'donations', |
|
| 145 | + esc_html__('Accept Donations?', 'event_espresso') |
|
| 146 | + ), |
|
| 147 | + new GraphQLField( |
|
| 148 | + 'isSoldOut', |
|
| 149 | + 'Boolean', |
|
| 150 | + 'is_sold_out', |
|
| 151 | + esc_html__('Flag indicating whether the tickets sold for the event, met or exceed the registration limit', |
|
| 152 | + 'event_espresso') |
|
| 153 | + ), |
|
| 154 | + new GraphQLField( |
|
| 155 | + 'isPostponed', |
|
| 156 | + 'Boolean', |
|
| 157 | + 'is_postponed', |
|
| 158 | + esc_html__('Flag indicating whether the event is marked as postponed', 'event_espresso') |
|
| 159 | + ), |
|
| 160 | + new GraphQLField( |
|
| 161 | + 'isCancelled', |
|
| 162 | + 'Boolean', |
|
| 163 | + 'is_cancelled', |
|
| 164 | + esc_html__('Flag indicating whether the event is marked as cancelled', 'event_espresso') |
|
| 165 | + ), |
|
| 166 | + new GraphQLField( |
|
| 167 | + 'isUpcoming', |
|
| 168 | + 'Boolean', |
|
| 169 | + 'is_upcoming', |
|
| 170 | + esc_html__('Whether the event is upcoming', 'event_espresso') |
|
| 171 | + ), |
|
| 172 | + new GraphQLField( |
|
| 173 | + 'isActive', |
|
| 174 | + 'Boolean', |
|
| 175 | + 'is_active', |
|
| 176 | + esc_html__('Flag indicating event is active', 'event_espresso') |
|
| 177 | + ), |
|
| 178 | + new GraphQLField( |
|
| 179 | + 'isInactive', |
|
| 180 | + 'Boolean', |
|
| 181 | + 'is_inactive', |
|
| 182 | + esc_html__('Flag indicating event is inactive', 'event_espresso') |
|
| 183 | + ), |
|
| 184 | + new GraphQLField( |
|
| 185 | + 'isExpired', |
|
| 186 | + 'Boolean', |
|
| 187 | + 'is_expired', |
|
| 188 | + esc_html__('Flag indicating event is expired or not', 'event_espresso') |
|
| 189 | + ), |
|
| 190 | + ]; |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | 193 | |
| 194 | - /** |
|
| 195 | - * Extends the existing WP GraphQL mutations. |
|
| 196 | - * |
|
| 197 | - * @since $VID:$ |
|
| 198 | - */ |
|
| 199 | - public function extendMutations() |
|
| 200 | - { |
|
| 201 | - add_action( |
|
| 202 | - 'graphql_post_object_mutation_update_additional_data', |
|
| 203 | - EventUpdate::mutateFields($this->model, $this), |
|
| 204 | - 10, |
|
| 205 | - 6 |
|
| 206 | - ); |
|
| 207 | - } |
|
| 194 | + /** |
|
| 195 | + * Extends the existing WP GraphQL mutations. |
|
| 196 | + * |
|
| 197 | + * @since $VID:$ |
|
| 198 | + */ |
|
| 199 | + public function extendMutations() |
|
| 200 | + { |
|
| 201 | + add_action( |
|
| 202 | + 'graphql_post_object_mutation_update_additional_data', |
|
| 203 | + EventUpdate::mutateFields($this->model, $this), |
|
| 204 | + 10, |
|
| 205 | + 6 |
|
| 206 | + ); |
|
| 207 | + } |
|
| 208 | 208 | } |
@@ -23,16 +23,16 @@ |
||
| 23 | 23 | |
| 24 | 24 | $args = []; |
| 25 | 25 | |
| 26 | - if ( ! empty( $input['event'] ) ) { |
|
| 27 | - $args['EVT_ID'] = absint( $input['event'] ); |
|
| 26 | + if ( ! empty($input['event'])) { |
|
| 27 | + $args['EVT_ID'] = absint($input['event']); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - if ( ! empty( $input['name'] ) ) { |
|
| 31 | - $args['DTT_name'] = sanitize_text_field( $input['name'] ); |
|
| 30 | + if ( ! empty($input['name'])) { |
|
| 31 | + $args['DTT_name'] = sanitize_text_field($input['name']); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - if ( ! empty( $input['description'] ) ) { |
|
| 35 | - $args['DTT_description'] = sanitize_text_field( $input['description'] ); |
|
| 34 | + if ( ! empty($input['description'])) { |
|
| 35 | + $args['DTT_description'] = sanitize_text_field($input['description']); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | // Likewise the other fields... |
@@ -23,16 +23,16 @@ |
||
| 23 | 23 | |
| 24 | 24 | $args = []; |
| 25 | 25 | |
| 26 | - if ( ! empty( $input['name'] ) ) { |
|
| 27 | - $args['VNU_name'] = sanitize_text_field( $input['name'] ); |
|
| 26 | + if ( ! empty($input['name'])) { |
|
| 27 | + $args['VNU_name'] = sanitize_text_field($input['name']); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - if ( ! empty( $input['desc'] ) ) { |
|
| 31 | - $args['VNU_desc'] = sanitize_text_field( $input['desc'] ); |
|
| 30 | + if ( ! empty($input['desc'])) { |
|
| 31 | + $args['VNU_desc'] = sanitize_text_field($input['desc']); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - if ( ! empty( $input['shortDesc'] ) ) { |
|
| 35 | - $args['VNU_short_desc'] = sanitize_text_field( $input['shortDesc'] ); |
|
| 34 | + if ( ! empty($input['shortDesc'])) { |
|
| 35 | + $args['VNU_short_desc'] = sanitize_text_field($input['shortDesc']); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | // Likewise the other fields... |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | * |
| 15 | 15 | * @param EEM_Datetime $model |
| 16 | 16 | * @param Datetime $type |
| 17 | - * @return callable |
|
| 17 | + * @return \Closure |
|
| 18 | 18 | */ |
| 19 | 19 | public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type) |
| 20 | 20 | { |
@@ -4,13 +4,11 @@ |
||
| 4 | 4 | use EEM_Datetime; |
| 5 | 5 | use EE_Datetime; |
| 6 | 6 | use EventEspresso\core\domain\services\graphql\types\Datetime; |
| 7 | - |
|
| 8 | 7 | use EE_Error; |
| 9 | 8 | use InvalidArgumentException; |
| 10 | 9 | use ReflectionException; |
| 11 | 10 | use EventEspresso\core\exceptions\InvalidDataTypeException; |
| 12 | 11 | use EventEspresso\core\exceptions\InvalidInterfaceException; |
| 13 | - |
|
| 14 | 12 | use GraphQL\Type\Definition\ResolveInfo; |
| 15 | 13 | use WPGraphQL\AppContext; |
| 16 | 14 | use GraphQL\Error\UserError; |
@@ -12,8 +12,8 @@ |
||
| 12 | 12 | /** |
| 13 | 13 | * Defines the mutation data modification closure. |
| 14 | 14 | * |
| 15 | - * @param EEM_Datetime $model |
|
| 16 | - * @param Datetime $type |
|
| 15 | + * @param EEM_Datetime $model |
|
| 16 | + * @param Datetime $type |
|
| 17 | 17 | * @return callable |
| 18 | 18 | */ |
| 19 | 19 | public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type) |
@@ -40,14 +40,14 @@ discard block |
||
| 40 | 40 | * @throws InvalidDataTypeException |
| 41 | 41 | * @throws EE_Error |
| 42 | 42 | */ |
| 43 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) |
|
| 43 | + return static function($input, AppContext $context, ResolveInfo $info) use ($model, $type) |
|
| 44 | 44 | { |
| 45 | 45 | /** |
| 46 | 46 | * Stop now if a user isn't allowed to create a datetime. |
| 47 | 47 | */ |
| 48 | - if (! current_user_can('ee_edit_events')) { |
|
| 48 | + if ( ! current_user_can('ee_edit_events')) { |
|
| 49 | 49 | // translators: the %1$s is the name of the object being mutated |
| 50 | - throw new UserError(sprintf(__('Sorry, you are not allowed to edit %1$s', 'event_espresso' ), $type->name())); |
|
| 50 | + throw new UserError(sprintf(__('Sorry, you are not allowed to edit %1$s', 'event_espresso'), $type->name())); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | $id = ! empty($input['id']) ? absint($input['id']) : 0; |
@@ -60,16 +60,16 @@ discard block |
||
| 60 | 60 | /** |
| 61 | 61 | * If there's no existing datetime, throw an exception |
| 62 | 62 | */ |
| 63 | - if (! $id || ! ($entity instanceof EE_Datetime)) { |
|
| 63 | + if ( ! $id || ! ($entity instanceof EE_Datetime)) { |
|
| 64 | 64 | // translators: the placeholder is the name of the type being updated |
| 65 | - throw new UserError(sprintf(__( 'No %1$s could be found to delete', 'event_espresso' ), $type->name())); |
|
| 65 | + throw new UserError(sprintf(__('No %1$s could be found to delete', 'event_espresso'), $type->name())); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | // Delete the entity |
| 69 | 69 | $result = ! empty($input['deletePermanently']) ? $entity->delete_permanently() : $entity->delete(); |
| 70 | 70 | |
| 71 | 71 | if (empty($result)) { |
| 72 | - throw new UserError(__( 'The object failed to delete but no error was provided', 'event_espresso')); |
|
| 72 | + throw new UserError(__('The object failed to delete but no error was provided', 'event_espresso')); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | return [ |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | * |
| 25 | 25 | * @param EEM_Ticket $model |
| 26 | 26 | * @param Ticket $type |
| 27 | - * @return callable |
|
| 27 | + * @return \Closure |
|
| 28 | 28 | */ |
| 29 | 29 | public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
| 30 | 30 | { |
@@ -5,13 +5,11 @@ |
||
| 5 | 5 | use EE_Ticket; |
| 6 | 6 | use EventEspresso\core\domain\services\graphql\types\Ticket; |
| 7 | 7 | use EventEspresso\core\domain\services\graphql\data\mutations\TicketMutation; |
| 8 | - |
|
| 9 | 8 | use EE_Error; |
| 10 | 9 | use InvalidArgumentException; |
| 11 | 10 | use ReflectionException; |
| 12 | 11 | use EventEspresso\core\exceptions\InvalidDataTypeException; |
| 13 | 12 | use EventEspresso\core\exceptions\InvalidInterfaceException; |
| 14 | - |
|
| 15 | 13 | use GraphQL\Type\Definition\ResolveInfo; |
| 16 | 14 | use WPGraphQL\AppContext; |
| 17 | 15 | use GraphQL\Error\UserError; |
@@ -22,8 +22,8 @@ |
||
| 22 | 22 | /** |
| 23 | 23 | * Defines the mutation data modification closure. |
| 24 | 24 | * |
| 25 | - * @param EEM_Ticket $model |
|
| 26 | - * @param Ticket $type |
|
| 25 | + * @param EEM_Ticket $model |
|
| 26 | + * @param Ticket $type |
|
| 27 | 27 | * @return callable |
| 28 | 28 | */ |
| 29 | 29 | public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
@@ -42,15 +42,15 @@ discard block |
||
| 42 | 42 | * @throws InvalidDataTypeException |
| 43 | 43 | * @throws EE_Error |
| 44 | 44 | */ |
| 45 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) |
|
| 45 | + return static function($input, AppContext $context, ResolveInfo $info) use ($model, $type) |
|
| 46 | 46 | { |
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * Stop now if a user isn't allowed to create a datetime. |
| 50 | 50 | */ |
| 51 | - if (! current_user_can('ee_edit_events')) { |
|
| 51 | + if ( ! current_user_can('ee_edit_events')) { |
|
| 52 | 52 | // translators: the %1$s is the name of the object being mutated |
| 53 | - throw new UserError(sprintf(__('Sorry, you are not allowed to create %1$s', 'event_espresso' ), $type->name())); |
|
| 53 | + throw new UserError(sprintf(__('Sorry, you are not allowed to create %1$s', 'event_espresso'), $type->name())); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | $args = TicketMutation::prepare_fields($input); |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $id = $entity->save(); |
| 60 | 60 | |
| 61 | 61 | if (empty($id)) { |
| 62 | - throw new UserError(__( 'The object failed to create but no error was provided', 'event_espresso')); |
|
| 62 | + throw new UserError(__('The object failed to create but no error was provided', 'event_espresso')); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | return [ |
@@ -4,13 +4,11 @@ |
||
| 4 | 4 | use EEM_Ticket; |
| 5 | 5 | use EE_Ticket; |
| 6 | 6 | use EventEspresso\core\domain\services\graphql\types\Ticket; |
| 7 | - |
|
| 8 | 7 | use EE_Error; |
| 9 | 8 | use InvalidArgumentException; |
| 10 | 9 | use ReflectionException; |
| 11 | 10 | use EventEspresso\core\exceptions\InvalidDataTypeException; |
| 12 | 11 | use EventEspresso\core\exceptions\InvalidInterfaceException; |
| 13 | - |
|
| 14 | 12 | use GraphQL\Type\Definition\ResolveInfo; |
| 15 | 13 | use WPGraphQL\AppContext; |
| 16 | 14 | use GraphQL\Error\UserError; |
@@ -40,14 +40,14 @@ discard block |
||
| 40 | 40 | * @throws InvalidDataTypeException |
| 41 | 41 | * @throws EE_Error |
| 42 | 42 | */ |
| 43 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) |
|
| 43 | + return static function($input, AppContext $context, ResolveInfo $info) use ($model, $type) |
|
| 44 | 44 | { |
| 45 | 45 | /** |
| 46 | 46 | * Stop now if a user isn't allowed to create a datetime. |
| 47 | 47 | */ |
| 48 | - if (! current_user_can('ee_edit_events')) { |
|
| 48 | + if ( ! current_user_can('ee_edit_events')) { |
|
| 49 | 49 | // translators: the %1$s is the name of the object being mutated |
| 50 | - throw new UserError(sprintf(__('Sorry, you are not allowed to edit %1$s', 'event_espresso' ), $type->name())); |
|
| 50 | + throw new UserError(sprintf(__('Sorry, you are not allowed to edit %1$s', 'event_espresso'), $type->name())); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | $id = ! empty($input['id']) ? absint($input['id']) : 0; |
@@ -60,16 +60,16 @@ discard block |
||
| 60 | 60 | /** |
| 61 | 61 | * If there's no existing datetime, throw an exception |
| 62 | 62 | */ |
| 63 | - if (! $id || ! ($entity instanceof EE_Ticket)) { |
|
| 63 | + if ( ! $id || ! ($entity instanceof EE_Ticket)) { |
|
| 64 | 64 | // translators: the placeholder is the name of the type being updated |
| 65 | - throw new UserError(sprintf(__( 'No %1$s could be found to delete', 'event_espresso' ), $type->name())); |
|
| 65 | + throw new UserError(sprintf(__('No %1$s could be found to delete', 'event_espresso'), $type->name())); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | // Delete the entity |
| 69 | 69 | $result = ! empty($input['deletePermanently']) ? $entity->delete_permanently() : $entity->delete(); |
| 70 | 70 | |
| 71 | 71 | if (empty($result)) { |
| 72 | - throw new UserError(__( 'The object failed to delete but no error was provided', 'event_espresso')); |
|
| 72 | + throw new UserError(__('The object failed to delete but no error was provided', 'event_espresso')); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | return [ |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | * |
| 25 | 25 | * @param EEM_Ticket $model |
| 26 | 26 | * @param Ticket $type |
| 27 | - * @return callable |
|
| 27 | + * @return \Closure |
|
| 28 | 28 | */ |
| 29 | 29 | public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
| 30 | 30 | { |
@@ -22,8 +22,8 @@ |
||
| 22 | 22 | /** |
| 23 | 23 | * Defines the mutation data modification closure. |
| 24 | 24 | * |
| 25 | - * @param EEM_Ticket $model |
|
| 26 | - * @param Ticket $type |
|
| 25 | + * @param EEM_Ticket $model |
|
| 26 | + * @param Ticket $type |
|
| 27 | 27 | * @return callable |
| 28 | 28 | */ |
| 29 | 29 | public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | - * @return GraphQLFieldInterface[] |
|
| 42 | + * @return GraphQLField[] |
|
| 43 | 43 | * @since $VID:$ |
| 44 | 44 | */ |
| 45 | 45 | protected function getFields() |
@@ -23,243 +23,243 @@ |
||
| 23 | 23 | class Ticket extends TypeBase |
| 24 | 24 | { |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Ticket constructor. |
|
| 28 | - * |
|
| 29 | - * @param EEM_Ticket $ticket_model |
|
| 30 | - */ |
|
| 31 | - public function __construct(EEM_Ticket $ticket_model) |
|
| 32 | - { |
|
| 33 | - $this->model = $ticket_model; |
|
| 34 | - $this->setName('Ticket'); |
|
| 35 | - $this->setDescription(__('A ticket for an event date', 'event_espresso')); |
|
| 36 | - $this->setIsCustomPostType(false); |
|
| 37 | - parent::__construct(); |
|
| 38 | - } |
|
| 26 | + /** |
|
| 27 | + * Ticket constructor. |
|
| 28 | + * |
|
| 29 | + * @param EEM_Ticket $ticket_model |
|
| 30 | + */ |
|
| 31 | + public function __construct(EEM_Ticket $ticket_model) |
|
| 32 | + { |
|
| 33 | + $this->model = $ticket_model; |
|
| 34 | + $this->setName('Ticket'); |
|
| 35 | + $this->setDescription(__('A ticket for an event date', 'event_espresso')); |
|
| 36 | + $this->setIsCustomPostType(false); |
|
| 37 | + parent::__construct(); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @return GraphQLFieldInterface[] |
|
| 43 | - * @since $VID:$ |
|
| 44 | - */ |
|
| 45 | - protected function getFields() |
|
| 46 | - { |
|
| 47 | - return [ |
|
| 48 | - new GraphQLField( |
|
| 49 | - 'id', |
|
| 50 | - ['non_null' => 'Int'], |
|
| 51 | - 'ID', |
|
| 52 | - esc_html__('Ticket ID', 'event_espresso') |
|
| 53 | - ), |
|
| 54 | - new GraphQLField( |
|
| 55 | - 'name', |
|
| 56 | - 'String', |
|
| 57 | - 'name', |
|
| 58 | - esc_html__('Ticket Name', 'event_espresso') |
|
| 59 | - ), |
|
| 60 | - new GraphQLField( |
|
| 61 | - 'description', |
|
| 62 | - 'String', |
|
| 63 | - 'description', |
|
| 64 | - esc_html__('Description of Ticket', 'event_espresso') |
|
| 65 | - ), |
|
| 66 | - new GraphQLField( |
|
| 67 | - 'startDate', |
|
| 68 | - 'String', |
|
| 69 | - 'start_date', |
|
| 70 | - esc_html__('Start time/date of Ticket', 'event_espresso') |
|
| 71 | - ), |
|
| 72 | - new GraphQLField( |
|
| 73 | - 'endDate', |
|
| 74 | - 'String', |
|
| 75 | - 'end_date', |
|
| 76 | - esc_html__('End time/date of Ticket', 'event_espresso') |
|
| 77 | - ), |
|
| 78 | - new GraphQLField( |
|
| 79 | - 'min', |
|
| 80 | - 'Int', |
|
| 81 | - 'min', |
|
| 82 | - esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso') |
|
| 83 | - ), |
|
| 84 | - new GraphQLField( |
|
| 85 | - 'max', |
|
| 86 | - 'Int', |
|
| 87 | - 'max', |
|
| 88 | - esc_html__('Maximum quantity of this ticket that can be purchased in one transaction', 'event_espresso'), |
|
| 89 | - [$this, 'parseInfiniteValue'] |
|
| 90 | - ), |
|
| 91 | - new GraphQLField( |
|
| 92 | - 'price', |
|
| 93 | - 'Float', |
|
| 94 | - 'price', |
|
| 95 | - esc_html__('Final calculated price for ticket', 'event_espresso') |
|
| 96 | - ), |
|
| 97 | - new GraphQLField( |
|
| 98 | - 'sold', |
|
| 99 | - 'Int', |
|
| 100 | - 'sold', |
|
| 101 | - esc_html__('Number of this ticket sold', 'event_espresso') |
|
| 102 | - ), |
|
| 103 | - new GraphQLField( |
|
| 104 | - 'quantity', |
|
| 105 | - 'Int', |
|
| 106 | - 'qty', |
|
| 107 | - esc_html__('Quantity of this ticket that is available', 'event_espresso'), |
|
| 108 | - [$this, 'parseInfiniteValue'] |
|
| 109 | - ), |
|
| 110 | - new GraphQLField( |
|
| 111 | - 'reserved', |
|
| 112 | - 'Int', |
|
| 113 | - 'reserved', |
|
| 114 | - esc_html__('Quantity of this ticket that is reserved, but not yet fully purchased', 'event_espresso') |
|
| 115 | - ), |
|
| 116 | - new GraphQLField( |
|
| 117 | - 'uses', |
|
| 118 | - 'Int', |
|
| 119 | - 'uses', |
|
| 120 | - esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'), |
|
| 121 | - [$this, 'parseInfiniteValue'] |
|
| 122 | - ), |
|
| 123 | - new GraphQLField( |
|
| 124 | - 'isRequired', |
|
| 125 | - 'Boolean', |
|
| 126 | - 'required', |
|
| 127 | - esc_html__('Flag indicating whether this ticket must be purchased with a transaction', 'event_espresso') |
|
| 128 | - ), |
|
| 129 | - new GraphQLField( |
|
| 130 | - 'isTaxable', |
|
| 131 | - 'Boolean', |
|
| 132 | - 'taxable', |
|
| 133 | - esc_html__('Flag indicating whether there is tax applied on this ticket', 'event_espresso') |
|
| 134 | - ), |
|
| 135 | - new GraphQLField( |
|
| 136 | - 'isDefault', |
|
| 137 | - 'Boolean', |
|
| 138 | - 'is_default', |
|
| 139 | - esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso') |
|
| 140 | - ), |
|
| 141 | - new GraphQLField( |
|
| 142 | - 'order', |
|
| 143 | - 'Int', |
|
| 144 | - 'order', |
|
| 145 | - esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
| 146 | - ), |
|
| 147 | - new GraphQLField( |
|
| 148 | - 'row', |
|
| 149 | - 'Int', |
|
| 150 | - 'row', |
|
| 151 | - esc_html__('How tickets are displayed in the ui', 'event_espresso') |
|
| 152 | - ), |
|
| 153 | - new GraphQLOutputField( |
|
| 154 | - 'wpUser', |
|
| 155 | - 'User', |
|
| 156 | - null, |
|
| 157 | - esc_html__('Ticket Creator', 'event_espresso') |
|
| 158 | - ), |
|
| 159 | - new GraphQLInputField( |
|
| 160 | - 'wpUser', |
|
| 161 | - 'Int', |
|
| 162 | - null, |
|
| 163 | - esc_html__('Ticket Creator ID', 'event_espresso') |
|
| 164 | - ), |
|
| 165 | - new GraphQLOutputField( |
|
| 166 | - 'parent', |
|
| 167 | - 'Ticket', |
|
| 168 | - null, |
|
| 169 | - esc_html__('The parent ticket of the current ticket', 'event_espresso') |
|
| 170 | - ), |
|
| 171 | - new GraphQLInputField( |
|
| 172 | - 'parent', |
|
| 173 | - 'Int', |
|
| 174 | - null, |
|
| 175 | - esc_html__('The parent ticket ID', 'event_espresso') |
|
| 176 | - ), |
|
| 177 | - new GraphQLField( |
|
| 178 | - 'reverseCalculate', |
|
| 179 | - 'Boolean', |
|
| 180 | - 'reverse_calculate', |
|
| 181 | - esc_html__('Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.', 'event_espresso') |
|
| 182 | - ), |
|
| 183 | - new GraphQLField( |
|
| 184 | - 'isFree', |
|
| 185 | - 'Boolean', |
|
| 186 | - 'is_free', |
|
| 187 | - esc_html__('Flag indicating whether the ticket is free.', 'event_espresso') |
|
| 188 | - ), |
|
| 189 | - new GraphQLOutputField( |
|
| 190 | - 'event', |
|
| 191 | - 'Event', |
|
| 192 | - null, |
|
| 193 | - esc_html__('Event of the ticket.', 'event_espresso') |
|
| 194 | - ), |
|
| 195 | - ]; |
|
| 196 | - } |
|
| 41 | + /** |
|
| 42 | + * @return GraphQLFieldInterface[] |
|
| 43 | + * @since $VID:$ |
|
| 44 | + */ |
|
| 45 | + protected function getFields() |
|
| 46 | + { |
|
| 47 | + return [ |
|
| 48 | + new GraphQLField( |
|
| 49 | + 'id', |
|
| 50 | + ['non_null' => 'Int'], |
|
| 51 | + 'ID', |
|
| 52 | + esc_html__('Ticket ID', 'event_espresso') |
|
| 53 | + ), |
|
| 54 | + new GraphQLField( |
|
| 55 | + 'name', |
|
| 56 | + 'String', |
|
| 57 | + 'name', |
|
| 58 | + esc_html__('Ticket Name', 'event_espresso') |
|
| 59 | + ), |
|
| 60 | + new GraphQLField( |
|
| 61 | + 'description', |
|
| 62 | + 'String', |
|
| 63 | + 'description', |
|
| 64 | + esc_html__('Description of Ticket', 'event_espresso') |
|
| 65 | + ), |
|
| 66 | + new GraphQLField( |
|
| 67 | + 'startDate', |
|
| 68 | + 'String', |
|
| 69 | + 'start_date', |
|
| 70 | + esc_html__('Start time/date of Ticket', 'event_espresso') |
|
| 71 | + ), |
|
| 72 | + new GraphQLField( |
|
| 73 | + 'endDate', |
|
| 74 | + 'String', |
|
| 75 | + 'end_date', |
|
| 76 | + esc_html__('End time/date of Ticket', 'event_espresso') |
|
| 77 | + ), |
|
| 78 | + new GraphQLField( |
|
| 79 | + 'min', |
|
| 80 | + 'Int', |
|
| 81 | + 'min', |
|
| 82 | + esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso') |
|
| 83 | + ), |
|
| 84 | + new GraphQLField( |
|
| 85 | + 'max', |
|
| 86 | + 'Int', |
|
| 87 | + 'max', |
|
| 88 | + esc_html__('Maximum quantity of this ticket that can be purchased in one transaction', 'event_espresso'), |
|
| 89 | + [$this, 'parseInfiniteValue'] |
|
| 90 | + ), |
|
| 91 | + new GraphQLField( |
|
| 92 | + 'price', |
|
| 93 | + 'Float', |
|
| 94 | + 'price', |
|
| 95 | + esc_html__('Final calculated price for ticket', 'event_espresso') |
|
| 96 | + ), |
|
| 97 | + new GraphQLField( |
|
| 98 | + 'sold', |
|
| 99 | + 'Int', |
|
| 100 | + 'sold', |
|
| 101 | + esc_html__('Number of this ticket sold', 'event_espresso') |
|
| 102 | + ), |
|
| 103 | + new GraphQLField( |
|
| 104 | + 'quantity', |
|
| 105 | + 'Int', |
|
| 106 | + 'qty', |
|
| 107 | + esc_html__('Quantity of this ticket that is available', 'event_espresso'), |
|
| 108 | + [$this, 'parseInfiniteValue'] |
|
| 109 | + ), |
|
| 110 | + new GraphQLField( |
|
| 111 | + 'reserved', |
|
| 112 | + 'Int', |
|
| 113 | + 'reserved', |
|
| 114 | + esc_html__('Quantity of this ticket that is reserved, but not yet fully purchased', 'event_espresso') |
|
| 115 | + ), |
|
| 116 | + new GraphQLField( |
|
| 117 | + 'uses', |
|
| 118 | + 'Int', |
|
| 119 | + 'uses', |
|
| 120 | + esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'), |
|
| 121 | + [$this, 'parseInfiniteValue'] |
|
| 122 | + ), |
|
| 123 | + new GraphQLField( |
|
| 124 | + 'isRequired', |
|
| 125 | + 'Boolean', |
|
| 126 | + 'required', |
|
| 127 | + esc_html__('Flag indicating whether this ticket must be purchased with a transaction', 'event_espresso') |
|
| 128 | + ), |
|
| 129 | + new GraphQLField( |
|
| 130 | + 'isTaxable', |
|
| 131 | + 'Boolean', |
|
| 132 | + 'taxable', |
|
| 133 | + esc_html__('Flag indicating whether there is tax applied on this ticket', 'event_espresso') |
|
| 134 | + ), |
|
| 135 | + new GraphQLField( |
|
| 136 | + 'isDefault', |
|
| 137 | + 'Boolean', |
|
| 138 | + 'is_default', |
|
| 139 | + esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso') |
|
| 140 | + ), |
|
| 141 | + new GraphQLField( |
|
| 142 | + 'order', |
|
| 143 | + 'Int', |
|
| 144 | + 'order', |
|
| 145 | + esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
| 146 | + ), |
|
| 147 | + new GraphQLField( |
|
| 148 | + 'row', |
|
| 149 | + 'Int', |
|
| 150 | + 'row', |
|
| 151 | + esc_html__('How tickets are displayed in the ui', 'event_espresso') |
|
| 152 | + ), |
|
| 153 | + new GraphQLOutputField( |
|
| 154 | + 'wpUser', |
|
| 155 | + 'User', |
|
| 156 | + null, |
|
| 157 | + esc_html__('Ticket Creator', 'event_espresso') |
|
| 158 | + ), |
|
| 159 | + new GraphQLInputField( |
|
| 160 | + 'wpUser', |
|
| 161 | + 'Int', |
|
| 162 | + null, |
|
| 163 | + esc_html__('Ticket Creator ID', 'event_espresso') |
|
| 164 | + ), |
|
| 165 | + new GraphQLOutputField( |
|
| 166 | + 'parent', |
|
| 167 | + 'Ticket', |
|
| 168 | + null, |
|
| 169 | + esc_html__('The parent ticket of the current ticket', 'event_espresso') |
|
| 170 | + ), |
|
| 171 | + new GraphQLInputField( |
|
| 172 | + 'parent', |
|
| 173 | + 'Int', |
|
| 174 | + null, |
|
| 175 | + esc_html__('The parent ticket ID', 'event_espresso') |
|
| 176 | + ), |
|
| 177 | + new GraphQLField( |
|
| 178 | + 'reverseCalculate', |
|
| 179 | + 'Boolean', |
|
| 180 | + 'reverse_calculate', |
|
| 181 | + esc_html__('Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.', 'event_espresso') |
|
| 182 | + ), |
|
| 183 | + new GraphQLField( |
|
| 184 | + 'isFree', |
|
| 185 | + 'Boolean', |
|
| 186 | + 'is_free', |
|
| 187 | + esc_html__('Flag indicating whether the ticket is free.', 'event_espresso') |
|
| 188 | + ), |
|
| 189 | + new GraphQLOutputField( |
|
| 190 | + 'event', |
|
| 191 | + 'Event', |
|
| 192 | + null, |
|
| 193 | + esc_html__('Event of the ticket.', 'event_espresso') |
|
| 194 | + ), |
|
| 195 | + ]; |
|
| 196 | + } |
|
| 197 | 197 | |
| 198 | 198 | |
| 199 | - /** |
|
| 200 | - * @param array $inputFields The mutation input fields. |
|
| 201 | - * |
|
| 202 | - * @throws InvalidArgumentException |
|
| 203 | - * @throws ReflectionException |
|
| 204 | - * @since $VID:$ |
|
| 205 | - */ |
|
| 206 | - public function registerMutations(array $inputFields) |
|
| 207 | - { |
|
| 208 | - // Register mutation to update an entity. |
|
| 209 | - register_graphql_mutation( |
|
| 199 | + /** |
|
| 200 | + * @param array $inputFields The mutation input fields. |
|
| 201 | + * |
|
| 202 | + * @throws InvalidArgumentException |
|
| 203 | + * @throws ReflectionException |
|
| 204 | + * @since $VID:$ |
|
| 205 | + */ |
|
| 206 | + public function registerMutations(array $inputFields) |
|
| 207 | + { |
|
| 208 | + // Register mutation to update an entity. |
|
| 209 | + register_graphql_mutation( |
|
| 210 | 210 | 'update' . $this->name(), |
| 211 | 211 | [ |
| 212 | 212 | 'inputFields' => $inputFields, |
| 213 | 213 | 'outputFields' => [ |
| 214 | - lcfirst($this->name()) => [ |
|
| 215 | - 'type' => $this->name(), |
|
| 216 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
| 217 | - ], |
|
| 218 | - ], |
|
| 214 | + lcfirst($this->name()) => [ |
|
| 215 | + 'type' => $this->name(), |
|
| 216 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
| 217 | + ], |
|
| 218 | + ], |
|
| 219 | 219 | 'mutateAndGetPayload' => TicketUpdate::mutateAndGetPayload($this->model, $this), |
| 220 | 220 | ] |
| 221 | - ); |
|
| 222 | - // Register mutation to delete an entity. |
|
| 223 | - register_graphql_mutation( |
|
| 221 | + ); |
|
| 222 | + // Register mutation to delete an entity. |
|
| 223 | + register_graphql_mutation( |
|
| 224 | 224 | 'delete' . $this->name(), |
| 225 | 225 | [ |
| 226 | 226 | 'inputFields' => [ |
| 227 | - 'id' => $inputFields['id'], |
|
| 228 | - 'deletePermanently' => [ |
|
| 229 | - 'type' => 'Boolean', |
|
| 230 | - 'description' => esc_html__( 'Whether to delete the entity permanently.', 'event_espresso' ), |
|
| 231 | - ], |
|
| 232 | - ], |
|
| 227 | + 'id' => $inputFields['id'], |
|
| 228 | + 'deletePermanently' => [ |
|
| 229 | + 'type' => 'Boolean', |
|
| 230 | + 'description' => esc_html__( 'Whether to delete the entity permanently.', 'event_espresso' ), |
|
| 231 | + ], |
|
| 232 | + ], |
|
| 233 | 233 | 'outputFields' => [ |
| 234 | - lcfirst($this->name()) => [ |
|
| 235 | - 'type' => $this->name(), |
|
| 236 | - 'description' => esc_html__( 'The object before it was deleted', 'event_espresso' ), |
|
| 237 | - 'resolve' => function ( $payload ) { |
|
| 238 | - $deleted = (object) $payload['deleted']; |
|
| 234 | + lcfirst($this->name()) => [ |
|
| 235 | + 'type' => $this->name(), |
|
| 236 | + 'description' => esc_html__( 'The object before it was deleted', 'event_espresso' ), |
|
| 237 | + 'resolve' => function ( $payload ) { |
|
| 238 | + $deleted = (object) $payload['deleted']; |
|
| 239 | 239 | |
| 240 | - return ! empty( $deleted ) ? $deleted : null; |
|
| 241 | - }, |
|
| 242 | - ], |
|
| 243 | - ], |
|
| 240 | + return ! empty( $deleted ) ? $deleted : null; |
|
| 241 | + }, |
|
| 242 | + ], |
|
| 243 | + ], |
|
| 244 | 244 | 'mutateAndGetPayload' => TicketDelete::mutateAndGetPayload($this->model, $this), |
| 245 | 245 | ] |
| 246 | - ); |
|
| 246 | + ); |
|
| 247 | 247 | |
| 248 | - // remove primary key from input. |
|
| 249 | - unset($inputFields['id']); |
|
| 250 | - // Register mutation to update an entity. |
|
| 251 | - register_graphql_mutation( |
|
| 248 | + // remove primary key from input. |
|
| 249 | + unset($inputFields['id']); |
|
| 250 | + // Register mutation to update an entity. |
|
| 251 | + register_graphql_mutation( |
|
| 252 | 252 | 'create' . $this->name(), |
| 253 | 253 | [ |
| 254 | 254 | 'inputFields' => $inputFields, |
| 255 | 255 | 'outputFields' => [ |
| 256 | - lcfirst($this->name()) => [ |
|
| 257 | - 'type' => $this->name(), |
|
| 258 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
| 259 | - ], |
|
| 260 | - ], |
|
| 256 | + lcfirst($this->name()) => [ |
|
| 257 | + 'type' => $this->name(), |
|
| 258 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
| 259 | + ], |
|
| 260 | + ], |
|
| 261 | 261 | 'mutateAndGetPayload' => TicketCreate::mutateAndGetPayload($this->model, $this), |
| 262 | 262 | ] |
| 263 | 263 | ); |
| 264 | - } |
|
| 264 | + } |
|
| 265 | 265 | } |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | { |
| 208 | 208 | // Register mutation to update an entity. |
| 209 | 209 | register_graphql_mutation( |
| 210 | - 'update' . $this->name(), |
|
| 210 | + 'update'.$this->name(), |
|
| 211 | 211 | [ |
| 212 | 212 | 'inputFields' => $inputFields, |
| 213 | 213 | 'outputFields' => [ |
@@ -221,23 +221,23 @@ discard block |
||
| 221 | 221 | ); |
| 222 | 222 | // Register mutation to delete an entity. |
| 223 | 223 | register_graphql_mutation( |
| 224 | - 'delete' . $this->name(), |
|
| 224 | + 'delete'.$this->name(), |
|
| 225 | 225 | [ |
| 226 | 226 | 'inputFields' => [ |
| 227 | 227 | 'id' => $inputFields['id'], |
| 228 | 228 | 'deletePermanently' => [ |
| 229 | 229 | 'type' => 'Boolean', |
| 230 | - 'description' => esc_html__( 'Whether to delete the entity permanently.', 'event_espresso' ), |
|
| 230 | + 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
| 231 | 231 | ], |
| 232 | 232 | ], |
| 233 | 233 | 'outputFields' => [ |
| 234 | 234 | lcfirst($this->name()) => [ |
| 235 | 235 | 'type' => $this->name(), |
| 236 | - 'description' => esc_html__( 'The object before it was deleted', 'event_espresso' ), |
|
| 237 | - 'resolve' => function ( $payload ) { |
|
| 236 | + 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
| 237 | + 'resolve' => function($payload) { |
|
| 238 | 238 | $deleted = (object) $payload['deleted']; |
| 239 | 239 | |
| 240 | - return ! empty( $deleted ) ? $deleted : null; |
|
| 240 | + return ! empty($deleted) ? $deleted : null; |
|
| 241 | 241 | }, |
| 242 | 242 | ], |
| 243 | 243 | ], |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | unset($inputFields['id']); |
| 250 | 250 | // Register mutation to update an entity. |
| 251 | 251 | register_graphql_mutation( |
| 252 | - 'create' . $this->name(), |
|
| 252 | + 'create'.$this->name(), |
|
| 253 | 253 | [ |
| 254 | 254 | 'inputFields' => $inputFields, |
| 255 | 255 | 'outputFields' => [ |
@@ -41,14 +41,14 @@ discard block |
||
| 41 | 41 | * @throws InvalidDataTypeException |
| 42 | 42 | * @throws EE_Error |
| 43 | 43 | */ |
| 44 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) |
|
| 44 | + return static function($input, AppContext $context, ResolveInfo $info) use ($model, $type) |
|
| 45 | 45 | { |
| 46 | 46 | /** |
| 47 | 47 | * Stop now if a user isn't allowed to create a datetime. |
| 48 | 48 | */ |
| 49 | - if (! current_user_can('ee_edit_events')) { |
|
| 49 | + if ( ! current_user_can('ee_edit_events')) { |
|
| 50 | 50 | // translators: the %1$s is the name of the object being mutated |
| 51 | - throw new UserError(sprintf(__('Sorry, you are not allowed to edit %1$s', 'event_espresso' ), $type->name())); |
|
| 51 | + throw new UserError(sprintf(__('Sorry, you are not allowed to edit %1$s', 'event_espresso'), $type->name())); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | $id = ! empty($input['id']) ? absint($input['id']) : 0; |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | /** |
| 62 | 62 | * If there's no existing datetime, throw an exception |
| 63 | 63 | */ |
| 64 | - if (! $id || ! ($entity instanceof EE_Ticket)) { |
|
| 64 | + if ( ! $id || ! ($entity instanceof EE_Ticket)) { |
|
| 65 | 65 | // translators: the placeholder is the name of the type being updated |
| 66 | - throw new UserError(sprintf(__( 'No %1$s could be found to update', 'event_espresso' ), $type->name())); |
|
| 66 | + throw new UserError(sprintf(__('No %1$s could be found to update', 'event_espresso'), $type->name())); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | $args = TicketMutation::prepare_fields($input); |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | $result = $entity->save($args); |
| 73 | 73 | |
| 74 | 74 | if (empty($result)) { |
| 75 | - throw new UserError(__( 'The object failed to update but no error was provided', 'event_espresso')); |
|
| 75 | + throw new UserError(__('The object failed to update but no error was provided', 'event_espresso')); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | return [ |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | * |
| 25 | 25 | * @param EEM_Ticket $model |
| 26 | 26 | * @param Ticket $type |
| 27 | - * @return callable |
|
| 27 | + * @return \Closure |
|
| 28 | 28 | */ |
| 29 | 29 | public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
| 30 | 30 | { |
@@ -5,13 +5,11 @@ |
||
| 5 | 5 | use EE_Ticket; |
| 6 | 6 | use EventEspresso\core\domain\services\graphql\types\Ticket; |
| 7 | 7 | use EventEspresso\core\domain\services\graphql\data\mutations\TicketMutation; |
| 8 | - |
|
| 9 | 8 | use EE_Error; |
| 10 | 9 | use InvalidArgumentException; |
| 11 | 10 | use ReflectionException; |
| 12 | 11 | use EventEspresso\core\exceptions\InvalidDataTypeException; |
| 13 | 12 | use EventEspresso\core\exceptions\InvalidInterfaceException; |
| 14 | - |
|
| 15 | 13 | use GraphQL\Type\Definition\ResolveInfo; |
| 16 | 14 | use WPGraphQL\AppContext; |
| 17 | 15 | use GraphQL\Error\UserError; |
@@ -22,8 +22,8 @@ |
||
| 22 | 22 | /** |
| 23 | 23 | * Defines the mutation data modification closure. |
| 24 | 24 | * |
| 25 | - * @param EEM_Ticket $model |
|
| 26 | - * @param Ticket $type |
|
| 25 | + * @param EEM_Ticket $model |
|
| 26 | + * @param Ticket $type |
|
| 27 | 27 | * @return callable |
| 28 | 28 | */ |
| 29 | 29 | public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
@@ -22,12 +22,12 @@ |
||
| 22 | 22 | |
| 23 | 23 | $args = []; |
| 24 | 24 | |
| 25 | - if ( ! empty( $input['name'] ) ) { |
|
| 26 | - $args['TKT_name'] = sanitize_text_field( $input['name'] ); |
|
| 25 | + if ( ! empty($input['name'])) { |
|
| 26 | + $args['TKT_name'] = sanitize_text_field($input['name']); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - if ( ! empty( $input['description'] ) ) { |
|
| 30 | - $args['TKT_description'] = sanitize_text_field( $input['description'] ); |
|
| 29 | + if ( ! empty($input['description'])) { |
|
| 30 | + $args['TKT_description'] = sanitize_text_field($input['description']); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | // Likewise the other fields... |