Completed
Branch FET/reg-form-builder/main (0f11d8)
by
unknown
02:56 queued 17s
created
core/domain/services/graphql/mutators/BulkEntityDelete.php 2 patches
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -17,76 +17,76 @@
 block discarded – undo
17 17
 
18 18
 class BulkEntityDelete extends EntityMutator
19 19
 {
20
-    /**
21
-     * Defines the mutation data modification closure.
22
-     *
23
-     * @return callable
24
-     */
25
-    public static function mutateAndGetPayload()
26
-    {
27
-        /**
28
-         * Updates an entity.
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
-         * @throws UserError
35
-         * @throws ReflectionException
36
-         * @throws InvalidArgumentException
37
-         * @throws InvalidInterfaceException
38
-         * @throws InvalidDataTypeException
39
-         * @throws EE_Error
40
-         */
41
-        return static function (array $input, AppContext $context, ResolveInfo $info): array {
42
-            /**
43
-             * Stop now if a user isn't allowed to delete.
44
-             */
45
-            if (! current_user_can('ee_delete_events')) {
46
-                throw new UserError(
47
-                    esc_html__('Sorry, you do not have the required permissions to delete entities', 'event_espresso')
48
-                );
49
-            }
20
+	/**
21
+	 * Defines the mutation data modification closure.
22
+	 *
23
+	 * @return callable
24
+	 */
25
+	public static function mutateAndGetPayload()
26
+	{
27
+		/**
28
+		 * Updates an entity.
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
+		 * @throws UserError
35
+		 * @throws ReflectionException
36
+		 * @throws InvalidArgumentException
37
+		 * @throws InvalidInterfaceException
38
+		 * @throws InvalidDataTypeException
39
+		 * @throws EE_Error
40
+		 */
41
+		return static function (array $input, AppContext $context, ResolveInfo $info): array {
42
+			/**
43
+			 * Stop now if a user isn't allowed to delete.
44
+			 */
45
+			if (! current_user_can('ee_delete_events')) {
46
+				throw new UserError(
47
+					esc_html__('Sorry, you do not have the required permissions to delete entities', 'event_espresso')
48
+				);
49
+			}
50 50
 
51
-            $details = EntityReorder::prepareEntityDetailsFromInput($input);
51
+			$details = EntityReorder::prepareEntityDetailsFromInput($input);
52 52
 
53
-            $deletePermanently = ! empty($input['deletePermanently']);
53
+			$deletePermanently = ! empty($input['deletePermanently']);
54 54
 
55
-            $deletionMethod = __NAMESPACE__;
56
-            // if it's for datetimes.
57
-            if ($details['entityType'] === EEM_Datetime::instance()->item_name()) {
58
-                $deletionMethod .= '\DatetimeDelete::' . ($deletePermanently ? 'deleteDatetimeAndRelations' : 'trashDatetimeAndRelations');
59
-            } elseif ($details['entityType'] === EEM_Ticket::instance()->item_name()) {
60
-                $deletionMethod .= '\TicketDelete::' . ($deletePermanently ? 'deleteTicketAndRelations' : 'trashTicket');
61
-            } elseif ($details['entityType'] === EEM_Price::instance()->item_name()) {
62
-                $deletionMethod .= '\PriceDelete::deletePriceAndRelations';
63
-            } else {
64
-                throw new UserError(
65
-                    esc_html__(
66
-                        'A valid data model could not be obtained. Did you supply a valid entity type?',
67
-                        'event_espresso'
68
-                    )
69
-                );
70
-            }
55
+			$deletionMethod = __NAMESPACE__;
56
+			// if it's for datetimes.
57
+			if ($details['entityType'] === EEM_Datetime::instance()->item_name()) {
58
+				$deletionMethod .= '\DatetimeDelete::' . ($deletePermanently ? 'deleteDatetimeAndRelations' : 'trashDatetimeAndRelations');
59
+			} elseif ($details['entityType'] === EEM_Ticket::instance()->item_name()) {
60
+				$deletionMethod .= '\TicketDelete::' . ($deletePermanently ? 'deleteTicketAndRelations' : 'trashTicket');
61
+			} elseif ($details['entityType'] === EEM_Price::instance()->item_name()) {
62
+				$deletionMethod .= '\PriceDelete::deletePriceAndRelations';
63
+			} else {
64
+				throw new UserError(
65
+					esc_html__(
66
+						'A valid data model could not be obtained. Did you supply a valid entity type?',
67
+						'event_espresso'
68
+					)
69
+				);
70
+			}
71 71
 
72
-            $deleted = [];
73
-            $failed  = [];
72
+			$deleted = [];
73
+			$failed  = [];
74 74
 
75
-            foreach ($details['entityDbids'] as $key => $entityDbid) {
76
-                $guid = $details['entityGuids'][ $key ];
77
-                $entity = $details['entities'][ $entityDbid ];
78
-                try {
79
-                    $result = $deletionMethod($entity);
80
-                    EntityMutator::validateResults($result);
81
-                    // we are here it means the deletion was successful.
82
-                    $deleted[] = $guid;
83
-                } catch (Exception $e) {
84
-                    // sorry mate, couldn't help you :(
85
-                    $failed[] = $guid;
86
-                }
87
-            }
75
+			foreach ($details['entityDbids'] as $key => $entityDbid) {
76
+				$guid = $details['entityGuids'][ $key ];
77
+				$entity = $details['entities'][ $entityDbid ];
78
+				try {
79
+					$result = $deletionMethod($entity);
80
+					EntityMutator::validateResults($result);
81
+					// we are here it means the deletion was successful.
82
+					$deleted[] = $guid;
83
+				} catch (Exception $e) {
84
+					// sorry mate, couldn't help you :(
85
+					$failed[] = $guid;
86
+				}
87
+			}
88 88
 
89
-            return compact('deleted', 'failed');
90
-        };
91
-    }
89
+			return compact('deleted', 'failed');
90
+		};
91
+	}
92 92
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -38,11 +38,11 @@  discard block
 block discarded – undo
38 38
          * @throws InvalidDataTypeException
39 39
          * @throws EE_Error
40 40
          */
41
-        return static function (array $input, AppContext $context, ResolveInfo $info): array {
41
+        return static function(array $input, AppContext $context, ResolveInfo $info): array {
42 42
             /**
43 43
              * Stop now if a user isn't allowed to delete.
44 44
              */
45
-            if (! current_user_can('ee_delete_events')) {
45
+            if ( ! current_user_can('ee_delete_events')) {
46 46
                 throw new UserError(
47 47
                     esc_html__('Sorry, you do not have the required permissions to delete entities', 'event_espresso')
48 48
                 );
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
             $deletionMethod = __NAMESPACE__;
56 56
             // if it's for datetimes.
57 57
             if ($details['entityType'] === EEM_Datetime::instance()->item_name()) {
58
-                $deletionMethod .= '\DatetimeDelete::' . ($deletePermanently ? 'deleteDatetimeAndRelations' : 'trashDatetimeAndRelations');
58
+                $deletionMethod .= '\DatetimeDelete::'.($deletePermanently ? 'deleteDatetimeAndRelations' : 'trashDatetimeAndRelations');
59 59
             } elseif ($details['entityType'] === EEM_Ticket::instance()->item_name()) {
60
-                $deletionMethod .= '\TicketDelete::' . ($deletePermanently ? 'deleteTicketAndRelations' : 'trashTicket');
60
+                $deletionMethod .= '\TicketDelete::'.($deletePermanently ? 'deleteTicketAndRelations' : 'trashTicket');
61 61
             } elseif ($details['entityType'] === EEM_Price::instance()->item_name()) {
62 62
                 $deletionMethod .= '\PriceDelete::deletePriceAndRelations';
63 63
             } else {
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
             $failed  = [];
74 74
 
75 75
             foreach ($details['entityDbids'] as $key => $entityDbid) {
76
-                $guid = $details['entityGuids'][ $key ];
77
-                $entity = $details['entities'][ $entityDbid ];
76
+                $guid = $details['entityGuids'][$key];
77
+                $entity = $details['entities'][$entityDbid];
78 78
                 try {
79 79
                     $result = $deletionMethod($entity);
80 80
                     EntityMutator::validateResults($result);
Please login to merge, or discard this patch.
core/domain/services/graphql/mutators/DatetimeDelete.php 2 patches
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -17,107 +17,107 @@
 block discarded – undo
17 17
 class DatetimeDelete extends EntityMutator
18 18
 {
19 19
 
20
-    /**
21
-     * Defines the mutation data modification closure.
22
-     *
23
-     * @param EEM_Datetime $model
24
-     * @param Datetime     $type
25
-     * @return callable
26
-     */
27
-    public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type)
28
-    {
29
-        /**
30
-         * Deletes an entity.
31
-         *
32
-         * @param array       $input   The input for the mutation
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
36
-         */
37
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
38
-            try {
39
-                /** @var EE_Datetime $entity */
40
-                $entity = EntityMutator::getEntityFromInputData($model, $input);
20
+	/**
21
+	 * Defines the mutation data modification closure.
22
+	 *
23
+	 * @param EEM_Datetime $model
24
+	 * @param Datetime     $type
25
+	 * @return callable
26
+	 */
27
+	public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type)
28
+	{
29
+		/**
30
+		 * Deletes an entity.
31
+		 *
32
+		 * @param array       $input   The input for the mutation
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
36
+		 */
37
+		return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
38
+			try {
39
+				/** @var EE_Datetime $entity */
40
+				$entity = EntityMutator::getEntityFromInputData($model, $input);
41 41
 
42
-                // Delete the entity
43
-                if (! empty($input['deletePermanently'])) {
44
-                    $result = DatetimeDelete::deleteDatetimeAndRelations($entity);
45
-                } else {
46
-                    $result = DatetimeDelete::trashDatetimeAndRelations($entity);
47
-                }
48
-                EntityMutator::validateResults($result);
42
+				// Delete the entity
43
+				if (! empty($input['deletePermanently'])) {
44
+					$result = DatetimeDelete::deleteDatetimeAndRelations($entity);
45
+				} else {
46
+					$result = DatetimeDelete::trashDatetimeAndRelations($entity);
47
+				}
48
+				EntityMutator::validateResults($result);
49 49
 
50
-                do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_datetime_delete', $entity, $input);
51
-            } catch (Exception $exception) {
52
-                EntityMutator::handleExceptions(
53
-                    $exception,
54
-                    esc_html__(
55
-                        'The datetime could not be deleted because of the following error(s)',
56
-                        'event_espresso'
57
-                    )
58
-                );
59
-            }
50
+				do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_datetime_delete', $entity, $input);
51
+			} catch (Exception $exception) {
52
+				EntityMutator::handleExceptions(
53
+					$exception,
54
+					esc_html__(
55
+						'The datetime could not be deleted because of the following error(s)',
56
+						'event_espresso'
57
+					)
58
+				);
59
+			}
60 60
 
61
-            return [
62
-                'deleted' => $entity,
63
-            ];
64
-        };
65
-    }
61
+			return [
62
+				'deleted' => $entity,
63
+			];
64
+		};
65
+	}
66 66
 
67
-    /**
68
-     * Deletes a datetime permanently along with its relations.
69
-     *
70
-     * @param EE_Datetime $entity
71
-     * @return bool | int
72
-     * @throws ReflectionException
73
-     * @throws InvalidArgumentException
74
-     * @throws InvalidInterfaceException
75
-     * @throws InvalidDataTypeException
76
-     * @throws EE_Error
77
-     */
78
-    public static function deleteDatetimeAndRelations(EE_Datetime $entity)
79
-    {
80
-        // all related tickets
81
-        $tickets = $entity->tickets();
82
-        foreach ($tickets as $ticket) {
83
-            // if the ticket is related to only one datetime
84
-            if ($ticket->count_related('Datetime') === 1) {
85
-                TicketDelete::deleteTicketAndRelations($ticket);
86
-            }
87
-        }
67
+	/**
68
+	 * Deletes a datetime permanently along with its relations.
69
+	 *
70
+	 * @param EE_Datetime $entity
71
+	 * @return bool | int
72
+	 * @throws ReflectionException
73
+	 * @throws InvalidArgumentException
74
+	 * @throws InvalidInterfaceException
75
+	 * @throws InvalidDataTypeException
76
+	 * @throws EE_Error
77
+	 */
78
+	public static function deleteDatetimeAndRelations(EE_Datetime $entity)
79
+	{
80
+		// all related tickets
81
+		$tickets = $entity->tickets();
82
+		foreach ($tickets as $ticket) {
83
+			// if the ticket is related to only one datetime
84
+			if ($ticket->count_related('Datetime') === 1) {
85
+				TicketDelete::deleteTicketAndRelations($ticket);
86
+			}
87
+		}
88 88
 
89
-        // Remove relations with tickets
90
-        $entity->_remove_relations('Ticket');
91
-        // Now delete the datetime permanently
92
-        return $entity->delete_permanently();
93
-    }
89
+		// Remove relations with tickets
90
+		$entity->_remove_relations('Ticket');
91
+		// Now delete the datetime permanently
92
+		return $entity->delete_permanently();
93
+	}
94 94
 
95
-    /**
96
-     * Trashes a datetime along with its lone relations.
97
-     *
98
-     * @param EE_Datetime $entity
99
-     * @return bool | int
100
-     * @throws ReflectionException
101
-     * @throws InvalidArgumentException
102
-     * @throws InvalidInterfaceException
103
-     * @throws InvalidDataTypeException
104
-     * @throws EE_Error
105
-     */
106
-    public static function trashDatetimeAndRelations(EE_Datetime $entity)
107
-    {
108
-        // non trashed related tickets
109
-        $tickets = $entity->tickets([[
110
-            'TKT_deleted' => false,
111
-        ]]);
112
-        // loop though all tickets to check if we need to trash any
113
-        foreach ($tickets as $ticket) {
114
-            // if the ticket is related to only one datetime
115
-            if ($ticket->count_related('Datetime') === 1) {
116
-                // trash the ticket
117
-                $ticket->delete();
118
-            }
119
-        }
120
-        // trash the datetime
121
-        return $entity->delete();
122
-    }
95
+	/**
96
+	 * Trashes a datetime along with its lone relations.
97
+	 *
98
+	 * @param EE_Datetime $entity
99
+	 * @return bool | int
100
+	 * @throws ReflectionException
101
+	 * @throws InvalidArgumentException
102
+	 * @throws InvalidInterfaceException
103
+	 * @throws InvalidDataTypeException
104
+	 * @throws EE_Error
105
+	 */
106
+	public static function trashDatetimeAndRelations(EE_Datetime $entity)
107
+	{
108
+		// non trashed related tickets
109
+		$tickets = $entity->tickets([[
110
+			'TKT_deleted' => false,
111
+		]]);
112
+		// loop though all tickets to check if we need to trash any
113
+		foreach ($tickets as $ticket) {
114
+			// if the ticket is related to only one datetime
115
+			if ($ticket->count_related('Datetime') === 1) {
116
+				// trash the ticket
117
+				$ticket->delete();
118
+			}
119
+		}
120
+		// trash the datetime
121
+		return $entity->delete();
122
+	}
123 123
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,13 +34,13 @@
 block discarded – undo
34 34
          * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
35 35
          * @return array
36 36
          */
37
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
37
+        return static function(array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
38 38
             try {
39 39
                 /** @var EE_Datetime $entity */
40 40
                 $entity = EntityMutator::getEntityFromInputData($model, $input);
41 41
 
42 42
                 // Delete the entity
43
-                if (! empty($input['deletePermanently'])) {
43
+                if ( ! empty($input['deletePermanently'])) {
44 44
                     $result = DatetimeDelete::deleteDatetimeAndRelations($entity);
45 45
                 } else {
46 46
                     $result = DatetimeDelete::trashDatetimeAndRelations($entity);
Please login to merge, or discard this patch.
core/domain/services/graphql/mutators/PriceDelete.php 2 patches
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -17,70 +17,70 @@
 block discarded – undo
17 17
 class PriceDelete extends EntityMutator
18 18
 {
19 19
 
20
-    /**
21
-     * Defines the mutation data modification closure.
22
-     *
23
-     * @param EEM_Price $model
24
-     * @param Price     $type
25
-     * @return callable
26
-     */
27
-    public static function mutateAndGetPayload(EEM_Price $model, Price $type)
28
-    {
29
-        /**
30
-         * Deletes an entity.
31
-         *
32
-         * @param array       $input   The input for the mutation
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
36
-         */
37
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
38
-            try {
39
-                /** @var EE_Price $entity */
40
-                $entity = EntityMutator::getEntityFromInputData($model, $input);
20
+	/**
21
+	 * Defines the mutation data modification closure.
22
+	 *
23
+	 * @param EEM_Price $model
24
+	 * @param Price     $type
25
+	 * @return callable
26
+	 */
27
+	public static function mutateAndGetPayload(EEM_Price $model, Price $type)
28
+	{
29
+		/**
30
+		 * Deletes an entity.
31
+		 *
32
+		 * @param array       $input   The input for the mutation
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
36
+		 */
37
+		return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
38
+			try {
39
+				/** @var EE_Price $entity */
40
+				$entity = EntityMutator::getEntityFromInputData($model, $input);
41 41
 
42
-                // Delete the entity
43
-                if (! empty($input['deletePermanently'])) {
44
-                    $result = PriceDelete::deletePriceAndRelations($entity);
45
-                } else {
46
-                    // trash the price
47
-                    $result = $entity->delete();
48
-                }
49
-                EntityMutator::validateResults($result);
42
+				// Delete the entity
43
+				if (! empty($input['deletePermanently'])) {
44
+					$result = PriceDelete::deletePriceAndRelations($entity);
45
+				} else {
46
+					// trash the price
47
+					$result = $entity->delete();
48
+				}
49
+				EntityMutator::validateResults($result);
50 50
 
51
-                do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_price_delete', $entity, $input);
52
-            } catch (Exception $exception) {
53
-                EntityMutator::handleExceptions(
54
-                    $exception,
55
-                    esc_html__(
56
-                        'The price could not be deleted because of the following error(s)',
57
-                        'event_espresso'
58
-                    )
59
-                );
60
-            }
51
+				do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_price_delete', $entity, $input);
52
+			} catch (Exception $exception) {
53
+				EntityMutator::handleExceptions(
54
+					$exception,
55
+					esc_html__(
56
+						'The price could not be deleted because of the following error(s)',
57
+						'event_espresso'
58
+					)
59
+				);
60
+			}
61 61
 
62
-            return [
63
-                'deleted' => $entity,
64
-            ];
65
-        };
66
-    }
62
+			return [
63
+				'deleted' => $entity,
64
+			];
65
+		};
66
+	}
67 67
 
68
-    /**
69
-     * Deletes a price permanently along with its relations.
70
-     *
71
-     * @param EE_Price $entity
72
-     * @return bool | int
73
-     * @throws ReflectionException
74
-     * @throws InvalidArgumentException
75
-     * @throws InvalidInterfaceException
76
-     * @throws InvalidDataTypeException
77
-     * @throws EE_Error
78
-     */
79
-    public static function deletePriceAndRelations(EE_Price $entity)
80
-    {
81
-        // Remove relation with ticket
82
-        $entity->_remove_relations('Ticket');
83
-        // Now delete the price permanently
84
-        return $entity->delete_permanently();
85
-    }
68
+	/**
69
+	 * Deletes a price permanently along with its relations.
70
+	 *
71
+	 * @param EE_Price $entity
72
+	 * @return bool | int
73
+	 * @throws ReflectionException
74
+	 * @throws InvalidArgumentException
75
+	 * @throws InvalidInterfaceException
76
+	 * @throws InvalidDataTypeException
77
+	 * @throws EE_Error
78
+	 */
79
+	public static function deletePriceAndRelations(EE_Price $entity)
80
+	{
81
+		// Remove relation with ticket
82
+		$entity->_remove_relations('Ticket');
83
+		// Now delete the price permanently
84
+		return $entity->delete_permanently();
85
+	}
86 86
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,13 +34,13 @@
 block discarded – undo
34 34
          * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
35 35
          * @return array
36 36
          */
37
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
37
+        return static function(array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
38 38
             try {
39 39
                 /** @var EE_Price $entity */
40 40
                 $entity = EntityMutator::getEntityFromInputData($model, $input);
41 41
 
42 42
                 // Delete the entity
43
-                if (! empty($input['deletePermanently'])) {
43
+                if ( ! empty($input['deletePermanently'])) {
44 44
                     $result = PriceDelete::deletePriceAndRelations($entity);
45 45
                 } else {
46 46
                     // trash the price
Please login to merge, or discard this patch.
core/domain/services/graphql/mutators/VenueUpdate.php 2 patches
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -14,63 +14,63 @@
 block discarded – undo
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 void
36
-         */
37
-        return static function (
38
-            int $id,
39
-            array $input,
40
-            WP_Post_Type $post_type_object,
41
-            string $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 (
51
-                    ! property_exists($post_type_object, 'graphql_single_name')
52
-                    || $post_type_object->graphql_single_name !== $type->name()
53
-                ) {
54
-                    return;
55
-                }
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 void
36
+		 */
37
+		return static function (
38
+			int $id,
39
+			array $input,
40
+			WP_Post_Type $post_type_object,
41
+			string $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 (
51
+					! property_exists($post_type_object, 'graphql_single_name')
52
+					|| $post_type_object->graphql_single_name !== $type->name()
53
+				) {
54
+					return;
55
+				}
56 56
 
57
-                /** @var EE_Venue $entity */
58
-                $entity = EntityMutator::getEntityFromID($model, $id);
59
-                $args = VenueMutation::prepareFields($input);
57
+				/** @var EE_Venue $entity */
58
+				$entity = EntityMutator::getEntityFromID($model, $id);
59
+				$args = VenueMutation::prepareFields($input);
60 60
 
61
-                // Update the entity
62
-                $entity->save($args);
61
+				// Update the entity
62
+				$entity->save($args);
63 63
 
64
-                do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_venue_update', $entity, $input);
65
-            } catch (Exception $exception) {
66
-                EntityMutator::handleExceptions(
67
-                    $exception,
68
-                    esc_html__(
69
-                        'The datetime could not be updated because of the following error(s)',
70
-                        'event_espresso'
71
-                    )
72
-                );
73
-            }
74
-        };
75
-    }
64
+				do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_venue_update', $entity, $input);
65
+			} catch (Exception $exception) {
66
+				EntityMutator::handleExceptions(
67
+					$exception,
68
+					esc_html__(
69
+						'The datetime could not be updated because of the following error(s)',
70
+						'event_espresso'
71
+					)
72
+				);
73
+			}
74
+		};
75
+	}
76 76
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
          * @param ResolveInfo   $info               The ResolveInfo passed down to all resolvers
35 35
          * @return void
36 36
          */
37
-        return static function (
37
+        return static function(
38 38
             int $id,
39 39
             array $input,
40 40
             WP_Post_Type $post_type_object,
Please login to merge, or discard this patch.
core/domain/services/graphql/mutators/PriceUpdate.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -15,49 +15,49 @@
 block discarded – undo
15 15
 class PriceUpdate extends EntityMutator
16 16
 {
17 17
 
18
-    /**
19
-     * Defines the mutation data modification closure.
20
-     *
21
-     * @param EEM_Price $model
22
-     * @param Price     $type
23
-     * @return callable
24
-     */
25
-    public static function mutateAndGetPayload(EEM_Price $model, Price $type)
26
-    {
27
-        /**
28
-         * Updates an entity.
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
-         * @throws EE_Error
35
-         * @throws ReflectionException
36
-         */
37
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
38
-            try {
39
-                /** @var EE_Price $entity */
40
-                $entity = EntityMutator::getEntityFromInputData($model, $input);
41
-
42
-                $args = PriceMutation::prepareFields($input);
43
-
44
-                // Update the entity
45
-                $entity->save($args);
46
-
47
-                do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_price_update', $entity, $input);
48
-            } catch (Exception $exception) {
49
-                EntityMutator::handleExceptions(
50
-                    $exception,
51
-                    esc_html__(
52
-                        'The price could not be updated because of the following error(s)',
53
-                        'event_espresso'
54
-                    )
55
-                );
56
-            }
57
-
58
-            return [
59
-                'id' => $entity->ID(),
60
-            ];
61
-        };
62
-    }
18
+	/**
19
+	 * Defines the mutation data modification closure.
20
+	 *
21
+	 * @param EEM_Price $model
22
+	 * @param Price     $type
23
+	 * @return callable
24
+	 */
25
+	public static function mutateAndGetPayload(EEM_Price $model, Price $type)
26
+	{
27
+		/**
28
+		 * Updates an entity.
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
+		 * @throws EE_Error
35
+		 * @throws ReflectionException
36
+		 */
37
+		return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
38
+			try {
39
+				/** @var EE_Price $entity */
40
+				$entity = EntityMutator::getEntityFromInputData($model, $input);
41
+
42
+				$args = PriceMutation::prepareFields($input);
43
+
44
+				// Update the entity
45
+				$entity->save($args);
46
+
47
+				do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_price_update', $entity, $input);
48
+			} catch (Exception $exception) {
49
+				EntityMutator::handleExceptions(
50
+					$exception,
51
+					esc_html__(
52
+						'The price could not be updated because of the following error(s)',
53
+						'event_espresso'
54
+					)
55
+				);
56
+			}
57
+
58
+			return [
59
+				'id' => $entity->ID(),
60
+			];
61
+		};
62
+	}
63 63
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
          * @throws EE_Error
35 35
          * @throws ReflectionException
36 36
          */
37
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
37
+        return static function(array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
38 38
             try {
39 39
                 /** @var EE_Price $entity */
40 40
                 $entity = EntityMutator::getEntityFromInputData($model, $input);
Please login to merge, or discard this patch.
core/domain/services/graphql/mutators/FormSectionUpdate.php 2 patches
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -14,52 +14,52 @@
 block discarded – undo
14 14
 class FormSectionUpdate extends EntityMutator
15 15
 {
16 16
 
17
-    /**
18
-     * Defines the mutation data modification closure.
19
-     *
20
-     * @param EEM_Form_Section $model
21
-     * @return callable
22
-     */
23
-    public static function mutateAndGetPayload(EEM_Form_Section $model)
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
-         * @throws EE_Error
33
-         * @throws ReflectionException
34
-         */
35
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model): array {
36
-            try {
37
-                /** @var EE_Form_Section $entity */
38
-                $entity = EntityMutator::getEntityFromInputData($model, $input);
17
+	/**
18
+	 * Defines the mutation data modification closure.
19
+	 *
20
+	 * @param EEM_Form_Section $model
21
+	 * @return callable
22
+	 */
23
+	public static function mutateAndGetPayload(EEM_Form_Section $model)
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
+		 * @throws EE_Error
33
+		 * @throws ReflectionException
34
+		 */
35
+		return static function (array $input, AppContext $context, ResolveInfo $info) use ($model): array {
36
+			try {
37
+				/** @var EE_Form_Section $entity */
38
+				$entity = EntityMutator::getEntityFromInputData($model, $input);
39 39
 
40
-                $args = FormSectionMutation::prepareFields($input);
40
+				$args = FormSectionMutation::prepareFields($input);
41 41
 
42
-                // Update the entity
43
-                $entity->save($args);
42
+				// Update the entity
43
+				$entity->save($args);
44 44
 
45
-                do_action(
46
-                    'AHEE__EventEspresso_core_domain_services_graphql_mutators_form_section_update',
47
-                    $entity,
48
-                    $input
49
-                );
50
-            } catch (Exception $exception) {
51
-                EntityMutator::handleExceptions(
52
-                    $exception,
53
-                    esc_html__(
54
-                        'The form section could not be updated because of the following error(s)',
55
-                        'event_espresso'
56
-                    )
57
-                );
58
-            }
45
+				do_action(
46
+					'AHEE__EventEspresso_core_domain_services_graphql_mutators_form_section_update',
47
+					$entity,
48
+					$input
49
+				);
50
+			} catch (Exception $exception) {
51
+				EntityMutator::handleExceptions(
52
+					$exception,
53
+					esc_html__(
54
+						'The form section could not be updated because of the following error(s)',
55
+						'event_espresso'
56
+					)
57
+				);
58
+			}
59 59
 
60
-            return [
61
-                'id' => $entity->UUID(),
62
-            ];
63
-        };
64
-    }
60
+			return [
61
+				'id' => $entity->UUID(),
62
+			];
63
+		};
64
+	}
65 65
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
          * @throws EE_Error
33 33
          * @throws ReflectionException
34 34
          */
35
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model): array {
35
+        return static function(array $input, AppContext $context, ResolveInfo $info) use ($model): array {
36 36
             try {
37 37
                 /** @var EE_Form_Section $entity */
38 38
                 $entity = EntityMutator::getEntityFromInputData($model, $input);
Please login to merge, or discard this patch.
core/domain/services/graphql/mutators/TicketDelete.php 2 patches
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -17,91 +17,91 @@
 block discarded – undo
17 17
 class TicketDelete extends EntityMutator
18 18
 {
19 19
 
20
-    /**
21
-     * Defines the mutation data modification closure.
22
-     *
23
-     * @param EEM_Ticket $model
24
-     * @param Ticket     $type
25
-     * @return callable
26
-     */
27
-    public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type)
28
-    {
29
-        /**
30
-         * Deletes an entity.
31
-         *
32
-         * @param array       $input   The input for the mutation
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
36
-         */
37
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
38
-            try {
39
-                /** @var EE_Ticket $entity */
40
-                $entity = EntityMutator::getEntityFromInputData($model, $input);
20
+	/**
21
+	 * Defines the mutation data modification closure.
22
+	 *
23
+	 * @param EEM_Ticket $model
24
+	 * @param Ticket     $type
25
+	 * @return callable
26
+	 */
27
+	public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type)
28
+	{
29
+		/**
30
+		 * Deletes an entity.
31
+		 *
32
+		 * @param array       $input   The input for the mutation
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
36
+		 */
37
+		return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
38
+			try {
39
+				/** @var EE_Ticket $entity */
40
+				$entity = EntityMutator::getEntityFromInputData($model, $input);
41 41
 
42
-                // Delete the entity
43
-                if (! empty($input['deletePermanently'])) {
44
-                    $result = TicketDelete::deleteTicketAndRelations($entity);
45
-                } else {
46
-                    // trash the ticket
47
-                    $result = TicketDelete::trashTicket($entity);
48
-                }
49
-                EntityMutator::validateResults($result);
42
+				// Delete the entity
43
+				if (! empty($input['deletePermanently'])) {
44
+					$result = TicketDelete::deleteTicketAndRelations($entity);
45
+				} else {
46
+					// trash the ticket
47
+					$result = TicketDelete::trashTicket($entity);
48
+				}
49
+				EntityMutator::validateResults($result);
50 50
 
51
-                do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_ticket_delete', $entity, $input);
52
-            } catch (Exception $exception) {
53
-                EntityMutator::handleExceptions(
54
-                    $exception,
55
-                    esc_html__(
56
-                        'The ticket could not be deleted because of the following error(s)',
57
-                        'event_espresso'
58
-                    )
59
-                );
60
-            }
51
+				do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_ticket_delete', $entity, $input);
52
+			} catch (Exception $exception) {
53
+				EntityMutator::handleExceptions(
54
+					$exception,
55
+					esc_html__(
56
+						'The ticket could not be deleted because of the following error(s)',
57
+						'event_espresso'
58
+					)
59
+				);
60
+			}
61 61
 
62
-            return [
63
-                'deleted' => $entity,
64
-            ];
65
-        };
66
-    }
62
+			return [
63
+				'deleted' => $entity,
64
+			];
65
+		};
66
+	}
67 67
 
68
-    /**
69
-     * Deletes a ticket permanently along with its relations.
70
-     *
71
-     * @param EE_Ticket $entity
72
-     * @return bool | int
73
-     * @throws ReflectionException
74
-     * @throws InvalidArgumentException
75
-     * @throws InvalidInterfaceException
76
-     * @throws InvalidDataTypeException
77
-     * @throws EE_Error
78
-     */
79
-    public static function deleteTicketAndRelations(EE_Ticket $entity)
80
-    {
81
-        // Remove related non-default prices for the ticket
82
-        $entity->delete_related_permanently('Price', [['PRC_is_default' => false]]);
83
-        // The ticket still might have relations with default taxes, lets divorce them
84
-        $entity->_remove_relations('Price');
85
-        // Remove relation with datetimes
86
-        $entity->_remove_relations('Datetime');
87
-        // Now delete the ticket permanently
88
-        return $entity->delete_permanently();
89
-    }
68
+	/**
69
+	 * Deletes a ticket permanently along with its relations.
70
+	 *
71
+	 * @param EE_Ticket $entity
72
+	 * @return bool | int
73
+	 * @throws ReflectionException
74
+	 * @throws InvalidArgumentException
75
+	 * @throws InvalidInterfaceException
76
+	 * @throws InvalidDataTypeException
77
+	 * @throws EE_Error
78
+	 */
79
+	public static function deleteTicketAndRelations(EE_Ticket $entity)
80
+	{
81
+		// Remove related non-default prices for the ticket
82
+		$entity->delete_related_permanently('Price', [['PRC_is_default' => false]]);
83
+		// The ticket still might have relations with default taxes, lets divorce them
84
+		$entity->_remove_relations('Price');
85
+		// Remove relation with datetimes
86
+		$entity->_remove_relations('Datetime');
87
+		// Now delete the ticket permanently
88
+		return $entity->delete_permanently();
89
+	}
90 90
 
91
-    /**
92
-     * Trashes a ticket.
93
-     *
94
-     * @param EE_Ticket $entity
95
-     * @return bool | int
96
-     * @throws ReflectionException
97
-     * @throws InvalidArgumentException
98
-     * @throws InvalidInterfaceException
99
-     * @throws InvalidDataTypeException
100
-     * @throws EE_Error
101
-     */
102
-    public static function trashTicket(EE_Ticket $entity)
103
-    {
104
-        // trash the ticket
105
-        return $entity->delete();
106
-    }
91
+	/**
92
+	 * Trashes a ticket.
93
+	 *
94
+	 * @param EE_Ticket $entity
95
+	 * @return bool | int
96
+	 * @throws ReflectionException
97
+	 * @throws InvalidArgumentException
98
+	 * @throws InvalidInterfaceException
99
+	 * @throws InvalidDataTypeException
100
+	 * @throws EE_Error
101
+	 */
102
+	public static function trashTicket(EE_Ticket $entity)
103
+	{
104
+		// trash the ticket
105
+		return $entity->delete();
106
+	}
107 107
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,13 +34,13 @@
 block discarded – undo
34 34
          * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
35 35
          * @return array
36 36
          */
37
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
37
+        return static function(array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
38 38
             try {
39 39
                 /** @var EE_Ticket $entity */
40 40
                 $entity = EntityMutator::getEntityFromInputData($model, $input);
41 41
 
42 42
                 // Delete the entity
43
-                if (! empty($input['deletePermanently'])) {
43
+                if ( ! empty($input['deletePermanently'])) {
44 44
                     $result = TicketDelete::deleteTicketAndRelations($entity);
45 45
                 } else {
46 46
                     // trash the ticket
Please login to merge, or discard this patch.
core/domain/services/graphql/mutators/FormSectionCreate.php 2 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -13,51 +13,51 @@
 block discarded – undo
13 13
 class FormSectionCreate extends EntityMutator
14 14
 {
15 15
 
16
-    /**
17
-     * Defines the mutation data modification closure.
18
-     *
19
-     * @param EEM_Form_Section $model
20
-     * @return callable
21
-     */
22
-    public static function mutateAndGetPayload(EEM_Form_Section $model)
23
-    {
24
-        /**
25
-         * Creates 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 (array $input, AppContext $context, ResolveInfo $info) use ($model): array {
33
-            $id = null;
34
-            try {
35
-                EntityMutator::checkPermissions($model);
36
-
37
-                $args = FormSectionMutation::prepareFields($input);
38
-
39
-                $entity = EE_Form_Section::new_instance($args);
40
-                $id = $entity->save();
41
-                EntityMutator::validateResults($id);
42
-
43
-                do_action(
44
-                    'AHEE__EventEspresso_core_domain_services_graphql_mutators_form_section_create',
45
-                    $entity,
46
-                    $input
47
-                );
48
-            } catch (Exception $exception) {
49
-                EntityMutator::handleExceptions(
50
-                    $exception,
51
-                    esc_html__(
52
-                        'The form section could not be created because of the following error(s)',
53
-                        'event_espresso'
54
-                    )
55
-                );
56
-            }
57
-
58
-            return [
59
-                'id' => $id,
60
-            ];
61
-        };
62
-    }
16
+	/**
17
+	 * Defines the mutation data modification closure.
18
+	 *
19
+	 * @param EEM_Form_Section $model
20
+	 * @return callable
21
+	 */
22
+	public static function mutateAndGetPayload(EEM_Form_Section $model)
23
+	{
24
+		/**
25
+		 * Creates 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 (array $input, AppContext $context, ResolveInfo $info) use ($model): array {
33
+			$id = null;
34
+			try {
35
+				EntityMutator::checkPermissions($model);
36
+
37
+				$args = FormSectionMutation::prepareFields($input);
38
+
39
+				$entity = EE_Form_Section::new_instance($args);
40
+				$id = $entity->save();
41
+				EntityMutator::validateResults($id);
42
+
43
+				do_action(
44
+					'AHEE__EventEspresso_core_domain_services_graphql_mutators_form_section_create',
45
+					$entity,
46
+					$input
47
+				);
48
+			} catch (Exception $exception) {
49
+				EntityMutator::handleExceptions(
50
+					$exception,
51
+					esc_html__(
52
+						'The form section could not be created because of the following error(s)',
53
+						'event_espresso'
54
+					)
55
+				);
56
+			}
57
+
58
+			return [
59
+				'id' => $id,
60
+			];
61
+		};
62
+	}
63 63
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
          * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
30 30
          * @return array
31 31
          */
32
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model): array {
32
+        return static function(array $input, AppContext $context, ResolveInfo $info) use ($model): array {
33 33
             $id = null;
34 34
             try {
35 35
                 EntityMutator::checkPermissions($model);
Please login to merge, or discard this patch.
core/domain/services/graphql/mutators/DatetimeCreate.php 2 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -13,56 +13,56 @@
 block discarded – undo
13 13
 class DatetimeCreate extends EntityMutator
14 14
 {
15 15
 
16
-    /**
17
-     * Defines the mutation data modification closure.
18
-     *
19
-     * @param EEM_Datetime $model
20
-     * @param Datetime     $type
21
-     * @return callable
22
-     */
23
-    public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type)
24
-    {
25
-        /**
26
-         * Creates 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 (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
34
-            $id = null;
35
-            try {
36
-                EntityMutator::checkPermissions($model);
16
+	/**
17
+	 * Defines the mutation data modification closure.
18
+	 *
19
+	 * @param EEM_Datetime $model
20
+	 * @param Datetime     $type
21
+	 * @return callable
22
+	 */
23
+	public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type)
24
+	{
25
+		/**
26
+		 * Creates 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 (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
34
+			$id = null;
35
+			try {
36
+				EntityMutator::checkPermissions($model);
37 37
 
38
-                $tickets = [];
39
-                $args = DatetimeMutation::prepareFields($input);
38
+				$tickets = [];
39
+				$args = DatetimeMutation::prepareFields($input);
40 40
 
41
-                if (isset($args['tickets'])) {
42
-                    $tickets = $args['tickets'];
43
-                    unset($args['tickets']);
44
-                }
41
+				if (isset($args['tickets'])) {
42
+					$tickets = $args['tickets'];
43
+					unset($args['tickets']);
44
+				}
45 45
 
46
-                $entity = EE_Datetime::new_instance($args);
47
-                $id = $entity->save();
48
-                EntityMutator::validateResults($id);
46
+				$entity = EE_Datetime::new_instance($args);
47
+				$id = $entity->save();
48
+				EntityMutator::validateResults($id);
49 49
 
50
-                if (! empty($tickets)) {
51
-                    DatetimeMutation::setRelatedTickets($entity, $tickets);
52
-                }
50
+				if (! empty($tickets)) {
51
+					DatetimeMutation::setRelatedTickets($entity, $tickets);
52
+				}
53 53
 
54
-                do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_datetime_create', $entity, $input);
55
-            } catch (Exception $exception) {
56
-                EntityMutator::handleExceptions(
57
-                    $exception,
58
-                    esc_html__(
59
-                        'The datetime could not be created because of the following error(s)',
60
-                        'event_espresso'
61
-                    )
62
-                );
63
-            }
54
+				do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_datetime_create', $entity, $input);
55
+			} catch (Exception $exception) {
56
+				EntityMutator::handleExceptions(
57
+					$exception,
58
+					esc_html__(
59
+						'The datetime could not be created because of the following error(s)',
60
+						'event_espresso'
61
+					)
62
+				);
63
+			}
64 64
 
65
-            return $id ? [ 'id' => $id ] : [];
66
-        };
67
-    }
65
+			return $id ? [ 'id' => $id ] : [];
66
+		};
67
+	}
68 68
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
          * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
31 31
          * @return array
32 32
          */
33
-        return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
33
+        return static function(array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array {
34 34
             $id = null;
35 35
             try {
36 36
                 EntityMutator::checkPermissions($model);
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
                 $id = $entity->save();
48 48
                 EntityMutator::validateResults($id);
49 49
 
50
-                if (! empty($tickets)) {
50
+                if ( ! empty($tickets)) {
51 51
                     DatetimeMutation::setRelatedTickets($entity, $tickets);
52 52
                 }
53 53
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
                 );
63 63
             }
64 64
 
65
-            return $id ? [ 'id' => $id ] : [];
65
+            return $id ? ['id' => $id] : [];
66 66
         };
67 67
     }
68 68
 }
Please login to merge, or discard this patch.