Completed
Branch master (59af22)
by
unknown
07:35 queued 03:06
created
core/domain/entities/routing/handlers/shared/GQLRequests.php 1 patch
Indentation   +220 added lines, -220 removed lines patch added patch discarded remove patch
@@ -19,232 +19,232 @@
 block discarded – undo
19 19
  */
20 20
 class GQLRequests extends Route
21 21
 {
22
-    /**
23
-     * @var AssetManifestFactory
24
-     */
25
-    private $manifest_factory;
22
+	/**
23
+	 * @var AssetManifestFactory
24
+	 */
25
+	private $manifest_factory;
26 26
 
27 27
 
28
-    /**
29
-     * AssetRequests constructor.
30
-     *
31
-     * @param EE_Dependency_Map    $dependency_map
32
-     * @param LoaderInterface      $loader
33
-     * @param RequestInterface     $request
34
-     * @param AssetManifestFactory $manifest_factory
35
-     */
36
-    public function __construct(
37
-        EE_Dependency_Map $dependency_map,
38
-        LoaderInterface $loader,
39
-        RequestInterface $request,
40
-        AssetManifestFactory $manifest_factory
41
-    ) {
42
-        $this->manifest_factory = $manifest_factory;
43
-        parent::__construct($dependency_map, $loader, $request);
44
-    }
28
+	/**
29
+	 * AssetRequests constructor.
30
+	 *
31
+	 * @param EE_Dependency_Map    $dependency_map
32
+	 * @param LoaderInterface      $loader
33
+	 * @param RequestInterface     $request
34
+	 * @param AssetManifestFactory $manifest_factory
35
+	 */
36
+	public function __construct(
37
+		EE_Dependency_Map $dependency_map,
38
+		LoaderInterface $loader,
39
+		RequestInterface $request,
40
+		AssetManifestFactory $manifest_factory
41
+	) {
42
+		$this->manifest_factory = $manifest_factory;
43
+		parent::__construct($dependency_map, $loader, $request);
44
+	}
45 45
 
46 46
 
47
-    /**
48
-     * returns true if the current request matches this route
49
-     *
50
-     * @return bool
51
-     * @since   5.0.0.p
52
-     */
53
-    public function matchesCurrentRequest(): bool
54
-    {
55
-        global $pagenow;
56
-        return (
57
-                   $this->request->isGQL()
58
-                   || $this->request->isUnitTesting()
59
-                   || (
60
-                       $this->request->isAdmin()
61
-                       && $this->request->getRequestParam('page') === 'espresso_events'
62
-                       && (
63
-                           $this->request->getRequestParam('action') === 'create_new'
64
-                           || $this->request->getRequestParam('action') === 'edit'
65
-                       )
66
-                   ) || (
67
-                       $pagenow
68
-                       && (
69
-                           $pagenow === 'post-new.php'
70
-                           || (
71
-                               $pagenow === 'post.php'
72
-                               && $this->request->getRequestParam('action') === 'edit'
73
-                           )
74
-                       )
75
-                   )
76
-               );
77
-    }
47
+	/**
48
+	 * returns true if the current request matches this route
49
+	 *
50
+	 * @return bool
51
+	 * @since   5.0.0.p
52
+	 */
53
+	public function matchesCurrentRequest(): bool
54
+	{
55
+		global $pagenow;
56
+		return (
57
+				   $this->request->isGQL()
58
+				   || $this->request->isUnitTesting()
59
+				   || (
60
+					   $this->request->isAdmin()
61
+					   && $this->request->getRequestParam('page') === 'espresso_events'
62
+					   && (
63
+						   $this->request->getRequestParam('action') === 'create_new'
64
+						   || $this->request->getRequestParam('action') === 'edit'
65
+					   )
66
+				   ) || (
67
+					   $pagenow
68
+					   && (
69
+						   $pagenow === 'post-new.php'
70
+						   || (
71
+							   $pagenow === 'post.php'
72
+							   && $this->request->getRequestParam('action') === 'edit'
73
+						   )
74
+					   )
75
+				   )
76
+			   );
77
+	}
78 78
 
79 79
 
80
-    /**
81
-     * @since 5.0.0.p
82
-     */
83
-    protected function registerDependencies()
84
-    {
85
-        $this->dependency_map->registerDependencies(
86
-            'EventEspresso\core\services\graphql\GraphQLManager',
87
-            [
88
-                'EventEspresso\core\services\graphql\ConnectionsManager' => EE_Dependency_Map::load_from_cache,
89
-                'EventEspresso\core\services\graphql\DataLoaderManager'  => EE_Dependency_Map::load_from_cache,
90
-                'EventEspresso\core\services\graphql\EnumsManager'       => EE_Dependency_Map::load_from_cache,
91
-                'EventEspresso\core\services\graphql\InputsManager'      => EE_Dependency_Map::load_from_cache,
92
-                'EventEspresso\core\services\graphql\TypesManager'       => EE_Dependency_Map::load_from_cache,
93
-                'EventEspresso\core\services\graphql\InterfaceManager'   => EE_Dependency_Map::load_from_cache
94
-            ]
95
-        );
96
-        $this->dependency_map->registerDependencies(
97
-            'EventEspresso\core\services\graphql\TypesManager',
98
-            [
99
-                'EventEspresso\core\services\graphql\types\TypeCollection' => EE_Dependency_Map::load_from_cache,
100
-            ]
101
-        );
102
-        $this->dependency_map->registerDependencies(
103
-            'EventEspresso\core\services\graphql\InputsManager',
104
-            [
105
-                'EventEspresso\core\services\graphql\inputs\InputCollection' => EE_Dependency_Map::load_from_cache,
106
-            ]
107
-        );
108
-        $this->dependency_map->registerDependencies(
109
-            'EventEspresso\core\services\graphql\EnumsManager',
110
-            [
111
-                'EventEspresso\core\services\graphql\enums\EnumCollection' => EE_Dependency_Map::load_from_cache,
112
-            ]
113
-        );
114
-        $this->dependency_map->registerDependencies(
115
-            'EventEspresso\core\services\graphql\ConnectionsManager',
116
-            [
117
-                'EventEspresso\core\services\graphql\connections\ConnectionCollection' => EE_Dependency_Map::load_from_cache,
118
-            ]
119
-        );
120
-        $this->dependency_map->registerDependencies(
121
-            'EventEspresso\core\services\graphql\DataLoaderManager',
122
-            [
123
-                'EventEspresso\core\services\graphql\loaders\DataLoaderCollection' => EE_Dependency_Map::load_from_cache,
124
-            ]
125
-        );
126
-        $this->dependency_map->registerDependencies(
127
-            'EventEspresso\core\services\graphql\InterfaceManager',
128
-            ['EventEspresso\core\services\graphql\interfaces\InterfaceCollection' => EE_Dependency_Map::load_from_cache],
129
-        );
130
-        $this->dependency_map->registerDependencies(
131
-            'EventEspresso\core\domain\services\graphql\types\Datetime',
132
-            ['EEM_Datetime' => EE_Dependency_Map::load_from_cache]
133
-        );
134
-        $this->dependency_map->registerDependencies(
135
-            'EventEspresso\core\domain\services\graphql\types\Attendee',
136
-            ['EEM_Attendee' => EE_Dependency_Map::load_from_cache]
137
-        );
138
-        $this->dependency_map->registerDependencies(
139
-            'EventEspresso\core\domain\services\graphql\types\Event',
140
-            ['EEM_Event' => EE_Dependency_Map::load_from_cache]
141
-        );
142
-        $this->dependency_map->registerDependencies(
143
-            'EventEspresso\core\domain\services\graphql\types\FormElement',
144
-            ['EEM_Form_Element' => EE_Dependency_Map::load_from_cache]
145
-        );
146
-        $this->dependency_map->registerDependencies(
147
-            'EventEspresso\core\domain\services\graphql\types\FormSection',
148
-            ['EEM_Form_Section' => EE_Dependency_Map::load_from_cache]
149
-        );
150
-        $this->dependency_map->registerDependencies(
151
-            'EventEspresso\core\domain\services\graphql\types\Ticket',
152
-            ['EEM_Ticket' => EE_Dependency_Map::load_from_cache]
153
-        );
154
-        $this->dependency_map->registerDependencies(
155
-            'EventEspresso\core\domain\services\graphql\types\Price',
156
-            ['EEM_Price' => EE_Dependency_Map::load_from_cache]
157
-        );
158
-        $this->dependency_map->registerDependencies(
159
-            'EventEspresso\core\domain\services\graphql\types\PriceType',
160
-            ['EEM_Price_Type' => EE_Dependency_Map::load_from_cache]
161
-        );
162
-        $this->dependency_map->registerDependencies(
163
-            'EventEspresso\core\domain\services\graphql\types\Venue',
164
-            ['EEM_Venue' => EE_Dependency_Map::load_from_cache]
165
-        );
166
-        $this->dependency_map->registerDependencies(
167
-            'EventEspresso\core\domain\services\graphql\types\State',
168
-            ['EEM_State' => EE_Dependency_Map::load_from_cache]
169
-        );
170
-        $this->dependency_map->registerDependencies(
171
-            'EventEspresso\core\domain\services\graphql\types\Country',
172
-            ['EEM_Country' => EE_Dependency_Map::load_from_cache]
173
-        );
174
-        $this->dependency_map->registerDependencies(
175
-            'EventEspresso\core\domain\services\graphql\connections\EventDatetimesConnection',
176
-            ['EEM_Datetime' => EE_Dependency_Map::load_from_cache]
177
-        );
178
-        $this->dependency_map->registerDependencies(
179
-            'EventEspresso\core\domain\services\graphql\connections\RootQueryDatetimesConnection',
180
-            ['EEM_Datetime' => EE_Dependency_Map::load_from_cache]
181
-        );
182
-        $this->dependency_map->registerDependencies(
183
-            'EventEspresso\core\domain\services\graphql\connections\RootQueryAttendeesConnection',
184
-            ['EEM_Attendee' => EE_Dependency_Map::load_from_cache]
185
-        );
186
-        $this->dependency_map->registerDependencies(
187
-            'EventEspresso\core\domain\services\graphql\connections\RootQueryCountriesConnection',
188
-            ['EEM_Country' => EE_Dependency_Map::load_from_cache]
189
-        );
190
-        $this->dependency_map->registerDependencies(
191
-            'EventEspresso\core\domain\services\graphql\connections\RootQueryFormElementsConnection',
192
-            ['EEM_Form_Element' => EE_Dependency_Map::load_from_cache]
193
-        );
194
-        $this->dependency_map->registerDependencies(
195
-            'EventEspresso\core\domain\services\graphql\connections\RootQueryFormSectionsConnection',
196
-            ['EEM_Form_Section' => EE_Dependency_Map::load_from_cache]
197
-        );
198
-        $this->dependency_map->registerDependencies(
199
-            'EventEspresso\core\domain\services\graphql\connections\RootQueryStatesConnection',
200
-            ['EEM_State' => EE_Dependency_Map::load_from_cache]
201
-        );
202
-        $this->dependency_map->registerDependencies(
203
-            'EventEspresso\core\domain\services\graphql\connections\DatetimeTicketsConnection',
204
-            ['EEM_Ticket' => EE_Dependency_Map::load_from_cache]
205
-        );
206
-        $this->dependency_map->registerDependencies(
207
-            'EventEspresso\core\domain\services\graphql\connections\RootQueryTicketsConnection',
208
-            ['EEM_Ticket' => EE_Dependency_Map::load_from_cache]
209
-        );
210
-        $this->dependency_map->registerDependencies(
211
-            'EventEspresso\core\domain\services\graphql\connections\TicketPricesConnection',
212
-            ['EEM_Price' => EE_Dependency_Map::load_from_cache]
213
-        );
214
-        $this->dependency_map->registerDependencies(
215
-            'EventEspresso\core\domain\services\graphql\connections\RootQueryPricesConnection',
216
-            ['EEM_Price' => EE_Dependency_Map::load_from_cache]
217
-        );
218
-        $this->dependency_map->registerDependencies(
219
-            'EventEspresso\core\domain\services\graphql\connections\RootQueryPriceTypesConnection',
220
-            ['EEM_Price_Type' => EE_Dependency_Map::load_from_cache]
221
-        );
222
-        $this->dependency_map->registerDependencies(
223
-            'EventEspresso\core\domain\services\graphql\connections\TicketDatetimesConnection',
224
-            ['EEM_Datetime' => EE_Dependency_Map::load_from_cache]
225
-        );
226
-        $this->dependency_map->registerDependencies(
227
-            'EventEspresso\core\domain\services\graphql\connections\EventVenuesConnection',
228
-            ['EEM_Venue' => EE_Dependency_Map::load_from_cache]
229
-        );
230
-    }
80
+	/**
81
+	 * @since 5.0.0.p
82
+	 */
83
+	protected function registerDependencies()
84
+	{
85
+		$this->dependency_map->registerDependencies(
86
+			'EventEspresso\core\services\graphql\GraphQLManager',
87
+			[
88
+				'EventEspresso\core\services\graphql\ConnectionsManager' => EE_Dependency_Map::load_from_cache,
89
+				'EventEspresso\core\services\graphql\DataLoaderManager'  => EE_Dependency_Map::load_from_cache,
90
+				'EventEspresso\core\services\graphql\EnumsManager'       => EE_Dependency_Map::load_from_cache,
91
+				'EventEspresso\core\services\graphql\InputsManager'      => EE_Dependency_Map::load_from_cache,
92
+				'EventEspresso\core\services\graphql\TypesManager'       => EE_Dependency_Map::load_from_cache,
93
+				'EventEspresso\core\services\graphql\InterfaceManager'   => EE_Dependency_Map::load_from_cache
94
+			]
95
+		);
96
+		$this->dependency_map->registerDependencies(
97
+			'EventEspresso\core\services\graphql\TypesManager',
98
+			[
99
+				'EventEspresso\core\services\graphql\types\TypeCollection' => EE_Dependency_Map::load_from_cache,
100
+			]
101
+		);
102
+		$this->dependency_map->registerDependencies(
103
+			'EventEspresso\core\services\graphql\InputsManager',
104
+			[
105
+				'EventEspresso\core\services\graphql\inputs\InputCollection' => EE_Dependency_Map::load_from_cache,
106
+			]
107
+		);
108
+		$this->dependency_map->registerDependencies(
109
+			'EventEspresso\core\services\graphql\EnumsManager',
110
+			[
111
+				'EventEspresso\core\services\graphql\enums\EnumCollection' => EE_Dependency_Map::load_from_cache,
112
+			]
113
+		);
114
+		$this->dependency_map->registerDependencies(
115
+			'EventEspresso\core\services\graphql\ConnectionsManager',
116
+			[
117
+				'EventEspresso\core\services\graphql\connections\ConnectionCollection' => EE_Dependency_Map::load_from_cache,
118
+			]
119
+		);
120
+		$this->dependency_map->registerDependencies(
121
+			'EventEspresso\core\services\graphql\DataLoaderManager',
122
+			[
123
+				'EventEspresso\core\services\graphql\loaders\DataLoaderCollection' => EE_Dependency_Map::load_from_cache,
124
+			]
125
+		);
126
+		$this->dependency_map->registerDependencies(
127
+			'EventEspresso\core\services\graphql\InterfaceManager',
128
+			['EventEspresso\core\services\graphql\interfaces\InterfaceCollection' => EE_Dependency_Map::load_from_cache],
129
+		);
130
+		$this->dependency_map->registerDependencies(
131
+			'EventEspresso\core\domain\services\graphql\types\Datetime',
132
+			['EEM_Datetime' => EE_Dependency_Map::load_from_cache]
133
+		);
134
+		$this->dependency_map->registerDependencies(
135
+			'EventEspresso\core\domain\services\graphql\types\Attendee',
136
+			['EEM_Attendee' => EE_Dependency_Map::load_from_cache]
137
+		);
138
+		$this->dependency_map->registerDependencies(
139
+			'EventEspresso\core\domain\services\graphql\types\Event',
140
+			['EEM_Event' => EE_Dependency_Map::load_from_cache]
141
+		);
142
+		$this->dependency_map->registerDependencies(
143
+			'EventEspresso\core\domain\services\graphql\types\FormElement',
144
+			['EEM_Form_Element' => EE_Dependency_Map::load_from_cache]
145
+		);
146
+		$this->dependency_map->registerDependencies(
147
+			'EventEspresso\core\domain\services\graphql\types\FormSection',
148
+			['EEM_Form_Section' => EE_Dependency_Map::load_from_cache]
149
+		);
150
+		$this->dependency_map->registerDependencies(
151
+			'EventEspresso\core\domain\services\graphql\types\Ticket',
152
+			['EEM_Ticket' => EE_Dependency_Map::load_from_cache]
153
+		);
154
+		$this->dependency_map->registerDependencies(
155
+			'EventEspresso\core\domain\services\graphql\types\Price',
156
+			['EEM_Price' => EE_Dependency_Map::load_from_cache]
157
+		);
158
+		$this->dependency_map->registerDependencies(
159
+			'EventEspresso\core\domain\services\graphql\types\PriceType',
160
+			['EEM_Price_Type' => EE_Dependency_Map::load_from_cache]
161
+		);
162
+		$this->dependency_map->registerDependencies(
163
+			'EventEspresso\core\domain\services\graphql\types\Venue',
164
+			['EEM_Venue' => EE_Dependency_Map::load_from_cache]
165
+		);
166
+		$this->dependency_map->registerDependencies(
167
+			'EventEspresso\core\domain\services\graphql\types\State',
168
+			['EEM_State' => EE_Dependency_Map::load_from_cache]
169
+		);
170
+		$this->dependency_map->registerDependencies(
171
+			'EventEspresso\core\domain\services\graphql\types\Country',
172
+			['EEM_Country' => EE_Dependency_Map::load_from_cache]
173
+		);
174
+		$this->dependency_map->registerDependencies(
175
+			'EventEspresso\core\domain\services\graphql\connections\EventDatetimesConnection',
176
+			['EEM_Datetime' => EE_Dependency_Map::load_from_cache]
177
+		);
178
+		$this->dependency_map->registerDependencies(
179
+			'EventEspresso\core\domain\services\graphql\connections\RootQueryDatetimesConnection',
180
+			['EEM_Datetime' => EE_Dependency_Map::load_from_cache]
181
+		);
182
+		$this->dependency_map->registerDependencies(
183
+			'EventEspresso\core\domain\services\graphql\connections\RootQueryAttendeesConnection',
184
+			['EEM_Attendee' => EE_Dependency_Map::load_from_cache]
185
+		);
186
+		$this->dependency_map->registerDependencies(
187
+			'EventEspresso\core\domain\services\graphql\connections\RootQueryCountriesConnection',
188
+			['EEM_Country' => EE_Dependency_Map::load_from_cache]
189
+		);
190
+		$this->dependency_map->registerDependencies(
191
+			'EventEspresso\core\domain\services\graphql\connections\RootQueryFormElementsConnection',
192
+			['EEM_Form_Element' => EE_Dependency_Map::load_from_cache]
193
+		);
194
+		$this->dependency_map->registerDependencies(
195
+			'EventEspresso\core\domain\services\graphql\connections\RootQueryFormSectionsConnection',
196
+			['EEM_Form_Section' => EE_Dependency_Map::load_from_cache]
197
+		);
198
+		$this->dependency_map->registerDependencies(
199
+			'EventEspresso\core\domain\services\graphql\connections\RootQueryStatesConnection',
200
+			['EEM_State' => EE_Dependency_Map::load_from_cache]
201
+		);
202
+		$this->dependency_map->registerDependencies(
203
+			'EventEspresso\core\domain\services\graphql\connections\DatetimeTicketsConnection',
204
+			['EEM_Ticket' => EE_Dependency_Map::load_from_cache]
205
+		);
206
+		$this->dependency_map->registerDependencies(
207
+			'EventEspresso\core\domain\services\graphql\connections\RootQueryTicketsConnection',
208
+			['EEM_Ticket' => EE_Dependency_Map::load_from_cache]
209
+		);
210
+		$this->dependency_map->registerDependencies(
211
+			'EventEspresso\core\domain\services\graphql\connections\TicketPricesConnection',
212
+			['EEM_Price' => EE_Dependency_Map::load_from_cache]
213
+		);
214
+		$this->dependency_map->registerDependencies(
215
+			'EventEspresso\core\domain\services\graphql\connections\RootQueryPricesConnection',
216
+			['EEM_Price' => EE_Dependency_Map::load_from_cache]
217
+		);
218
+		$this->dependency_map->registerDependencies(
219
+			'EventEspresso\core\domain\services\graphql\connections\RootQueryPriceTypesConnection',
220
+			['EEM_Price_Type' => EE_Dependency_Map::load_from_cache]
221
+		);
222
+		$this->dependency_map->registerDependencies(
223
+			'EventEspresso\core\domain\services\graphql\connections\TicketDatetimesConnection',
224
+			['EEM_Datetime' => EE_Dependency_Map::load_from_cache]
225
+		);
226
+		$this->dependency_map->registerDependencies(
227
+			'EventEspresso\core\domain\services\graphql\connections\EventVenuesConnection',
228
+			['EEM_Venue' => EE_Dependency_Map::load_from_cache]
229
+		);
230
+	}
231 231
 
232 232
 
233
-    /**
234
-     * implements logic required to run during request
235
-     *
236
-     * @return bool
237
-     * @since   5.0.0.p
238
-     */
239
-    protected function requestHandler(): bool
240
-    {
241
-        // load handler for EE GraphQL requests
242
-        $graphQL_manager = $this->loader->getShared(
243
-            'EventEspresso\core\services\graphql\GraphQLManager'
244
-        );
245
-        $graphQL_manager->init();
246
-        $manifest = $this->manifest_factory->createFromDomainObject(DomainFactory::getEventEspressoCoreDomain());
247
-        $manifest->initialize();
248
-        return true;
249
-    }
233
+	/**
234
+	 * implements logic required to run during request
235
+	 *
236
+	 * @return bool
237
+	 * @since   5.0.0.p
238
+	 */
239
+	protected function requestHandler(): bool
240
+	{
241
+		// load handler for EE GraphQL requests
242
+		$graphQL_manager = $this->loader->getShared(
243
+			'EventEspresso\core\services\graphql\GraphQLManager'
244
+		);
245
+		$graphQL_manager->init();
246
+		$manifest = $this->manifest_factory->createFromDomainObject(DomainFactory::getEventEspressoCoreDomain());
247
+		$manifest->initialize();
248
+		return true;
249
+	}
250 250
 }
