@@ -13,45 +13,45 @@ |
||
| 13 | 13 | class PriceUpdate extends EntityMutator |
| 14 | 14 | { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * Defines the mutation data modification closure. |
|
| 18 | - * |
|
| 19 | - * @param EEM_Price $model |
|
| 20 | - * @param Price $type |
|
| 21 | - * @return callable |
|
| 22 | - */ |
|
| 23 | - public static function mutateAndGetPayload(EEM_Price $model, Price $type) |
|
| 24 | - { |
|
| 25 | - /** |
|
| 26 | - * Updates an entity. |
|
| 27 | - * |
|
| 28 | - * @param array $input The input for the mutation |
|
| 29 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
| 30 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
| 31 | - * @return array |
|
| 32 | - */ |
|
| 33 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
| 34 | - try { |
|
| 35 | - /** @var EE_Price $entity */ |
|
| 36 | - $entity = EntityMutator::getEntityFromInputData($model, $input); |
|
| 16 | + /** |
|
| 17 | + * Defines the mutation data modification closure. |
|
| 18 | + * |
|
| 19 | + * @param EEM_Price $model |
|
| 20 | + * @param Price $type |
|
| 21 | + * @return callable |
|
| 22 | + */ |
|
| 23 | + public static function mutateAndGetPayload(EEM_Price $model, Price $type) |
|
| 24 | + { |
|
| 25 | + /** |
|
| 26 | + * Updates an entity. |
|
| 27 | + * |
|
| 28 | + * @param array $input The input for the mutation |
|
| 29 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
| 30 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
| 31 | + * @return array |
|
| 32 | + */ |
|
| 33 | + return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
| 34 | + try { |
|
| 35 | + /** @var EE_Price $entity */ |
|
| 36 | + $entity = EntityMutator::getEntityFromInputData($model, $input); |
|
| 37 | 37 | |
| 38 | - $args = PriceMutation::prepareFields($input); |
|
| 38 | + $args = PriceMutation::prepareFields($input); |
|
| 39 | 39 | |
| 40 | - // Update the entity |
|
| 41 | - $entity->save($args); |
|
| 42 | - } catch (Exception $exception) { |
|
| 43 | - EntityMutator::handleExceptions( |
|
| 44 | - $exception, |
|
| 45 | - esc_html__( |
|
| 46 | - 'The price could not be updated because of the following error(s)', |
|
| 47 | - 'event_espresso' |
|
| 48 | - ) |
|
| 49 | - ); |
|
| 50 | - } |
|
| 40 | + // Update the entity |
|
| 41 | + $entity->save($args); |
|
| 42 | + } catch (Exception $exception) { |
|
| 43 | + EntityMutator::handleExceptions( |
|
| 44 | + $exception, |
|
| 45 | + esc_html__( |
|
| 46 | + 'The price could not be updated because of the following error(s)', |
|
| 47 | + 'event_espresso' |
|
| 48 | + ) |
|
| 49 | + ); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - return [ |
|
| 53 | - 'id' => $entity->ID(), |
|
| 54 | - ]; |
|
| 55 | - }; |
|
| 56 | - } |
|
| 52 | + return [ |
|
| 53 | + 'id' => $entity->ID(), |
|
| 54 | + ]; |
|
| 55 | + }; |
|
| 56 | + } |
|
| 57 | 57 | } |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
| 31 | 31 | * @return array |
| 32 | 32 | */ |
| 33 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
| 33 | + return static function($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
| 34 | 34 | try { |
| 35 | 35 | /** @var EE_Price $entity */ |
| 36 | 36 | $entity = EntityMutator::getEntityFromInputData($model, $input); |
@@ -12,43 +12,43 @@ |
||
| 12 | 12 | class PriceDelete extends EntityMutator |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Defines the mutation data modification closure. |
|
| 17 | - * |
|
| 18 | - * @param EEM_Price $model |
|
| 19 | - * @param Price $type |
|
| 20 | - * @return callable |
|
| 21 | - */ |
|
| 22 | - public static function mutateAndGetPayload(EEM_Price $model, Price $type) |
|
| 23 | - { |
|
| 24 | - /** |
|
| 25 | - * Deletes an entity. |
|
| 26 | - * |
|
| 27 | - * @param array $input The input for the mutation |
|
| 28 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
| 29 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
| 30 | - * @return array |
|
| 31 | - */ |
|
| 32 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
| 33 | - try { |
|
| 34 | - /** @var EE_Price $entity */ |
|
| 35 | - $entity = EntityMutator::getEntityFromInputData($model, $input); |
|
| 36 | - // Delete the entity |
|
| 37 | - $result = ! empty($input['deletePermanently']) ? $entity->delete_permanently() : $entity->delete(); |
|
| 38 | - EntityMutator::validateResults($result); |
|
| 39 | - } catch (Exception $exception) { |
|
| 40 | - EntityMutator::handleExceptions( |
|
| 41 | - $exception, |
|
| 42 | - esc_html__( |
|
| 43 | - 'The price could not be deleted because of the following error(s)', |
|
| 44 | - 'event_espresso' |
|
| 45 | - ) |
|
| 46 | - ); |
|
| 47 | - } |
|
| 15 | + /** |
|
| 16 | + * Defines the mutation data modification closure. |
|
| 17 | + * |
|
| 18 | + * @param EEM_Price $model |
|
| 19 | + * @param Price $type |
|
| 20 | + * @return callable |
|
| 21 | + */ |
|
| 22 | + public static function mutateAndGetPayload(EEM_Price $model, Price $type) |
|
| 23 | + { |
|
| 24 | + /** |
|
| 25 | + * Deletes an entity. |
|
| 26 | + * |
|
| 27 | + * @param array $input The input for the mutation |
|
| 28 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
| 29 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
| 30 | + * @return array |
|
| 31 | + */ |
|
| 32 | + return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
| 33 | + try { |
|
| 34 | + /** @var EE_Price $entity */ |
|
| 35 | + $entity = EntityMutator::getEntityFromInputData($model, $input); |
|
| 36 | + // Delete the entity |
|
| 37 | + $result = ! empty($input['deletePermanently']) ? $entity->delete_permanently() : $entity->delete(); |
|
| 38 | + EntityMutator::validateResults($result); |
|
| 39 | + } catch (Exception $exception) { |
|
| 40 | + EntityMutator::handleExceptions( |
|
| 41 | + $exception, |
|
| 42 | + esc_html__( |
|
| 43 | + 'The price could not be deleted because of the following error(s)', |
|
| 44 | + 'event_espresso' |
|
| 45 | + ) |
|
| 46 | + ); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - return [ |
|
| 50 | - 'deleted' => $entity, |
|
| 51 | - ]; |
|
| 52 | - }; |
|
| 53 | - } |
|
| 49 | + return [ |
|
| 50 | + 'deleted' => $entity, |
|
| 51 | + ]; |
|
| 52 | + }; |
|
| 53 | + } |
|
| 54 | 54 | } |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
| 30 | 30 | * @return array |
| 31 | 31 | */ |
| 32 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
| 32 | + return static function($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
| 33 | 33 | try { |
| 34 | 34 | /** @var EE_Price $entity */ |
| 35 | 35 | $entity = EntityMutator::getEntityFromInputData($model, $input); |
@@ -14,60 +14,60 @@ |
||
| 14 | 14 | class VenueUpdate extends EntityMutator |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Defines the mutation data modification closure. |
|
| 19 | - * |
|
| 20 | - * @param EEM_Venue $model |
|
| 21 | - * @param Venue $type |
|
| 22 | - * @return callable |
|
| 23 | - */ |
|
| 24 | - public static function mutateFields(EEM_Venue $model, Venue $type) |
|
| 25 | - { |
|
| 26 | - /** |
|
| 27 | - * Update additional data related to the entity. |
|
| 28 | - * |
|
| 29 | - * @param int $id The ID of the postObject being mutated |
|
| 30 | - * @param array $input The input for the mutation |
|
| 31 | - * @param WP_Post_Type $post_type_object The Post Type Object for the type of post being mutated |
|
| 32 | - * @param string $mutation_name The name of the mutation (ex: create, update, delete) |
|
| 33 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
| 34 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
| 35 | - * @return array|void |
|
| 36 | - */ |
|
| 37 | - return static function ( |
|
| 38 | - $id, |
|
| 39 | - array $input, |
|
| 40 | - WP_Post_Type $post_type_object, |
|
| 41 | - $mutation_name, |
|
| 42 | - AppContext $context, |
|
| 43 | - ResolveInfo $info |
|
| 44 | - ) use ( |
|
| 45 | - $model, |
|
| 46 | - $type |
|
| 47 | - ) { |
|
| 48 | - try { |
|
| 49 | - // Make sure we are dealing with the right entity. |
|
| 50 | - if (! property_exists($post_type_object, 'graphql_single_name') |
|
| 51 | - || $post_type_object->graphql_single_name !== $type->name() |
|
| 52 | - ) { |
|
| 53 | - return; |
|
| 54 | - } |
|
| 17 | + /** |
|
| 18 | + * Defines the mutation data modification closure. |
|
| 19 | + * |
|
| 20 | + * @param EEM_Venue $model |
|
| 21 | + * @param Venue $type |
|
| 22 | + * @return callable |
|
| 23 | + */ |
|
| 24 | + public static function mutateFields(EEM_Venue $model, Venue $type) |
|
| 25 | + { |
|
| 26 | + /** |
|
| 27 | + * Update additional data related to the entity. |
|
| 28 | + * |
|
| 29 | + * @param int $id The ID of the postObject being mutated |
|
| 30 | + * @param array $input The input for the mutation |
|
| 31 | + * @param WP_Post_Type $post_type_object The Post Type Object for the type of post being mutated |
|
| 32 | + * @param string $mutation_name The name of the mutation (ex: create, update, delete) |
|
| 33 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
| 34 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
| 35 | + * @return array|void |
|
| 36 | + */ |
|
| 37 | + return static function ( |
|
| 38 | + $id, |
|
| 39 | + array $input, |
|
| 40 | + WP_Post_Type $post_type_object, |
|
| 41 | + $mutation_name, |
|
| 42 | + AppContext $context, |
|
| 43 | + ResolveInfo $info |
|
| 44 | + ) use ( |
|
| 45 | + $model, |
|
| 46 | + $type |
|
| 47 | + ) { |
|
| 48 | + try { |
|
| 49 | + // Make sure we are dealing with the right entity. |
|
| 50 | + if (! property_exists($post_type_object, 'graphql_single_name') |
|
| 51 | + || $post_type_object->graphql_single_name !== $type->name() |
|
| 52 | + ) { |
|
| 53 | + return; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** @var EE_Venue $entity */ |
|
| 57 | - $entity = EntityMutator::getEntityFromID($model, $id); |
|
| 58 | - $args = VenueMutation::prepareFields($input, $mutation_name); |
|
| 56 | + /** @var EE_Venue $entity */ |
|
| 57 | + $entity = EntityMutator::getEntityFromID($model, $id); |
|
| 58 | + $args = VenueMutation::prepareFields($input, $mutation_name); |
|
| 59 | 59 | |
| 60 | - // Update the entity |
|
| 61 | - $entity->save($args); |
|
| 62 | - } catch (Exception $exception) { |
|
| 63 | - EntityMutator::handleExceptions( |
|
| 64 | - $exception, |
|
| 65 | - esc_html__( |
|
| 66 | - 'The datetime could not be updated because of the following error(s)', |
|
| 67 | - 'event_espresso' |
|
| 68 | - ) |
|
| 69 | - ); |
|
| 70 | - } |
|
| 71 | - }; |
|
| 72 | - } |
|
| 60 | + // Update the entity |
|
| 61 | + $entity->save($args); |
|
| 62 | + } catch (Exception $exception) { |
|
| 63 | + EntityMutator::handleExceptions( |
|
| 64 | + $exception, |
|
| 65 | + esc_html__( |
|
| 66 | + 'The datetime could not be updated because of the following error(s)', |
|
| 67 | + 'event_espresso' |
|
| 68 | + ) |
|
| 69 | + ); |
|
| 70 | + } |
|
| 71 | + }; |
|
| 72 | + } |
|
| 73 | 73 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
| 35 | 35 | * @return array|void |
| 36 | 36 | */ |
| 37 | - return static function ( |
|
| 37 | + return static function( |
|
| 38 | 38 | $id, |
| 39 | 39 | array $input, |
| 40 | 40 | WP_Post_Type $post_type_object, |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | ) { |
| 48 | 48 | try { |
| 49 | 49 | // Make sure we are dealing with the right entity. |
| 50 | - if (! property_exists($post_type_object, 'graphql_single_name') |
|
| 50 | + if ( ! property_exists($post_type_object, 'graphql_single_name') |
|
| 51 | 51 | || $post_type_object->graphql_single_name !== $type->name() |
| 52 | 52 | ) { |
| 53 | 53 | return; |