Completed
Branch EDTR/drag-and-drop (3217e5)
by
unknown
25:22 queued 16:35
created
core/domain/services/graphql/mutators/EntityReorder.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
     /**
26 26
      * Defines the mutation data modification closure.
27 27
      *
28
-     * @return callable
28
+     * @return \Closure
29 29
      */
30 30
     public static function mutateAndGetPayload()
31 31
     {
Please login to merge, or discard this patch.
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -5,7 +5,6 @@  discard block
 block discarded – undo
5 5
 use EE_Registry;
6 6
 use EEM_Base;
7 7
 use EE_Base_Class;
8
-
9 8
 use EE_Error;
10 9
 use EventEspresso\core\exceptions\ExceptionStackTraceDisplay;
11 10
 use Exception;
@@ -13,7 +12,6 @@  discard block
 block discarded – undo
13 12
 use ReflectionException;
14 13
 use EventEspresso\core\exceptions\InvalidDataTypeException;
15 14
 use EventEspresso\core\exceptions\InvalidInterfaceException;
16
-
17 15
 use GraphQL\Type\Definition\ResolveInfo;
18 16
 use RuntimeException;
19 17
 use WPGraphQL\AppContext;
Please login to merge, or discard this patch.
Indentation   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -22,135 +22,135 @@
 block discarded – undo
22 22
 
23 23
 class EntityReorder
24 24
 {
25
-    /**
26
-     * Defines the mutation data modification closure.
27
-     *
28
-     * @return callable
29
-     */
30
-    public static function mutateAndGetPayload()
31
-    {
32
-        /**
33
-         * Updates an entity.
34
-         *
35
-         * @param array       $input   The input for the mutation
36
-         * @param AppContext  $context The AppContext passed down to all resolvers
37
-         * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
38
-         * @return array
39
-         * @throws UserError
40
-         * @throws ReflectionException
41
-         * @throws InvalidArgumentException
42
-         * @throws InvalidInterfaceException
43
-         * @throws InvalidDataTypeException
44
-         * @throws EE_Error
45
-         */
46
-        return static function ($input, AppContext $context, ResolveInfo $info) {
47
-            /**
48
-             * Stop now if a user isn't allowed to reorder.
49
-             */
50
-            if (! current_user_can('ee_edit_events')) {
51
-                throw new UserError(
52
-                    esc_html__('Sorry, you do not have the required permissions to reorder entities', 'event_espresso')
53
-                );
54
-            }
55
-
56
-            $entityGuids = ! empty($input['entityIds']) ? array_map('sanitize_text_field', (array) $input['entityIds']) : [];
57
-            $entityType  = ! empty($input['entityType']) ? sanitize_text_field($input['entityType']) : null;
58
-
59
-            /**
60
-             * Make sure we have the IDs and entity type
61
-             */
62
-            if (empty($entityGuids) || empty($entityType)) {
63
-                throw new UserError(
64
-                    // translators: the placeholders are the names of the fields
65
-                    sprintf(esc_html__('%1$s and %2$s are required.', 'event_espresso'), 'entityIds', 'entityType')
66
-                );
67
-            }
68
-
69
-            $model = EE_Registry::instance()->load_model($entityType);
70
-
71
-            if (!($model instanceof EEM_Base)) {
72
-                throw new UserError(
73
-                    esc_html__(
74
-                        'A valid data model could not be obtained. Did you supply a valid entity type?',
75
-                        'event_espresso'
76
-                    )
77
-                );
78
-            }
79
-
80
-            // convert GUIDs to DB IDs
81
-            $entityDbids = array_map(function ($entityGuid) {
82
-                $id_parts = Relay::fromGlobalId($entityGuid);
83
-                return ! empty($id_parts['id']) ? absint($id_parts['id']) : 0;
84
-            }, (array) $entityGuids);
85
-            // remove 0 values
86
-            $entityDbids = array_filter($entityDbids);
87
-
88
-            /**
89
-             * If we could not get DB IDs for some GUIDs
90
-             */
91
-            if (count($entityDbids) !== count($entityGuids)) {
92
-                throw new UserError(
93
-                    esc_html__('Sorry, update cancelled due to missing or invalid entity IDs.', 'event_espresso')
94
-                );
95
-            }
96
-
97
-            // e.g. DTT_ID, TKT_ID
98
-            $primaryKey = $model->get_primary_key_field()->get_name();
99
-            // e.g. "DTT_ID" will give us "DTT"
100
-            $keyPrefix = explode('_', $primaryKey)[0];
101
-            $deletedKey  = $keyPrefix . '_deleted'; // e.g. "TKT_deleted"
102
-
103
-            $entities = $model::instance()->get_all([
104
-                [
105
-                    $primaryKey => ['IN', $entityDbids],
106
-                    $deletedKey => ['IN', [true, false]],
107
-                ],
108
-            ]);
109
-
110
-            /**
111
-             * If we could not get exactly same number of entities for the given DB IDs
112
-             */
113
-            if (count($entityDbids) !== count($entities)) {
114
-                throw new UserError(esc_html__('Sorry, update cancelled due to missing entities.', 'event_espresso'));
115
-            }
116
-
117
-            // Make sure we have an instance for every ID.
118
-            foreach ($entityDbids as $entityDbid) {
119
-                if (isset($entities[ $entityDbid ]) && $entities[ $entityDbid ] instanceof EE_Base_Class) {
120
-                    continue;
121
-                }
122
-                throw new UserError(esc_html__('Sorry, update cancelled due to invalid entities.', 'event_espresso'));
123
-            }
124
-
125
-            $orderKey  = $keyPrefix . '_order'; // e.g. "TKT_order"
126
-
127
-            $ok = false;
128
-
129
-            // We do not want to continue reorder if one fails.
130
-            // Thus wrap whole loop in try-catch
131
-            try {
132
-                foreach ($entityDbids as $order => $entityDbid) {
133
-                    $args = [
134
-                        $orderKey => $order + 1,
135
-                    ];
136
-                    $entities[ $entityDbid ]->save($args);
137
-                }
138
-                $ok = true;
139
-            } catch (Exception $exception) {
140
-                new ExceptionStackTraceDisplay(
141
-                    new RuntimeException(
142
-                        sprintf(
143
-                            esc_html__(
144
-                                'Failed to update order because of the following error(s): %1$s',
145
-                                'event_espresso'
146
-                            ),
147
-                            $exception->getMessage()
148
-                        )
149
-                    )
150
-                );
151
-            }
152
-
153
-            return compact('ok');
154
-        };
155
-    }
25
+	/**
26
+	 * Defines the mutation data modification closure.
27
+	 *
28
+	 * @return callable
29
+	 */
30
+	public static function mutateAndGetPayload()
31
+	{
32
+		/**
33
+		 * Updates an entity.
34
+		 *
35
+		 * @param array       $input   The input for the mutation
36
+		 * @param AppContext  $context The AppContext passed down to all resolvers
37
+		 * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
38
+		 * @return array
39
+		 * @throws UserError
40
+		 * @throws ReflectionException
41
+		 * @throws InvalidArgumentException
42
+		 * @throws InvalidInterfaceException
43
+		 * @throws InvalidDataTypeException
44
+		 * @throws EE_Error
45
+		 */
46
+		return static function ($input, AppContext $context, ResolveInfo $info) {
47
+			/**
48
+			 * Stop now if a user isn't allowed to reorder.
49
+			 */
50
+			if (! current_user_can('ee_edit_events')) {
51
+				throw new UserError(
52
+					esc_html__('Sorry, you do not have the required permissions to reorder entities', 'event_espresso')
53
+				);
54
+			}
55
+
56
+			$entityGuids = ! empty($input['entityIds']) ? array_map('sanitize_text_field', (array) $input['entityIds']) : [];
57
+			$entityType  = ! empty($input['entityType']) ? sanitize_text_field($input['entityType']) : null;
58
+
59
+			/**
60
+			 * Make sure we have the IDs and entity type
61
+			 */
62
+			if (empty($entityGuids) || empty($entityType)) {
63
+				throw new UserError(
64
+					// translators: the placeholders are the names of the fields
65
+					sprintf(esc_html__('%1$s and %2$s are required.', 'event_espresso'), 'entityIds', 'entityType')
66
+				);
67
+			}
68
+
69
+			$model = EE_Registry::instance()->load_model($entityType);
70
+
71
+			if (!($model instanceof EEM_Base)) {
72
+				throw new UserError(
73
+					esc_html__(
74
+						'A valid data model could not be obtained. Did you supply a valid entity type?',
75
+						'event_espresso'
76
+					)
77
+				);
78
+			}
79
+
80
+			// convert GUIDs to DB IDs
81
+			$entityDbids = array_map(function ($entityGuid) {
82
+				$id_parts = Relay::fromGlobalId($entityGuid);
83
+				return ! empty($id_parts['id']) ? absint($id_parts['id']) : 0;
84
+			}, (array) $entityGuids);
85
+			// remove 0 values
86
+			$entityDbids = array_filter($entityDbids);
87
+
88
+			/**
89
+			 * If we could not get DB IDs for some GUIDs
90
+			 */
91
+			if (count($entityDbids) !== count($entityGuids)) {
92
+				throw new UserError(
93
+					esc_html__('Sorry, update cancelled due to missing or invalid entity IDs.', 'event_espresso')
94
+				);
95
+			}
96
+
97
+			// e.g. DTT_ID, TKT_ID
98
+			$primaryKey = $model->get_primary_key_field()->get_name();
99
+			// e.g. "DTT_ID" will give us "DTT"
100
+			$keyPrefix = explode('_', $primaryKey)[0];
101
+			$deletedKey  = $keyPrefix . '_deleted'; // e.g. "TKT_deleted"
102
+
103
+			$entities = $model::instance()->get_all([
104
+				[
105
+					$primaryKey => ['IN', $entityDbids],
106
+					$deletedKey => ['IN', [true, false]],
107
+				],
108
+			]);
109
+
110
+			/**
111
+			 * If we could not get exactly same number of entities for the given DB IDs
112
+			 */
113
+			if (count($entityDbids) !== count($entities)) {
114
+				throw new UserError(esc_html__('Sorry, update cancelled due to missing entities.', 'event_espresso'));
115
+			}
116
+
117
+			// Make sure we have an instance for every ID.
118
+			foreach ($entityDbids as $entityDbid) {
119
+				if (isset($entities[ $entityDbid ]) && $entities[ $entityDbid ] instanceof EE_Base_Class) {
120
+					continue;
121
+				}
122
+				throw new UserError(esc_html__('Sorry, update cancelled due to invalid entities.', 'event_espresso'));
123
+			}
124
+
125
+			$orderKey  = $keyPrefix . '_order'; // e.g. "TKT_order"
126
+
127
+			$ok = false;
128
+
129
+			// We do not want to continue reorder if one fails.
130
+			// Thus wrap whole loop in try-catch
131
+			try {
132
+				foreach ($entityDbids as $order => $entityDbid) {
133
+					$args = [
134
+						$orderKey => $order + 1,
135
+					];
136
+					$entities[ $entityDbid ]->save($args);
137
+				}
138
+				$ok = true;
139
+			} catch (Exception $exception) {
140
+				new ExceptionStackTraceDisplay(
141
+					new RuntimeException(
142
+						sprintf(
143
+							esc_html__(
144
+								'Failed to update order because of the following error(s): %1$s',
145
+								'event_espresso'
146
+							),
147
+							$exception->getMessage()
148
+						)
149
+					)
150
+				);
151
+			}
152
+
153
+			return compact('ok');
154
+		};
155
+	}
156 156
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
          * @throws InvalidDataTypeException
44 44
          * @throws EE_Error
45 45
          */
46
-        return static function ($input, AppContext $context, ResolveInfo $info) {
46
+        return static function($input, AppContext $context, ResolveInfo $info) {
47 47
             /**
48 48
              * Stop now if a user isn't allowed to reorder.
49 49
              */
50
-            if (! current_user_can('ee_edit_events')) {
50
+            if ( ! current_user_can('ee_edit_events')) {
51 51
                 throw new UserError(
52 52
                     esc_html__('Sorry, you do not have the required permissions to reorder entities', 'event_espresso')
53 53
                 );
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 
69 69
             $model = EE_Registry::instance()->load_model($entityType);
70 70
 
71
-            if (!($model instanceof EEM_Base)) {
71
+            if ( ! ($model instanceof EEM_Base)) {
72 72
                 throw new UserError(
73 73
                     esc_html__(
74 74
                         'A valid data model could not be obtained. Did you supply a valid entity type?',
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
             }
79 79
 
80 80
             // convert GUIDs to DB IDs
81
-            $entityDbids = array_map(function ($entityGuid) {
81
+            $entityDbids = array_map(function($entityGuid) {
82 82
                 $id_parts = Relay::fromGlobalId($entityGuid);
83 83
                 return ! empty($id_parts['id']) ? absint($id_parts['id']) : 0;
84 84
             }, (array) $entityGuids);
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
             $primaryKey = $model->get_primary_key_field()->get_name();
99 99
             // e.g. "DTT_ID" will give us "DTT"
100 100
             $keyPrefix = explode('_', $primaryKey)[0];
101
-            $deletedKey  = $keyPrefix . '_deleted'; // e.g. "TKT_deleted"
101
+            $deletedKey = $keyPrefix.'_deleted'; // e.g. "TKT_deleted"
102 102
 
103 103
             $entities = $model::instance()->get_all([
104 104
                 [
@@ -116,13 +116,13 @@  discard block
 block discarded – undo
116 116
 
117 117
             // Make sure we have an instance for every ID.
118 118
             foreach ($entityDbids as $entityDbid) {
119
-                if (isset($entities[ $entityDbid ]) && $entities[ $entityDbid ] instanceof EE_Base_Class) {
119
+                if (isset($entities[$entityDbid]) && $entities[$entityDbid] instanceof EE_Base_Class) {
120 120
                     continue;
121 121
                 }
122 122
                 throw new UserError(esc_html__('Sorry, update cancelled due to invalid entities.', 'event_espresso'));
123 123
             }
124 124
 
125
-            $orderKey  = $keyPrefix . '_order'; // e.g. "TKT_order"
125
+            $orderKey = $keyPrefix.'_order'; // e.g. "TKT_order"
126 126
 
127 127
             $ok = false;
128 128
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
                     $args = [
134 134
                         $orderKey => $order + 1,
135 135
                     ];
136
-                    $entities[ $entityDbid ]->save($args);
136
+                    $entities[$entityDbid]->save($args);
137 137
                 }
138 138
                 $ok = true;
139 139
             } catch (Exception $exception) {
Please login to merge, or discard this patch.
core/domain/services/graphql/types/Datetime.php 2 patches
Indentation   +295 added lines, -295 removed lines patch added patch discarded remove patch
@@ -34,308 +34,308 @@
 block discarded – undo
34 34
 class Datetime extends TypeBase
35 35
 {
36 36
 
37
-    /**
38
-     * EventDate constructor.
39
-     *
40
-     * @param EEM_Datetime $datetime_model
41
-     */
42
-    public function __construct(EEM_Datetime $datetime_model)
43
-    {
44
-        $this->model = $datetime_model;
45
-        $this->setName($this->namespace . 'Datetime');
46
-        $this->setDescription(__('An event date', 'event_espresso'));
47
-        $this->setIsCustomPostType(false);
48
-        parent::__construct();
49
-    }
37
+	/**
38
+	 * EventDate constructor.
39
+	 *
40
+	 * @param EEM_Datetime $datetime_model
41
+	 */
42
+	public function __construct(EEM_Datetime $datetime_model)
43
+	{
44
+		$this->model = $datetime_model;
45
+		$this->setName($this->namespace . 'Datetime');
46
+		$this->setDescription(__('An event date', 'event_espresso'));
47
+		$this->setIsCustomPostType(false);
48
+		parent::__construct();
49
+	}
50 50
 
51 51
 
52
-    /**
53
-     * @return GraphQLFieldInterface[]
54
-     * @since $VID:$
55
-     */
56
-    public function getFields()
57
-    {
58
-        return [
59
-            new GraphQLField(
60
-                'id',
61
-                ['non_null' => 'ID'],
62
-                null,
63
-                esc_html__('The globally unique ID for the object.', 'event_espresso')
64
-            ),
65
-            new GraphQLOutputField(
66
-                'dbId',
67
-                ['non_null' => 'Int'],
68
-                'ID',
69
-                esc_html__('The datetime ID.', 'event_espresso')
70
-            ),
71
-            new GraphQLOutputField(
72
-                'cacheId',
73
-                ['non_null' => 'String'],
74
-                null,
75
-                esc_html__('The cache ID of the object.', 'event_espresso')
76
-            ),
77
-            new GraphQLField(
78
-                'capacity',
79
-                'Int',
80
-                'reg_limit',
81
-                esc_html__('Registration Limit for this time', 'event_espresso'),
82
-                [$this, 'parseInfiniteValue']
83
-            ),
84
-            new GraphQLField(
85
-                'description',
86
-                'String',
87
-                'description',
88
-                esc_html__('Description for Datetime', 'event_espresso')
89
-            ),
90
-            new GraphQLField(
91
-                'endDate',
92
-                'String',
93
-                'end_date_and_time',
94
-                esc_html__('End date and time of the Event', 'event_espresso'),
95
-                [$this, 'formatDatetime']
96
-            ),
97
-            new GraphQLOutputField(
98
-                'event',
99
-                $this->namespace . 'Event',
100
-                null,
101
-                esc_html__('Event of the datetime.', 'event_espresso')
102
-            ),
103
-            new GraphQLInputField(
104
-                'event',
105
-                'ID',
106
-                null,
107
-                esc_html__('Globally unique event ID of the datetime.', 'event_espresso')
108
-            ),
109
-            new GraphQLInputField(
110
-                'eventId',
111
-                'Int',
112
-                null,
113
-                esc_html__('Event ID of the datetime.', 'event_espresso')
114
-            ),
115
-            new GraphQLOutputField(
116
-                'isActive',
117
-                'Boolean',
118
-                'is_active',
119
-                esc_html__('Flag indicating datetime is active', 'event_espresso')
120
-            ),
121
-            new GraphQLOutputField(
122
-                'isExpired',
123
-                'Boolean',
124
-                'is_expired',
125
-                esc_html__('Flag indicating datetime is expired or not', 'event_espresso')
126
-            ),
127
-            new GraphQLField(
128
-                'isPrimary',
129
-                'Boolean',
130
-                'is_primary',
131
-                esc_html__('Flag indicating datetime is primary one for event', 'event_espresso')
132
-            ),
133
-            new GraphQLOutputField(
134
-                'isSoldOut',
135
-                'Boolean',
136
-                'sold_out',
137
-                esc_html__(
138
-                    'Flag indicating whether the tickets sold for this datetime, met or exceed the registration limit',
139
-                    'event_espresso'
140
-                )
141
-            ),
142
-            new GraphQLField(
143
-                'isTrashed',
144
-                'Boolean',
145
-                null,
146
-                esc_html__('Flag indicating datetime has been trashed.', 'event_espresso'),
147
-                null,
148
-                [$this, 'getIsTrashed']
149
-            ),
150
-            new GraphQLOutputField(
151
-                'isUpcoming',
152
-                'Boolean',
153
-                'is_upcoming',
154
-                esc_html__('Whether the date is upcoming', 'event_espresso')
155
-            ),
156
-            new GraphQLOutputField(
157
-                'length',
158
-                'Int',
159
-                'length',
160
-                esc_html__('The length of the event (start to end time) in seconds', 'event_espresso')
161
-            ),
162
-            new GraphQLField(
163
-                'name',
164
-                'String',
165
-                'name',
166
-                esc_html__('Datetime Name', 'event_espresso')
167
-            ),
168
-            new GraphQLField(
169
-                'order',
170
-                'Int',
171
-                'order',
172
-                esc_html__('The order in which the Datetime is displayed', 'event_espresso')
173
-            ),
174
-            new GraphQLOutputField(
175
-                'parent',
176
-                $this->name(),
177
-                null,
178
-                esc_html__('The parent datetime of the current datetime', 'event_espresso')
179
-            ),
180
-            new GraphQLInputField(
181
-                'parent',
182
-                'ID',
183
-                null,
184
-                esc_html__('The parent datetime ID', 'event_espresso')
185
-            ),
186
-            new GraphQLField(
187
-                'reserved',
188
-                'Int',
189
-                'reserved',
190
-                esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso')
191
-            ),
192
-            new GraphQLField(
193
-                'startDate',
194
-                'String',
195
-                'start_date_and_time',
196
-                esc_html__('Start date and time of the Event', 'event_espresso'),
197
-                [$this, 'formatDatetime']
198
-            ),
199
-            new GraphQLField(
200
-                'sold',
201
-                'Int',
202
-                'sold',
203
-                esc_html__('How many sales for this Datetime that have occurred', 'event_espresso')
204
-            ),
205
-            new GraphQLOutputField(
206
-                'status',
207
-                $this->namespace . 'DatetimeStatusEnum',
208
-                'get_active_status',
209
-                esc_html__('Datetime status', 'event_espresso')
210
-            ),
211
-            new GraphQLInputField(
212
-                'tickets',
213
-                ['list_of' => 'ID'],
214
-                null,
215
-                sprintf(
216
-                    '%1$s %2$s',
217
-                    esc_html__('Globally unique IDs of the tickets related to the datetime.', 'event_espresso'),
218
-                    esc_html__('Ignored if empty.', 'event_espresso')
219
-                )
220
-            ),
221
-        ];
222
-    }
52
+	/**
53
+	 * @return GraphQLFieldInterface[]
54
+	 * @since $VID:$
55
+	 */
56
+	public function getFields()
57
+	{
58
+		return [
59
+			new GraphQLField(
60
+				'id',
61
+				['non_null' => 'ID'],
62
+				null,
63
+				esc_html__('The globally unique ID for the object.', 'event_espresso')
64
+			),
65
+			new GraphQLOutputField(
66
+				'dbId',
67
+				['non_null' => 'Int'],
68
+				'ID',
69
+				esc_html__('The datetime ID.', 'event_espresso')
70
+			),
71
+			new GraphQLOutputField(
72
+				'cacheId',
73
+				['non_null' => 'String'],
74
+				null,
75
+				esc_html__('The cache ID of the object.', 'event_espresso')
76
+			),
77
+			new GraphQLField(
78
+				'capacity',
79
+				'Int',
80
+				'reg_limit',
81
+				esc_html__('Registration Limit for this time', 'event_espresso'),
82
+				[$this, 'parseInfiniteValue']
83
+			),
84
+			new GraphQLField(
85
+				'description',
86
+				'String',
87
+				'description',
88
+				esc_html__('Description for Datetime', 'event_espresso')
89
+			),
90
+			new GraphQLField(
91
+				'endDate',
92
+				'String',
93
+				'end_date_and_time',
94
+				esc_html__('End date and time of the Event', 'event_espresso'),
95
+				[$this, 'formatDatetime']
96
+			),
97
+			new GraphQLOutputField(
98
+				'event',
99
+				$this->namespace . 'Event',
100
+				null,
101
+				esc_html__('Event of the datetime.', 'event_espresso')
102
+			),
103
+			new GraphQLInputField(
104
+				'event',
105
+				'ID',
106
+				null,
107
+				esc_html__('Globally unique event ID of the datetime.', 'event_espresso')
108
+			),
109
+			new GraphQLInputField(
110
+				'eventId',
111
+				'Int',
112
+				null,
113
+				esc_html__('Event ID of the datetime.', 'event_espresso')
114
+			),
115
+			new GraphQLOutputField(
116
+				'isActive',
117
+				'Boolean',
118
+				'is_active',
119
+				esc_html__('Flag indicating datetime is active', 'event_espresso')
120
+			),
121
+			new GraphQLOutputField(
122
+				'isExpired',
123
+				'Boolean',
124
+				'is_expired',
125
+				esc_html__('Flag indicating datetime is expired or not', 'event_espresso')
126
+			),
127
+			new GraphQLField(
128
+				'isPrimary',
129
+				'Boolean',
130
+				'is_primary',
131
+				esc_html__('Flag indicating datetime is primary one for event', 'event_espresso')
132
+			),
133
+			new GraphQLOutputField(
134
+				'isSoldOut',
135
+				'Boolean',
136
+				'sold_out',
137
+				esc_html__(
138
+					'Flag indicating whether the tickets sold for this datetime, met or exceed the registration limit',
139
+					'event_espresso'
140
+				)
141
+			),
142
+			new GraphQLField(
143
+				'isTrashed',
144
+				'Boolean',
145
+				null,
146
+				esc_html__('Flag indicating datetime has been trashed.', 'event_espresso'),
147
+				null,
148
+				[$this, 'getIsTrashed']
149
+			),
150
+			new GraphQLOutputField(
151
+				'isUpcoming',
152
+				'Boolean',
153
+				'is_upcoming',
154
+				esc_html__('Whether the date is upcoming', 'event_espresso')
155
+			),
156
+			new GraphQLOutputField(
157
+				'length',
158
+				'Int',
159
+				'length',
160
+				esc_html__('The length of the event (start to end time) in seconds', 'event_espresso')
161
+			),
162
+			new GraphQLField(
163
+				'name',
164
+				'String',
165
+				'name',
166
+				esc_html__('Datetime Name', 'event_espresso')
167
+			),
168
+			new GraphQLField(
169
+				'order',
170
+				'Int',
171
+				'order',
172
+				esc_html__('The order in which the Datetime is displayed', 'event_espresso')
173
+			),
174
+			new GraphQLOutputField(
175
+				'parent',
176
+				$this->name(),
177
+				null,
178
+				esc_html__('The parent datetime of the current datetime', 'event_espresso')
179
+			),
180
+			new GraphQLInputField(
181
+				'parent',
182
+				'ID',
183
+				null,
184
+				esc_html__('The parent datetime ID', 'event_espresso')
185
+			),
186
+			new GraphQLField(
187
+				'reserved',
188
+				'Int',
189
+				'reserved',
190
+				esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso')
191
+			),
192
+			new GraphQLField(
193
+				'startDate',
194
+				'String',
195
+				'start_date_and_time',
196
+				esc_html__('Start date and time of the Event', 'event_espresso'),
197
+				[$this, 'formatDatetime']
198
+			),
199
+			new GraphQLField(
200
+				'sold',
201
+				'Int',
202
+				'sold',
203
+				esc_html__('How many sales for this Datetime that have occurred', 'event_espresso')
204
+			),
205
+			new GraphQLOutputField(
206
+				'status',
207
+				$this->namespace . 'DatetimeStatusEnum',
208
+				'get_active_status',
209
+				esc_html__('Datetime status', 'event_espresso')
210
+			),
211
+			new GraphQLInputField(
212
+				'tickets',
213
+				['list_of' => 'ID'],
214
+				null,
215
+				sprintf(
216
+					'%1$s %2$s',
217
+					esc_html__('Globally unique IDs of the tickets related to the datetime.', 'event_espresso'),
218
+					esc_html__('Ignored if empty.', 'event_espresso')
219
+				)
220
+			),
221
+		];
222
+	}
223 223
 
224 224
 
225
-    /**
226
-     * @param EE_Datetime   $source  The source that's passed down the GraphQL queries
227
-     * @param array       $args    The inputArgs on the field
228
-     * @param AppContext  $context The AppContext passed down the GraphQL tree
229
-     * @param ResolveInfo $info    The ResolveInfo passed down the GraphQL tree
230
-     * @return string
231
-     * @throws Exception
232
-     * @throws InvalidArgumentException
233
-     * @throws InvalidDataTypeException
234
-     * @throws InvalidInterfaceException
235
-     * @throws ReflectionException
236
-     * @throws UserError
237
-     * @throws UnexpectedEntityException
238
-     * @since $VID:$
239
-     */
240
-    public function getIsTrashed(EE_Datetime $source, array $args, AppContext $context, ResolveInfo $info)
241
-    {
242
-        return (bool) $source->get('DTT_deleted');
243
-    }
225
+	/**
226
+	 * @param EE_Datetime   $source  The source that's passed down the GraphQL queries
227
+	 * @param array       $args    The inputArgs on the field
228
+	 * @param AppContext  $context The AppContext passed down the GraphQL tree
229
+	 * @param ResolveInfo $info    The ResolveInfo passed down the GraphQL tree
230
+	 * @return string
231
+	 * @throws Exception
232
+	 * @throws InvalidArgumentException
233
+	 * @throws InvalidDataTypeException
234
+	 * @throws InvalidInterfaceException
235
+	 * @throws ReflectionException
236
+	 * @throws UserError
237
+	 * @throws UnexpectedEntityException
238
+	 * @since $VID:$
239
+	 */
240
+	public function getIsTrashed(EE_Datetime $source, array $args, AppContext $context, ResolveInfo $info)
241
+	{
242
+		return (bool) $source->get('DTT_deleted');
243
+	}
244 244
 
245 245
 
246
-    /**
247
-     * @param array $inputFields The mutation input fields.
248
-     * @throws InvalidArgumentException
249
-     * @throws ReflectionException
250
-     * @since $VID:$
251
-     */
252
-    public function registerMutations(array $inputFields)
253
-    {
254
-        // Register mutation to update an entity.
255
-        register_graphql_mutation(
256
-            'update' . $this->name(),
257
-            [
258
-                'inputFields'         => $inputFields,
259
-                'outputFields'        => [
260
-                    lcfirst($this->name()) => [
261
-                        'type'    => $this->name(),
262
-                        'resolve' => [$this, 'resolveFromPayload'],
263
-                    ],
264
-                ],
265
-                'mutateAndGetPayload' => DatetimeUpdate::mutateAndGetPayload($this->model, $this),
266
-            ]
267
-        );
268
-        // Register mutation to delete an entity.
269
-        register_graphql_mutation(
270
-            'delete' . $this->name(),
271
-            [
272
-                'inputFields'         => [
273
-                    'id'                => $inputFields['id'],
274
-                    'deletePermanently' => [
275
-                        'type'        => 'Boolean',
276
-                        'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'),
277
-                    ],
278
-                ],
279
-                'outputFields'        => [
280
-                    lcfirst($this->name()) => [
281
-                        'type'        => $this->name(),
282
-                        'description' => esc_html__('The object before it was deleted', 'event_espresso'),
283
-                        'resolve'     => static function ($payload) {
284
-                            $deleted = (object) $payload['deleted'];
246
+	/**
247
+	 * @param array $inputFields The mutation input fields.
248
+	 * @throws InvalidArgumentException
249
+	 * @throws ReflectionException
250
+	 * @since $VID:$
251
+	 */
252
+	public function registerMutations(array $inputFields)
253
+	{
254
+		// Register mutation to update an entity.
255
+		register_graphql_mutation(
256
+			'update' . $this->name(),
257
+			[
258
+				'inputFields'         => $inputFields,
259
+				'outputFields'        => [
260
+					lcfirst($this->name()) => [
261
+						'type'    => $this->name(),
262
+						'resolve' => [$this, 'resolveFromPayload'],
263
+					],
264
+				],
265
+				'mutateAndGetPayload' => DatetimeUpdate::mutateAndGetPayload($this->model, $this),
266
+			]
267
+		);
268
+		// Register mutation to delete an entity.
269
+		register_graphql_mutation(
270
+			'delete' . $this->name(),
271
+			[
272
+				'inputFields'         => [
273
+					'id'                => $inputFields['id'],
274
+					'deletePermanently' => [
275
+						'type'        => 'Boolean',
276
+						'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'),
277
+					],
278
+				],
279
+				'outputFields'        => [
280
+					lcfirst($this->name()) => [
281
+						'type'        => $this->name(),
282
+						'description' => esc_html__('The object before it was deleted', 'event_espresso'),
283
+						'resolve'     => static function ($payload) {
284
+							$deleted = (object) $payload['deleted'];
285 285
 
286
-                            return ! empty($deleted) ? $deleted : null;
287
-                        },
288
-                    ],
289
-                ],
290
-                'mutateAndGetPayload' => DatetimeDelete::mutateAndGetPayload($this->model, $this),
291
-            ]
292
-        );
286
+							return ! empty($deleted) ? $deleted : null;
287
+						},
288
+					],
289
+				],
290
+				'mutateAndGetPayload' => DatetimeDelete::mutateAndGetPayload($this->model, $this),
291
+			]
292
+		);
293 293
 
294
-        // remove primary key from input.
295
-        unset($inputFields['id']);
296
-        // Register mutation to update an entity.
297
-        register_graphql_mutation(
298
-            'create' . $this->name(),
299
-            [
300
-                'inputFields'         => $inputFields,
301
-                'outputFields'        => [
302
-                    lcfirst($this->name()) => [
303
-                        'type'    => $this->name(),
304
-                        'resolve' => [$this, 'resolveFromPayload'],
305
-                    ],
306
-                ],
307
-                'mutateAndGetPayload' => DatetimeCreate::mutateAndGetPayload($this->model, $this),
308
-            ]
309
-        );
294
+		// remove primary key from input.
295
+		unset($inputFields['id']);
296
+		// Register mutation to update an entity.
297
+		register_graphql_mutation(
298
+			'create' . $this->name(),
299
+			[
300
+				'inputFields'         => $inputFields,
301
+				'outputFields'        => [
302
+					lcfirst($this->name()) => [
303
+						'type'    => $this->name(),
304
+						'resolve' => [$this, 'resolveFromPayload'],
305
+					],
306
+				],
307
+				'mutateAndGetPayload' => DatetimeCreate::mutateAndGetPayload($this->model, $this),
308
+			]
309
+		);
310 310
         
311
-        // Register mutation to update an entity.
312
-        register_graphql_mutation(
313
-            'reorder' . $this->namespace . 'Entities',
314
-            [
315
-                'inputFields'         => [
316
-                    'entityIds'  => [
317
-                        'type'        => [
318
-                            'non_null' => ['list_of' => 'ID'],
319
-                        ],
320
-                        'description' => esc_html__('The reordered list of entity GUIDs.', 'event_espresso'),
321
-                    ],
322
-                    'entityType' => [
323
-                        'type'        => [
324
-                            'non_null' => $this->namespace . 'ModelNameEnum',
325
-                        ],
326
-                        'description' => esc_html__('The entity type for the IDs', 'event_espresso'),
327
-                    ],
328
-                ],
329
-                'outputFields'        => [
330
-                    'ok' => [
331
-                        'type'    => 'Boolean',
332
-                        'resolve' => function ($payload) {
333
-                            return (bool) $payload['ok'];
334
-                        },
335
-                    ],
336
-                ],
337
-                'mutateAndGetPayload' => EntityReorder::mutateAndGetPayload(),
338
-            ]
339
-        );
340
-    }
311
+		// Register mutation to update an entity.
312
+		register_graphql_mutation(
313
+			'reorder' . $this->namespace . 'Entities',
314
+			[
315
+				'inputFields'         => [
316
+					'entityIds'  => [
317
+						'type'        => [
318
+							'non_null' => ['list_of' => 'ID'],
319
+						],
320
+						'description' => esc_html__('The reordered list of entity GUIDs.', 'event_espresso'),
321
+					],
322
+					'entityType' => [
323
+						'type'        => [
324
+							'non_null' => $this->namespace . 'ModelNameEnum',
325
+						],
326
+						'description' => esc_html__('The entity type for the IDs', 'event_espresso'),
327
+					],
328
+				],
329
+				'outputFields'        => [
330
+					'ok' => [
331
+						'type'    => 'Boolean',
332
+						'resolve' => function ($payload) {
333
+							return (bool) $payload['ok'];
334
+						},
335
+					],
336
+				],
337
+				'mutateAndGetPayload' => EntityReorder::mutateAndGetPayload(),
338
+			]
339
+		);
340
+	}
341 341
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     public function __construct(EEM_Datetime $datetime_model)
43 43
     {
44 44
         $this->model = $datetime_model;
45
-        $this->setName($this->namespace . 'Datetime');
45
+        $this->setName($this->namespace.'Datetime');
46 46
         $this->setDescription(__('An event date', 'event_espresso'));
47 47
         $this->setIsCustomPostType(false);
48 48
         parent::__construct();
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
             ),
97 97
             new GraphQLOutputField(
98 98
                 'event',
99
-                $this->namespace . 'Event',
99
+                $this->namespace.'Event',
100 100
                 null,
101 101
                 esc_html__('Event of the datetime.', 'event_espresso')
102 102
             ),
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
             ),
205 205
             new GraphQLOutputField(
206 206
                 'status',
207
-                $this->namespace . 'DatetimeStatusEnum',
207
+                $this->namespace.'DatetimeStatusEnum',
208 208
                 'get_active_status',
209 209
                 esc_html__('Datetime status', 'event_espresso')
210 210
             ),
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
     {
254 254
         // Register mutation to update an entity.
255 255
         register_graphql_mutation(
256
-            'update' . $this->name(),
256
+            'update'.$this->name(),
257 257
             [
258 258
                 'inputFields'         => $inputFields,
259 259
                 'outputFields'        => [
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
         );
268 268
         // Register mutation to delete an entity.
269 269
         register_graphql_mutation(
270
-            'delete' . $this->name(),
270
+            'delete'.$this->name(),
271 271
             [
272 272
                 'inputFields'         => [
273 273
                     'id'                => $inputFields['id'],
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
                     lcfirst($this->name()) => [
281 281
                         'type'        => $this->name(),
282 282
                         'description' => esc_html__('The object before it was deleted', 'event_espresso'),
283
-                        'resolve'     => static function ($payload) {
283
+                        'resolve'     => static function($payload) {
284 284
                             $deleted = (object) $payload['deleted'];
285 285
 
286 286
                             return ! empty($deleted) ? $deleted : null;
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
         unset($inputFields['id']);
296 296
         // Register mutation to update an entity.
297 297
         register_graphql_mutation(
298
-            'create' . $this->name(),
298
+            'create'.$this->name(),
299 299
             [
300 300
                 'inputFields'         => $inputFields,
301 301
                 'outputFields'        => [
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
         
311 311
         // Register mutation to update an entity.
312 312
         register_graphql_mutation(
313
-            'reorder' . $this->namespace . 'Entities',
313
+            'reorder'.$this->namespace.'Entities',
314 314
             [
315 315
                 'inputFields'         => [
316 316
                     'entityIds'  => [
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
                     ],
322 322
                     'entityType' => [
323 323
                         'type'        => [
324
-                            'non_null' => $this->namespace . 'ModelNameEnum',
324
+                            'non_null' => $this->namespace.'ModelNameEnum',
325 325
                         ],
326 326
                         'description' => esc_html__('The entity type for the IDs', 'event_espresso'),
327 327
                     ],
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
                 'outputFields'        => [
330 330
                     'ok' => [
331 331
                         'type'    => 'Boolean',
332
-                        'resolve' => function ($payload) {
332
+                        'resolve' => function($payload) {
333 333
                             return (bool) $payload['ok'];
334 334
                         },
335 335
                     ],
Please login to merge, or discard this patch.
core/domain/services/graphql/enums/ModelNameEnum.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -17,30 +17,30 @@
 block discarded – undo
17 17
 class ModelNameEnum extends EnumBase
18 18
 {
19 19
 
20
-    /**
21
-     * ModelNameEnum constructor.
22
-     */
23
-    public function __construct()
24
-    {
25
-        $this->setName($this->namespace . 'ModelNameEnum');
26
-        $this->setDescription(esc_html__('Entity model name', 'event_espresso'));
27
-        parent::__construct();
28
-    }
20
+	/**
21
+	 * ModelNameEnum constructor.
22
+	 */
23
+	public function __construct()
24
+	{
25
+		$this->setName($this->namespace . 'ModelNameEnum');
26
+		$this->setDescription(esc_html__('Entity model name', 'event_espresso'));
27
+		parent::__construct();
28
+	}
29 29
 
30 30
 
31
-    /**
32
-     * @return array
33
-     * @since $VID:$
34
-     */
35
-    protected function getValues()
36
-    {
37
-        return [
38
-            'DATETIME'     => [
39
-                'value'       => EEM_Datetime::instance()->item_name(),
40
-            ],
41
-            'TICKET'     => [
42
-                'value'       => EEM_Ticket::instance()->item_name(),
43
-            ],
44
-        ];
45
-    }
31
+	/**
32
+	 * @return array
33
+	 * @since $VID:$
34
+	 */
35
+	protected function getValues()
36
+	{
37
+		return [
38
+			'DATETIME'     => [
39
+				'value'       => EEM_Datetime::instance()->item_name(),
40
+			],
41
+			'TICKET'     => [
42
+				'value'       => EEM_Ticket::instance()->item_name(),
43
+			],
44
+		];
45
+	}
46 46
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
      */
23 23
     public function __construct()
24 24
     {
25
-        $this->setName($this->namespace . 'ModelNameEnum');
25
+        $this->setName($this->namespace.'ModelNameEnum');
26 26
         $this->setDescription(esc_html__('Entity model name', 'event_espresso'));
27 27
         parent::__construct();
28 28
     }
Please login to merge, or discard this patch.