Please login to merge, or discard this patch.
core/services/graphql/TypesManager.php 1 patch
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -17,113 +17,113 @@
 block discarded – undo
17 17
  */
18 18
 class TypesManager implements GQLManagerInterface
19 19
 {
20
-    /**
21
-     * @var TypeCollection|TypeInterface[] $types
22
-     */
23
-    private $types;
20
+	/**
21
+	 * @var TypeCollection|TypeInterface[] $types
22
+	 */
23
+	private $types;
24 24
 
25 25
 
26
-    /**
27
-     * TypesManager constructor.
28
-     *
29
-     * @param TypeCollection|TypeInterface[] $types
30
-     */
31
-    public function __construct(TypeCollection $types)
32
-    {
33
-        $this->types = $types;
34
-    }
26
+	/**
27
+	 * TypesManager constructor.
28
+	 *
29
+	 * @param TypeCollection|TypeInterface[] $types
30
+	 */
31
+	public function __construct(TypeCollection $types)
32
+	{
33
+		$this->types = $types;
34
+	}
35 35
 
36 36
 
37
-    /**
38
-     * @throws CollectionDetailsException
39
-     * @throws CollectionLoaderException
40
-     * @since 5.0.0.p
41
-     */
42
-    public function init()
43
-    {
44
-        $this->types->loadTypes();
45
-        add_action('graphql_register_types', [$this, 'configureTypes'], 10);
46
-    }
37
+	/**
38
+	 * @throws CollectionDetailsException
39
+	 * @throws CollectionLoaderException
40
+	 * @since 5.0.0.p
41
+	 */
42
+	public function init()
43
+	{
44
+		$this->types->loadTypes();
45
+		add_action('graphql_register_types', [$this, 'configureTypes'], 10);
46
+	}
47 47
 
48 48
 
49
-    /**
50
-     * @since 5.0.0.p
51
-     */
52
-    public function configureTypes()
53
-    {
54
-        // loop through the collection of types and register their fields
55
-        foreach ($this->types as $type) {
56
-            if ($type->isCustomPostType()) {
57
-                $this->extendCustomPostType($type);
58
-            } else {
59
-                $this->registerType($type);
60
-            }
61
-        }
62
-    }
49
+	/**
50
+	 * @since 5.0.0.p
51
+	 */
52
+	public function configureTypes()
53
+	{
54
+		// loop through the collection of types and register their fields
55
+		foreach ($this->types as $type) {
56
+			if ($type->isCustomPostType()) {
57
+				$this->extendCustomPostType($type);
58
+			} else {
59
+				$this->registerType($type);
60
+			}
61
+		}
62
+	}
63 63
 
64 64
 
65
-    /**
66
-     * @param TypeInterface $type
67
-     * @since 5.0.0.p
68
-     */
69
-    public function extendCustomPostType(TypeInterface $type)
70
-    {
71
-        $typeName = $type->name();
72
-        foreach ($type->fields() as $field) {
73
-            $fieldName = $field->name();
74
-            $config = $field->toArray();
75
-            if ($field->useForInput()) {
76
-                // Register input fields for existing mutations.
77
-                register_graphql_field('Update' . $typeName . 'Input', $fieldName, $config);
78
-                register_graphql_field('Create' . $typeName . 'Input', $fieldName, $config);
79
-            }
80
-            if ($field->useForOutput()) {
81
-                $config['resolve'] = [$type, 'resolveField'];
82
-                // Register fields for queries.
83
-                register_graphql_field($typeName, $fieldName, $config);
84
-            }
85
-        }
86
-        if (is_callable([$type, 'extendMutations'])) {
87
-            /** @disregard P1013 */
88
-            $type->extendMutations();
89
-        }
90
-    }
65
+	/**
66
+	 * @param TypeInterface $type
67
+	 * @since 5.0.0.p
68
+	 */
69
+	public function extendCustomPostType(TypeInterface $type)
70
+	{
71
+		$typeName = $type->name();
72
+		foreach ($type->fields() as $field) {
73
+			$fieldName = $field->name();
74
+			$config = $field->toArray();
75
+			if ($field->useForInput()) {
76
+				// Register input fields for existing mutations.
77
+				register_graphql_field('Update' . $typeName . 'Input', $fieldName, $config);
78
+				register_graphql_field('Create' . $typeName . 'Input', $fieldName, $config);
79
+			}
80
+			if ($field->useForOutput()) {
81
+				$config['resolve'] = [$type, 'resolveField'];
82
+				// Register fields for queries.
83
+				register_graphql_field($typeName, $fieldName, $config);
84
+			}
85
+		}
86
+		if (is_callable([$type, 'extendMutations'])) {
87
+			/** @disregard P1013 */
88
+			$type->extendMutations();
89
+		}
90
+	}
91 91
 
92 92
 
93
-    /**
94
-     * @param TypeInterface $type
95
-     * @since 5.0.0.p
96
-     */
97
-    public function registerType(TypeInterface $type)
98
-    {
99
-        $outputFields = [];
100
-        $inputFields = [];
101
-        foreach ($type->fields() as $field) {
102
-            $fieldName = $field->name();
103
-            $config = $field->toArray();
104
-            if ($field->useForInput()) {
105
-                $inputFields[ $fieldName ] = $config;
106
-            }
107
-            if ($field->useForOutput()) {
108
-                $config['resolve'] = [$type, 'resolveField'];
109
-                $outputFields[ $fieldName ] = $config;
110
-            }
111
-        }
112
-        $typeName = $type->name();
113
-        if (! empty($outputFields)) {
114
-            // Register the object type.
115
-            register_graphql_object_type(
116
-                $typeName,
117
-                [
118
-                    'description' => $type->description(),
119
-                    'fields'      => $outputFields,
120
-                    'interfaces'  => $type->interfaces(),
121
-                ]
122
-            );
123
-        }
124
-        if (is_callable([$type, 'registerMutations'])) {
125
-            /** @disregard P1013 */
126
-            $type->registerMutations($inputFields);
127
-        }
128
-    }
93
+	/**
94
+	 * @param TypeInterface $type
95
+	 * @since 5.0.0.p
96
+	 */
97
+	public function registerType(TypeInterface $type)
98
+	{
99
+		$outputFields = [];
100
+		$inputFields = [];
101
+		foreach ($type->fields() as $field) {
102
+			$fieldName = $field->name();
103
+			$config = $field->toArray();
104
+			if ($field->useForInput()) {
105
+				$inputFields[ $fieldName ] = $config;
106
+			}
107
+			if ($field->useForOutput()) {
108
+				$config['resolve'] = [$type, 'resolveField'];
109
+				$outputFields[ $fieldName ] = $config;
110
+			}
111
+		}
112
+		$typeName = $type->name();
113
+		if (! empty($outputFields)) {
114
+			// Register the object type.
115
+			register_graphql_object_type(
116
+				$typeName,
117
+				[
118
+					'description' => $type->description(),
119
+					'fields'      => $outputFields,
120
+					'interfaces'  => $type->interfaces(),
121
+				]
122
+			);
123
+		}
124
+		if (is_callable([$type, 'registerMutations'])) {
125
+			/** @disregard P1013 */
126
+			$type->registerMutations($inputFields);
127
+		}
128
+	}
129 129
 }
Please login to merge, or discard this patch.
core/services/graphql/GraphQLManager.php 1 patch
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -15,84 +15,84 @@
 block discarded – undo
15 15
  */
16 16
 class GraphQLManager implements GQLManagerInterface
17 17
 {
18
-    /**
19
-     * @var ConnectionsManager $connections_manager
20
-     */
21
-    protected $connections_manager;
18
+	/**
19
+	 * @var ConnectionsManager $connections_manager
20
+	 */
21
+	protected $connections_manager;
22 22
 
23
-    /**
24
-     * @var DataLoaderManager $data_loader_manager
25
-     */
26
-    protected $data_loader_manager;
23
+	/**
24
+	 * @var DataLoaderManager $data_loader_manager
25
+	 */
26
+	protected $data_loader_manager;
27 27
 
28
-    /**
29
-     * @var EnumsManager $enums_manager
30
-     */
31
-    protected $enums_manager;
28
+	/**
29
+	 * @var EnumsManager $enums_manager
30
+	 */
31
+	protected $enums_manager;
32 32
 
33
-    /**
34
-     * @var InputsManager $inputs_manager
35
-     */
36
-    protected $inputs_manager;
33
+	/**
34
+	 * @var InputsManager $inputs_manager
35
+	 */
36
+	protected $inputs_manager;
37 37
 
38
-    /**
39
-     * @var TypesManager $types_manager
40
-     */
41
-    protected $types_manager;
38
+	/**
39
+	 * @var TypesManager $types_manager
40
+	 */
41
+	protected $types_manager;
42 42
 
43
-    /**
44
-     * @var InterfaceManager $interface_manager
45
-     */
46
-    protected $interface_manager;
43
+	/**
44
+	 * @var InterfaceManager $interface_manager
45
+	 */
46
+	protected $interface_manager;
47 47
     
48
-    /**
49
-     * @var boolean $initialized
50
-     */
51
-    private $initialized = false;
48
+	/**
49
+	 * @var boolean $initialized
50
+	 */
51
+	private $initialized = false;
52 52
 
53 53
 
54
-    /**
55
-     * GraphQLManager constructor.
56
-     *
57
-     * @param ConnectionsManager $connections_manager
58
-     * @param DataLoaderManager $data_loader_manager
59
-     * @param EnumsManager $enums_manager
60
-     * @param InputsManager $inputs_manager
61
-     * @param TypesManager $types_manager
62
-     */
63
-    public function __construct(
64
-        ConnectionsManager $connections_manager,
65
-        DataLoaderManager $data_loader_manager,
66
-        EnumsManager $enums_manager,
67
-        InputsManager $inputs_manager,
68
-        TypesManager $types_manager,
69
-        InterfaceManager $interface_manager
70
-    ) {
71
-        $this->connections_manager = $connections_manager;
72
-        $this->data_loader_manager = $data_loader_manager;
73
-        $this->enums_manager = $enums_manager;
74
-        $this->inputs_manager = $inputs_manager;
75
-        $this->types_manager = $types_manager;
76
-        $this->interface_manager = $interface_manager;
77
-    }
54
+	/**
55
+	 * GraphQLManager constructor.
56
+	 *
57
+	 * @param ConnectionsManager $connections_manager
58
+	 * @param DataLoaderManager $data_loader_manager
59
+	 * @param EnumsManager $enums_manager
60
+	 * @param InputsManager $inputs_manager
61
+	 * @param TypesManager $types_manager
62
+	 */
63
+	public function __construct(
64
+		ConnectionsManager $connections_manager,
65
+		DataLoaderManager $data_loader_manager,
66
+		EnumsManager $enums_manager,
67
+		InputsManager $inputs_manager,
68
+		TypesManager $types_manager,
69
+		InterfaceManager $interface_manager
70
+	) {
71
+		$this->connections_manager = $connections_manager;
72
+		$this->data_loader_manager = $data_loader_manager;
73
+		$this->enums_manager = $enums_manager;
74
+		$this->inputs_manager = $inputs_manager;
75
+		$this->types_manager = $types_manager;
76
+		$this->interface_manager = $interface_manager;
77
+	}
78 78
 
79 79
 
80
-    /**
81
-     * @throws CollectionDetailsException
82
-     * @throws CollectionLoaderException
83
-     * @since 5.0.0.p
84
-     */
85
-    public function init()
86
-    {
87
-        if ($this->initialized) {
88
-            return;
89
-        }
90
-        $this->connections_manager->init();
91
-        $this->data_loader_manager->init();
92
-        $this->enums_manager->init();
93
-        $this->interface_manager->init();
94
-        $this->inputs_manager->init();
95
-        $this->types_manager->init();
96
-        $this->initialized = true;
97
-    }
80
+	/**
81
+	 * @throws CollectionDetailsException
82
+	 * @throws CollectionLoaderException
83
+	 * @since 5.0.0.p
84
+	 */
85
+	public function init()
86
+	{
87
+		if ($this->initialized) {
88
+			return;
89
+		}
90
+		$this->connections_manager->init();
91
+		$this->data_loader_manager->init();
92
+		$this->enums_manager->init();
93
+		$this->interface_manager->init();
94
+		$this->inputs_manager->init();
95
+		$this->types_manager->init();
96
+		$this->initialized = true;
97
+	}
98 98
 }
Please login to merge, or discard this patch.
core/services/graphql/InterfaceManager.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -10,58 +10,58 @@
 block discarded – undo
10 10
 
11 11
 class InterfaceManager implements GQLManagerInterface
12 12
 {
13
-    /**
14
-     * @var InterfaceCollection|GraphQLInterface[]
15
-     */
16
-    protected InterfaceCollection $interfaces;
13
+	/**
14
+	 * @var InterfaceCollection|GraphQLInterface[]
15
+	 */
16
+	protected InterfaceCollection $interfaces;
17 17
 
18 18
 
19
-    public function __construct(InterfaceCollection $interfaces)
20
-    {
21
-        $this->interfaces = $interfaces;
22
-    }
19
+	public function __construct(InterfaceCollection $interfaces)
20
+	{
21
+		$this->interfaces = $interfaces;
22
+	}
23 23
 
24 24
 
25
-    public function init(): void
26
-    {
27
-        $this->interfaces->loadInterfaces();
28
-        add_action('graphql_register_types', [$this, 'callback']);
29
-    }
25
+	public function init(): void
26
+	{
27
+		$this->interfaces->loadInterfaces();
28
+		add_action('graphql_register_types', [$this, 'callback']);
29
+	}
30 30
 
31 31
 
32
-    /**
33
-     * @param TypeRegistry $registry
34
-     * @return void
35
-     * @throws Exception
36
-     */
37
-    public function callback(TypeRegistry $registry): void
38
-    {
39
-        foreach ($this->interfaces as $interface) {
40
-            $registry->register_interface_type(
41
-                $interface->getName(),
42
-                [
43
-                    'description' => $interface->getDescription(),
44
-                    'fields' => $this->fieldsToArray($interface->getFields()),
45
-                ]
46
-            );
47
-        }
48
-    }
32
+	/**
33
+	 * @param TypeRegistry $registry
34
+	 * @return void
35
+	 * @throws Exception
36
+	 */
37
+	public function callback(TypeRegistry $registry): void
38
+	{
39
+		foreach ($this->interfaces as $interface) {
40
+			$registry->register_interface_type(
41
+				$interface->getName(),
42
+				[
43
+					'description' => $interface->getDescription(),
44
+					'fields' => $this->fieldsToArray($interface->getFields()),
45
+				]
46
+			);
47
+		}
48
+	}
49 49
 
50
-    /**
51
-     * Convert an array of GraphQLFieldInterface into compatible format with WPGraphQL
52
-     * @param GraphQLFieldInterface[] $fields
53
-     * @return array
54
-     */
55
-    protected function fieldsToArray(array $fields): array
56
-    {
57
-        $array = [];
58
-        foreach ($fields as $f) {
59
-            $name = $f->name();
60
-            $array[$name] = $f->toArray();
61
-            if ($f->useForOutput()) {
62
-                $array[$name]['resolve'] = [$f, 'resolve'];
63
-            }
64
-        }
65
-        return $array;
66
-    }
50
+	/**
51
+	 * Convert an array of GraphQLFieldInterface into compatible format with WPGraphQL
52
+	 * @param GraphQLFieldInterface[] $fields
53
+	 * @return array
54
+	 */
55
+	protected function fieldsToArray(array $fields): array
56
+	{
57
+		$array = [];
58
+		foreach ($fields as $f) {
59
+			$name = $f->name();
60
+			$array[$name] = $f->toArray();
61
+			if ($f->useForOutput()) {
62
+				$array[$name]['resolve'] = [$f, 'resolve'];
63
+			}
64
+		}
65
+		return $array;
66
+	}
67 67
 }
Please login to merge, or discard this patch.
core/services/graphql/interfaces/GraphQLInterfaceInterface.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -6,12 +6,12 @@
 block discarded – undo
6 6
 
7 7
 interface GraphQLInterfaceInterface
8 8
 {
9
-    public function getName(): string;
9
+	public function getName(): string;
10 10
 
11
-    public function getDescription(): string;
11
+	public function getDescription(): string;
12 12
 
13
-    /**
14
-     * @return GraphQLFieldInterface[]
15
-     */
16
-    public function getFields(): array;
13
+	/**
14
+	 * @return GraphQLFieldInterface[]
15
+	 */
16
+	public function getFields(): array;
17 17
 }
Please login to merge, or discard this patch.
core/services/graphql/interfaces/InterfaceCollection.php 2 patches
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -12,84 +12,84 @@
 block discarded – undo
12 12
 
13 13
 class InterfaceCollection extends Collection
14 14
 {
15
-    const COLLECTION_NAME = 'espresso_graphql_interface_files';
15
+	const COLLECTION_NAME = 'espresso_graphql_interface_files';
16 16
 
17
-    protected ?CollectionLoader $loader = null;
17
+	protected ?CollectionLoader $loader = null;
18 18
 
19 19
 
20
-    /**
21
-     * InputCollection constructor
22
-     *
23
-     * @throws InvalidInterfaceException
24
-     */
25
-    public function __construct()
26
-    {
27
-        parent::__construct(
28
-            GraphQLInterfaceInterface::class,
29
-            InterfaceCollection::COLLECTION_NAME
30
-        );
31
-    }
20
+	/**
21
+	 * InputCollection constructor
22
+	 *
23
+	 * @throws InvalidInterfaceException
24
+	 */
25
+	public function __construct()
26
+	{
27
+		parent::__construct(
28
+			GraphQLInterfaceInterface::class,
29
+			InterfaceCollection::COLLECTION_NAME
30
+		);
31
+	}
32 32
 
33 33
 
34
-    /**
35
-     * @throws CollectionDetailsException
36
-     * @throws CollectionLoaderException
37
-     * @since 5.0.0.p
38
-     */
39
-    private function loadCollection()
40
-    {
41
-        if (! $this->loader instanceof CollectionLoader) {
42
-            $this->loader = new CollectionLoader(
43
-                new CollectionDetails(
44
-                    // collection name
45
-                    InterfaceCollection::COLLECTION_NAME,
46
-                    // collection interface
47
-                    GraphQLInterfaceInterface::class,
48
-                    // FQCNs for classes to add (all classes within each namespace will be loaded)
49
-                    apply_filters(
50
-                        'FHEE__EventEspresso_core_services_graphql_interfaces_InterfaceCollection__loadCollection__collection_FQCNs',
51
-                        ['EventEspresso\core\domain\services\graphql\interfaces']
52
-                    ),
53
-                    // filepaths to classes to add
54
-                    [],
55
-                    // file mask to use if parsing folder for files to add
56
-                    '',
57
-                    // what to use as identifier for collection entities
58
-                    // using CLASS NAME prevents duplicates (works like a singleton)
59
-                    CollectionDetails::ID_CLASS_NAME
60
-                ),
61
-                $this
62
-            );
63
-        }
64
-    }
34
+	/**
35
+	 * @throws CollectionDetailsException
36
+	 * @throws CollectionLoaderException
37
+	 * @since 5.0.0.p
38
+	 */
39
+	private function loadCollection()
40
+	{
41
+		if (! $this->loader instanceof CollectionLoader) {
42
+			$this->loader = new CollectionLoader(
43
+				new CollectionDetails(
44
+					// collection name
45
+					InterfaceCollection::COLLECTION_NAME,
46
+					// collection interface
47
+					GraphQLInterfaceInterface::class,
48
+					// FQCNs for classes to add (all classes within each namespace will be loaded)
49
+					apply_filters(
50
+						'FHEE__EventEspresso_core_services_graphql_interfaces_InterfaceCollection__loadCollection__collection_FQCNs',
51
+						['EventEspresso\core\domain\services\graphql\interfaces']
52
+					),
53
+					// filepaths to classes to add
54
+					[],
55
+					// file mask to use if parsing folder for files to add
56
+					'',
57
+					// what to use as identifier for collection entities
58
+					// using CLASS NAME prevents duplicates (works like a singleton)
59
+					CollectionDetails::ID_CLASS_NAME
60
+				),
61
+				$this
62
+			);
63
+		}
64
+	}
65 65
 
66 66
 
67
-    /**
68
-     * @return array|Collection|CollectionInterface
69
-     * @throws CollectionDetailsException
70
-     * @throws CollectionLoaderException
71
-     * @since 5.0.0.p
72
-     */
73
-    public function loadInterfaces()
74
-    {
75
-        $this->loadCollection();
76
-        return $this->loader->getCollection();
77
-    }
67
+	/**
68
+	 * @return array|Collection|CollectionInterface
69
+	 * @throws CollectionDetailsException
70
+	 * @throws CollectionLoaderException
71
+	 * @since 5.0.0.p
72
+	 */
73
+	public function loadInterfaces()
74
+	{
75
+		$this->loadCollection();
76
+		return $this->loader->getCollection();
77
+	}
78 78
 
79 79
 
80
-    /**
81
-     * getIdentifier
82
-     * Overrides EventEspresso\core\services\collections\Collection::getIdentifier()
83
-     * If no $identifier is supplied, then the  fully qualified class name is used
84
-     *
85
-     * @param        $object
86
-     * @param mixed  $identifier
87
-     * @return string
88
-     */
89
-    public function getIdentifier($object, $identifier = null)
90
-    {
91
-        return ! empty($identifier)
92
-            ? $identifier
93
-            : get_class($object);
94
-    }
80
+	/**
81
+	 * getIdentifier
82
+	 * Overrides EventEspresso\core\services\collections\Collection::getIdentifier()
83
+	 * If no $identifier is supplied, then the  fully qualified class name is used
84
+	 *
85
+	 * @param        $object
86
+	 * @param mixed  $identifier
87
+	 * @return string
88
+	 */
89
+	public function getIdentifier($object, $identifier = null)
90
+	{
91
+		return ! empty($identifier)
92
+			? $identifier
93
+			: get_class($object);
94
+	}
95 95
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
      */
50 50
     private function loadCollection()
51 51
     {
52
-        if (! $this->loader instanceof CollectionLoader) {
52
+        if ( ! $this->loader instanceof CollectionLoader) {
53 53
             $this->loader = new CollectionLoader(
54 54
                 new CollectionDetails(
55 55
                     // collection name
Please login to merge, or discard this patch.
core/services/graphql/interfaces/GraphQLInterface.php 2 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -7,63 +7,63 @@
 block discarded – undo
7 7
 
8 8
 abstract class GraphQLInterface implements GraphQLInterfaceInterface
9 9
 {
10
-    protected string $namespace = 'Espresso';
10
+	protected string $namespace = 'Espresso';
11 11
 
12
-    protected string $name;
12
+	protected string $name;
13 13
 
14
-    /**
15
-     * @var GraphQLFieldInterface[]
16
-     */
17
-    protected array $fields;
14
+	/**
15
+	 * @var GraphQLFieldInterface[]
16
+	 */
17
+	protected array $fields;
18 18
 
19
-    public function __construct()
20
-    {
21
-        $this->name = $this->namespace . $this->getShortName();
19
+	public function __construct()
20
+	{
21
+		$this->name = $this->namespace . $this->getShortName();
22 22
 
23
-        $this->fields = $this->validateFields($this->getArrayOfFields());
24
-    }
23
+		$this->fields = $this->validateFields($this->getArrayOfFields());
24
+	}
25 25
 
26
-    public function getName(): string
27
-    {
28
-        return $this->name;
29
-    }
26
+	public function getName(): string
27
+	{
28
+		return $this->name;
29
+	}
30 30
 
31
-    public function getDescription(): string
32
-    {
33
-        return '';
34
-    }
31
+	public function getDescription(): string
32
+	{
33
+		return '';
34
+	}
35 35
 
36
-    /**
37
-     * @return GraphQLFieldInterface[]
38
-     */
39
-    public function getFields(): array
40
-    {
41
-        return $this->fields;
42
-    }
36
+	/**
37
+	 * @return GraphQLFieldInterface[]
38
+	 */
39
+	public function getFields(): array
40
+	{
41
+		return $this->fields;
42
+	}
43 43
 
44
-    /**
45
-     * Get GraphQL interface name *without* namespace prefix
46
-     */
47
-    abstract protected function getShortName(): string;
44
+	/**
45
+	 * Get GraphQL interface name *without* namespace prefix
46
+	 */
47
+	abstract protected function getShortName(): string;
48 48
 
49
-    /**
50
-     * @return GraphQLFieldInterface[]
51
-     */
52
-    abstract protected function getArrayOfFields(): array;
49
+	/**
50
+	 * @return GraphQLFieldInterface[]
51
+	 */
52
+	abstract protected function getArrayOfFields(): array;
53 53
 
54 54
 
55
-    /**
56
-     * @param mixed[] $array
57
-     * @return GraphQLFieldInterface[]
58
-     */
59
-    protected function validateFields(array $array): array
60
-    {
61
-        foreach ($array as $field) {
62
-            if (! ($field instanceof GraphQLFieldInterface)) {
63
-                throw new EE_Error(esc_html__(sprintf('GraphQL interface %1$s expects its fields to be instance of %2$s', $this->name, GraphQLFieldInterface::class), 'event_espresso'));
64
-            }
65
-        }
55
+	/**
56
+	 * @param mixed[] $array
57
+	 * @return GraphQLFieldInterface[]
58
+	 */
59
+	protected function validateFields(array $array): array
60
+	{
61
+		foreach ($array as $field) {
62
+			if (! ($field instanceof GraphQLFieldInterface)) {
63
+				throw new EE_Error(esc_html__(sprintf('GraphQL interface %1$s expects its fields to be instance of %2$s', $this->name, GraphQLFieldInterface::class), 'event_espresso'));
64
+			}
65
+		}
66 66
 
67
-        return $array;
68
-    }
67
+		return $array;
68
+	}
69 69
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 
19 19
     public function __construct()
20 20
     {
21
-        $this->name = $this->namespace . $this->getShortName();
21
+        $this->name = $this->namespace.$this->getShortName();
22 22
 
23 23
         $this->fields = $this->validateFields($this->getArrayOfFields());
24 24
     }
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     protected function validateFields(array $array): array
60 60
     {
61 61
         foreach ($array as $field) {
62
-            if (! ($field instanceof GraphQLFieldInterface)) {
62
+            if ( ! ($field instanceof GraphQLFieldInterface)) {
63 63
                 throw new EE_Error(esc_html__(sprintf('GraphQL interface %1$s expects its fields to be instance of %2$s', $this->name, GraphQLFieldInterface::class), 'event_espresso'));
64 64
             }
65 65
         }
Please login to merge, or discard this patch.
core/services/graphql/types/TypeBase.php 2 patches
Indentation   +263 added lines, -263 removed lines patch added patch discarded remove patch
@@ -37,267 +37,267 @@
 block discarded – undo
37 37
  */
38 38
 abstract class TypeBase implements TypeInterface
39 39
 {
40
-    /**
41
-     * The graphql namespace/prefix.
42
-     */
43
-    protected string    $namespace   = 'Espresso';
44
-
45
-    protected ?EEM_Base $model       = null;
46
-
47
-    protected string    $name        = '';
48
-
49
-    protected string    $description = '';
50
-
51
-    /**
52
-     * @var GraphQLFieldInterface[] $fields
53
-     */
54
-    protected array         $fields              = [];
55
-
56
-    /**
57
-     * @var GraphQLInterfaceInterface[] $interfaces
58
-     */
59
-    protected array         $interfaces          = [];
60
-
61
-    protected FieldResolver $field_resolver;
62
-
63
-    protected bool          $is_custom_post_type = false;
64
-
65
-
66
-    /**
67
-     * TypeBase constructor.
68
-     *
69
-     * @param EEM_Base|null $model
70
-     */
71
-    public function __construct(EEM_Base $model = null)
72
-    {
73
-        $this->model = $model;
74
-        $this->setFields($this->getFields());
75
-        $this->field_resolver = new FieldResolver(
76
-            $this->model,
77
-            $this->getFieldsForResolver()
78
-        );
79
-    }
80
-
81
-
82
-    /**
83
-     * @return GraphQLFieldInterface[]
84
-     * @since 5.0.0.p
85
-     */
86
-    abstract protected function getFields(): array;
87
-
88
-
89
-    /**
90
-     * @return string
91
-     */
92
-    public function name(): string
93
-    {
94
-        return $this->name;
95
-    }
96
-
97
-
98
-    /**
99
-     * @param string $name
100
-     */
101
-    protected function setName(string $name)
102
-    {
103
-        $this->name = $name;
104
-    }
105
-
106
-
107
-    /**
108
-     * @return string
109
-     */
110
-    public function description(): string
111
-    {
112
-        return $this->description;
113
-    }
114
-
115
-
116
-    /**
117
-     * @param string $description
118
-     */
119
-    protected function setDescription(string $description)
120
-    {
121
-        $this->description = $description;
122
-    }
123
-
124
-
125
-    /**
126
-     * @return GraphQLFieldInterface[]
127
-     * @since 5.0.0.p
128
-     */
129
-    public function fields(): array
130
-    {
131
-        return $this->fields;
132
-    }
133
-
134
-
135
-    /**
136
-     * @param GraphQLFieldInterface[] $fields
137
-     */
138
-    protected function setFields(array $fields)
139
-    {
140
-        foreach ($fields as $field) {
141
-            if ($field instanceof GraphQLField) {
142
-                $this->fields[] = $field;
143
-            }
144
-        }
145
-    }
146
-
147
-
148
-    /**
149
-     * Creates a key map for internal resolver.
150
-     *
151
-     * @return array
152
-     * @since 5.0.0.p
153
-     */
154
-    public function getFieldsForResolver(): array
155
-    {
156
-        $fields = [];
157
-        foreach ($this->fields() as $field) {
158
-            if ($field->useForOutput()) {
159
-                $fields[ $field->name() ] = $field;
160
-            }
161
-        }
162
-        return $fields;
163
-    }
164
-
165
-
166
-    public function interfaces(): array
167
-    {
168
-        return $this->interfaces;
169
-    }
170
-
171
-
172
-    /**
173
-     * @return bool
174
-     */
175
-    public function isCustomPostType(): bool
176
-    {
177
-        return $this->is_custom_post_type;
178
-    }
179
-
180
-
181
-    /**
182
-     * @param bool $is_custom_post_type
183
-     */
184
-    protected function setIsCustomPostType(bool $is_custom_post_type)
185
-    {
186
-        $this->is_custom_post_type = filter_var($is_custom_post_type, FILTER_VALIDATE_BOOLEAN);
187
-    }
188
-
189
-
190
-    /**
191
-     * @param int|float $value
192
-     * @return int
193
-     * @since 5.0.0.p
194
-     */
195
-    public function parseInfiniteValue($value): int
196
-    {
197
-        $value = trim((string) $value);
198
-        return $value === ''
199
-               || $value === '∞'
200
-               || $value === 'INF'
201
-               || $value === INF
202
-               || $value === EE_INF
203
-               || is_infinite((float) $value)
204
-            ? -1
205
-            : $value;
206
-    }
207
-
208
-
209
-    /**
210
-     * @param mixed $source
211
-     * @return EE_Base_Class|null
212
-     * @throws EE_Error
213
-     * @throws ReflectionException
214
-     */
215
-    private function getModel($source): ?EE_Base_Class
216
-    {
217
-        // If it comes from a custom connection
218
-        // where the $source is already instantiated.
219
-        if ($source instanceof EE_Base_Class) {
220
-            return $source;
221
-        }
222
-        return $source instanceof Post
223
-            ? $this->model->get_one_by_ID($source->ID)
224
-            : null;
225
-    }
226
-
227
-
228
-    /**
229
-     * @param mixed       $source  The source that's passed down the GraphQL queries
230
-     * @param array       $args    The inputArgs on the field
231
-     * @param AppContext  $context The AppContext passed down the GraphQL tree
232
-     * @param ResolveInfo $info    The ResolveInfo passed down the GraphQL tree
233
-     * @return EE_Base_Class|Deferred|string|null
234
-     * @throws EE_Error
235
-     * @throws InvalidDataTypeException
236
-     * @throws InvalidInterfaceException
237
-     * @throws UnexpectedEntityException
238
-     * @throws UserError
239
-     * @throws InvalidArgumentException
240
-     * @throws ReflectionException
241
-     * @since 5.0.0.p
242
-     */
243
-    public function resolveField($source, array $args, AppContext $context, ResolveInfo $info)
244
-    {
245
-        $source = $source instanceof RootQuery
246
-            ? $source
247
-            : $this->getModel($source);
248
-
249
-        return $this->field_resolver->resolve($source, $args, $context, $info);
250
-    }
251
-
252
-
253
-    /**
254
-     * @param mixed      $payload The payload returned after mutation
255
-     * @param array      $args    The inputArgs on the field
256
-     * @param AppContext $context The AppContext passed down the GraphQL tree
257
-     * @return EE_Base_Class|EE_Soft_Delete_Base_Class|null
258
-     * @throws EE_Error
259
-     * @throws ReflectionException
260
-     */
261
-    public function resolveFromPayload($payload, array $args, AppContext $context)
262
-    {
263
-        if (empty($payload['id'])) {
264
-            return null;
265
-        }
266
-        return $this->model->get_one_by_ID($payload['id']);
267
-    }
268
-
269
-
270
-    /**
271
-     * Prepares a datetime value in ISO8601/RFC3339 format.
272
-     * It is assumed that the value of $datetime is in the format
273
-     * returned by EE_Base_Class::get_format().
274
-     *
275
-     * @param string        $datetime The datetime value.
276
-     * @param EE_Base_Class $source   The source object.
277
-     * @return string ISO8601/RFC3339 formatted datetime.
278
-     * @throws Exception
279
-     */
280
-    public function formatDatetime(string $datetime, EE_Base_Class $source): string
281
-    {
282
-        $format = $source->get_format();
283
-        // create date object based on local timezone
284
-        $datetime = DateTime::createFromFormat($format, $datetime, new DateTimeZone($source->get_timezone()));
285
-        // change the timezone to UTC
286
-        $datetime->setTimezone(new DateTimeZone('UTC'));
287
-
288
-        return $datetime->format(DateTimeInterface::RFC3339);
289
-    }
290
-
291
-
292
-    /**
293
-     * Converts an object to JSON. The object must have a "toJson" method.
294
-     *
295
-     * @param JsonableInterface $object The object/value.
296
-     * @param EE_Base_Class     $source The source object.
297
-     * @return string JSON representation of the object.
298
-     */
299
-    public function toJson(JsonableInterface $object, EE_Base_Class $source): string
300
-    {
301
-        return $object->toJson();
302
-    }
40
+	/**
41
+	 * The graphql namespace/prefix.
42
+	 */
43
+	protected string    $namespace   = 'Espresso';
44
+
45
+	protected ?EEM_Base $model       = null;
46
+
47
+	protected string    $name        = '';
48
+
49
+	protected string    $description = '';
50
+
51
+	/**
52
+	 * @var GraphQLFieldInterface[] $fields
53
+	 */
54
+	protected array         $fields              = [];
55
+
56
+	/**
57
+	 * @var GraphQLInterfaceInterface[] $interfaces
58
+	 */
59
+	protected array         $interfaces          = [];
60
+
61
+	protected FieldResolver $field_resolver;
62
+
63
+	protected bool          $is_custom_post_type = false;
64
+
65
+
66
+	/**
67
+	 * TypeBase constructor.
68
+	 *
69
+	 * @param EEM_Base|null $model
70
+	 */
71
+	public function __construct(EEM_Base $model = null)
72
+	{
73
+		$this->model = $model;
74
+		$this->setFields($this->getFields());
75
+		$this->field_resolver = new FieldResolver(
76
+			$this->model,
77
+			$this->getFieldsForResolver()
78
+		);
79
+	}
80
+
81
+
82
+	/**
83
+	 * @return GraphQLFieldInterface[]
84
+	 * @since 5.0.0.p
85
+	 */
86
+	abstract protected function getFields(): array;
87
+
88
+
89
+	/**
90
+	 * @return string
91
+	 */
92
+	public function name(): string
93
+	{
94
+		return $this->name;
95
+	}
96
+
97
+
98
+	/**
99
+	 * @param string $name
100
+	 */
101
+	protected function setName(string $name)
102
+	{
103
+		$this->name = $name;
104
+	}
105
+
106
+
107
+	/**
108
+	 * @return string
109
+	 */
110
+	public function description(): string
111
+	{
112
+		return $this->description;
113
+	}
114
+
115
+
116
+	/**
117
+	 * @param string $description
118
+	 */
119
+	protected function setDescription(string $description)
120
+	{
121
+		$this->description = $description;
122
+	}
123
+
124
+
125
+	/**
126
+	 * @return GraphQLFieldInterface[]
127
+	 * @since 5.0.0.p
128
+	 */
129
+	public function fields(): array
130
+	{
131
+		return $this->fields;
132
+	}
133
+
134
+
135
+	/**
136
+	 * @param GraphQLFieldInterface[] $fields
137
+	 */
138
+	protected function setFields(array $fields)
139
+	{
140
+		foreach ($fields as $field) {
141
+			if ($field instanceof GraphQLField) {
142
+				$this->fields[] = $field;
143
+			}
144
+		}
145
+	}
146
+
147
+
148
+	/**
149
+	 * Creates a key map for internal resolver.
150
+	 *
151
+	 * @return array
152
+	 * @since 5.0.0.p
153
+	 */
154
+	public function getFieldsForResolver(): array
155
+	{
156
+		$fields = [];
157
+		foreach ($this->fields() as $field) {
158
+			if ($field->useForOutput()) {
159
+				$fields[ $field->name() ] = $field;
160
+			}
161
+		}
162
+		return $fields;
163
+	}
164
+
165
+
166
+	public function interfaces(): array
167
+	{
168
+		return $this->interfaces;
169
+	}
170
+
171
+
172
+	/**
173
+	 * @return bool
174
+	 */
175
+	public function isCustomPostType(): bool
176
+	{
177
+		return $this->is_custom_post_type;
178
+	}
179
+
180
+
181
+	/**
182
+	 * @param bool $is_custom_post_type
183
+	 */
184
+	protected function setIsCustomPostType(bool $is_custom_post_type)
185
+	{
186
+		$this->is_custom_post_type = filter_var($is_custom_post_type, FILTER_VALIDATE_BOOLEAN);
187
+	}
188
+
189
+
190
+	/**
191
+	 * @param int|float $value
192
+	 * @return int
193
+	 * @since 5.0.0.p
194
+	 */
195
+	public function parseInfiniteValue($value): int
196
+	{
197
+		$value = trim((string) $value);
198
+		return $value === ''
199
+			   || $value === '∞'
200
+			   || $value === 'INF'
201
+			   || $value === INF
202
+			   || $value === EE_INF
203
+			   || is_infinite((float) $value)
204
+			? -1
205
+			: $value;
206
+	}
207
+
208
+
209
+	/**
210
+	 * @param mixed $source
211
+	 * @return EE_Base_Class|null
212
+	 * @throws EE_Error
213
+	 * @throws ReflectionException
214
+	 */
215
+	private function getModel($source): ?EE_Base_Class
216
+	{
217
+		// If it comes from a custom connection
218
+		// where the $source is already instantiated.
219
+		if ($source instanceof EE_Base_Class) {
220
+			return $source;
221
+		}
222
+		return $source instanceof Post
223
+			? $this->model->get_one_by_ID($source->ID)
224
+			: null;
225
+	}
226
+
227
+
228
+	/**
229
+	 * @param mixed       $source  The source that's passed down the GraphQL queries
230
+	 * @param array       $args    The inputArgs on the field
231
+	 * @param AppContext  $context The AppContext passed down the GraphQL tree
232
+	 * @param ResolveInfo $info    The ResolveInfo passed down the GraphQL tree
233
+	 * @return EE_Base_Class|Deferred|string|null
234
+	 * @throws EE_Error
235
+	 * @throws InvalidDataTypeException
236
+	 * @throws InvalidInterfaceException
237
+	 * @throws UnexpectedEntityException
238
+	 * @throws UserError
239
+	 * @throws InvalidArgumentException
240
+	 * @throws ReflectionException
241
+	 * @since 5.0.0.p
242
+	 */
243
+	public function resolveField($source, array $args, AppContext $context, ResolveInfo $info)
244
+	{
245
+		$source = $source instanceof RootQuery
246
+			? $source
247
+			: $this->getModel($source);
248
+
249
+		return $this->field_resolver->resolve($source, $args, $context, $info);
250
+	}
251
+
252
+
253
+	/**
254
+	 * @param mixed      $payload The payload returned after mutation
255
+	 * @param array      $args    The inputArgs on the field
256
+	 * @param AppContext $context The AppContext passed down the GraphQL tree
257
+	 * @return EE_Base_Class|EE_Soft_Delete_Base_Class|null
258
+	 * @throws EE_Error
259
+	 * @throws ReflectionException
260
+	 */
261
+	public function resolveFromPayload($payload, array $args, AppContext $context)
262
+	{
263
+		if (empty($payload['id'])) {
264
+			return null;
265
+		}
266
+		return $this->model->get_one_by_ID($payload['id']);
267
+	}
268
+
269
+
270
+	/**
271
+	 * Prepares a datetime value in ISO8601/RFC3339 format.
272
+	 * It is assumed that the value of $datetime is in the format
273
+	 * returned by EE_Base_Class::get_format().
274
+	 *
275
+	 * @param string        $datetime The datetime value.
276
+	 * @param EE_Base_Class $source   The source object.
277
+	 * @return string ISO8601/RFC3339 formatted datetime.
278
+	 * @throws Exception
279
+	 */
280
+	public function formatDatetime(string $datetime, EE_Base_Class $source): string
281
+	{
282
+		$format = $source->get_format();
283
+		// create date object based on local timezone
284
+		$datetime = DateTime::createFromFormat($format, $datetime, new DateTimeZone($source->get_timezone()));
285
+		// change the timezone to UTC
286
+		$datetime->setTimezone(new DateTimeZone('UTC'));
287
+
288
+		return $datetime->format(DateTimeInterface::RFC3339);
289
+	}
290
+
291
+
292
+	/**
293
+	 * Converts an object to JSON. The object must have a "toJson" method.
294
+	 *
295
+	 * @param JsonableInterface $object The object/value.
296
+	 * @param EE_Base_Class     $source The source object.
297
+	 * @return string JSON representation of the object.
298
+	 */
299
+	public function toJson(JsonableInterface $object, EE_Base_Class $source): string
300
+	{
301
+		return $object->toJson();
302
+	}
303 303
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -51,12 +51,12 @@  discard block
 block discarded – undo
51 51
     /**
52 52
      * @var GraphQLFieldInterface[] $fields
53 53
      */
54
-    protected array         $fields              = [];
54
+    protected array         $fields = [];
55 55
 
56 56
     /**
57 57
      * @var GraphQLInterfaceInterface[] $interfaces
58 58
      */
59
-    protected array         $interfaces          = [];
59
+    protected array         $interfaces = [];
60 60
 
61 61
     protected FieldResolver $field_resolver;
62 62
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
         $fields = [];
157 157
         foreach ($this->fields() as $field) {
158 158
             if ($field->useForOutput()) {
159
-                $fields[ $field->name() ] = $field;
159
+                $fields[$field->name()] = $field;
160 160
             }
161 161
         }
162 162
         return $fields;
Please login to merge, or discard this patch.
core/services/graphql/types/TypeInterface.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -24,84 +24,84 @@
 block discarded – undo
24 24
  */
25 25
 interface TypeInterface
26 26
 {
27
-    /**
28
-     * @return string
29
-     */
30
-    public function name(): string;
31
-
32
-
33
-    /**
34
-     * @return string
35
-     */
36
-    public function description(): string;
37
-
38
-
39
-    /**
40
-     * @return GraphQLFieldInterface[]
41
-     * @since 5.0.0.p
42
-     */
43
-    public function fields(): array;
44
-
45
-    /**
46
-     * @return GraphQLInterfaceInterface
47
-     */
48
-    public function interfaces(): array;
49
-
50
-
51
-    /**
52
-     * Creates a key map for internal resolver.
53
-     *
54
-     * @return array
55
-     * @since 5.0.0.p
56
-     */
57
-    public function getFieldsForResolver(): array;
58
-
59
-
60
-    /**
61
-     * @return bool
62
-     */
63
-    public function isCustomPostType(): bool;
64
-
65
-
66
-    /**
67
-     * @param int|float $value
68
-     * @return int
69
-     * @since 5.0.0.p
70
-     */
71
-    public function parseInfiniteValue($value): int;
72
-
73
-
74
-    /**
75
-     * @param mixed       $source  The source that's passed down the GraphQL queries
76
-     * @param array       $args    The inputArgs on the field
77
-     * @param AppContext  $context The AppContext passed down the GraphQL tree
78
-     * @param ResolveInfo $info    The ResolveInfo passed down the GraphQL tree
79
-     * @return mixed
80
-     * @throws EE_Error
81
-     * @throws InvalidDataTypeException
82
-     * @throws InvalidInterfaceException
83
-     * @throws UnexpectedEntityException
84
-     * @throws UserError
85
-     * @throws InvalidArgumentException
86
-     * @throws ReflectionException
87
-     * @since 5.0.0.p
88
-     */
89
-    public function resolveField($source, array $args, AppContext $context, ResolveInfo $info);
90
-
91
-
92
-    /**
93
-     * @param mixed      $payload The payload returned after mutation
94
-     * @param array      $args    The inputArgs on the field
95
-     * @param AppContext $context The AppContext passed down the GraphQL tree
96
-     * @return string|null
97
-     * @throws EE_Error
98
-     * @throws InvalidDataTypeException
99
-     * @throws InvalidInterfaceException
100
-     * @throws UnexpectedEntityException
101
-     * @throws UserError
102
-     * @throws InvalidArgumentException
103
-     * @throws ReflectionException
104
-     * @since 5.0.0.p
105
-     */
106
-    public function resolveFromPayload($payload, array $args, AppContext $context);
27
+	/**
28
+	 * @return string
29
+	 */
30
+	public function name(): string;
31
+
32
+
33
+	/**
34
+	 * @return string
35
+	 */
36
+	public function description(): string;
37
+
38
+
39
+	/**
40
+	 * @return GraphQLFieldInterface[]
41
+	 * @since 5.0.0.p
42
+	 */
43
+	public function fields(): array;
44
+
45
+	/**
46
+	 * @return GraphQLInterfaceInterface
47
+	 */
48
+	public function interfaces(): array;
49
+
50
+
51
+	/**
52
+	 * Creates a key map for internal resolver.
53
+	 *
54
+	 * @return array
55
+	 * @since 5.0.0.p
56
+	 */
57
+	public function getFieldsForResolver(): array;
58
+
59
+
60
+	/**
61
+	 * @return bool
62
+	 */
63
+	public function isCustomPostType(): bool;
64
+
65
+
66
+	/**
67
+	 * @param int|float $value
68
+	 * @return int
69
+	 * @since 5.0.0.p
70
+	 */
71
+	public function parseInfiniteValue($value): int;
72
+
73
+
74
+	/**
75
+	 * @param mixed       $source  The source that's passed down the GraphQL queries
76
+	 * @param array       $args    The inputArgs on the field
77
+	 * @param AppContext  $context The AppContext passed down the GraphQL tree
78
+	 * @param ResolveInfo $info    The ResolveInfo passed down the GraphQL tree
79
+	 * @return mixed
80
+	 * @throws EE_Error
81
+	 * @throws InvalidDataTypeException
82
+	 * @throws InvalidInterfaceException
83
+	 * @throws UnexpectedEntityException
84
+	 * @throws UserError
85
+	 * @throws InvalidArgumentException
86
+	 * @throws ReflectionException
87
+	 * @since 5.0.0.p
88
+	 */
89
+	public function resolveField($source, array $args, AppContext $context, ResolveInfo $info);
90
+
91
+
92
+	/**
93
+	 * @param mixed      $payload The payload returned after mutation
94
+	 * @param array      $args    The inputArgs on the field
95
+	 * @param AppContext $context The AppContext passed down the GraphQL tree
96
+	 * @return string|null
97
+	 * @throws EE_Error
98
+	 * @throws InvalidDataTypeException
99
+	 * @throws InvalidInterfaceException
100
+	 * @throws UnexpectedEntityException
101
+	 * @throws UserError
102
+	 * @throws InvalidArgumentException
103
+	 * @throws ReflectionException
104
+	 * @since 5.0.0.p
105
+	 */
106
+	public function resolveFromPayload($payload, array $args, AppContext $context);
107 107
 }
Please login to merge, or discard this patch.