@@ -49,137 +49,137 @@ |
||
49 | 49 | */ |
50 | 50 | class RestApiSpoofer |
51 | 51 | { |
52 | - /** |
|
53 | - * @var WP_REST_Server $wp_rest_server |
|
54 | - */ |
|
55 | - protected $wp_rest_server; |
|
52 | + /** |
|
53 | + * @var WP_REST_Server $wp_rest_server |
|
54 | + */ |
|
55 | + protected $wp_rest_server; |
|
56 | 56 | |
57 | - /** |
|
58 | - * @var Read |
|
59 | - */ |
|
60 | - protected $rest_controller; |
|
57 | + /** |
|
58 | + * @var Read |
|
59 | + */ |
|
60 | + protected $rest_controller; |
|
61 | 61 | |
62 | - /** |
|
63 | - * @var EED_Core_Rest_Api $rest_module |
|
64 | - */ |
|
65 | - protected $rest_module; |
|
62 | + /** |
|
63 | + * @var EED_Core_Rest_Api $rest_module |
|
64 | + */ |
|
65 | + protected $rest_module; |
|
66 | 66 | |
67 | 67 | |
68 | - /** |
|
69 | - * RestApiSpoofer constructor. |
|
70 | - * |
|
71 | - * @param WP_REST_Server $wp_rest_server |
|
72 | - * @param EED_Core_Rest_Api $rest_module |
|
73 | - * @param Read $rest_api |
|
74 | - * @param string $api_version |
|
75 | - */ |
|
76 | - public function __construct( |
|
77 | - WP_REST_Server $wp_rest_server, |
|
78 | - EED_Core_Rest_Api $rest_module, |
|
79 | - Read $rest_api, |
|
80 | - $api_version = '4.8.36' |
|
81 | - ) { |
|
82 | - $this->wp_rest_server = $wp_rest_server; |
|
83 | - $this->rest_module = $rest_module; |
|
84 | - $this->rest_controller = $rest_api; |
|
85 | - $this->rest_controller->setRequestedVersion($api_version); |
|
86 | - $this->setUpRestServer(); |
|
87 | - } |
|
68 | + /** |
|
69 | + * RestApiSpoofer constructor. |
|
70 | + * |
|
71 | + * @param WP_REST_Server $wp_rest_server |
|
72 | + * @param EED_Core_Rest_Api $rest_module |
|
73 | + * @param Read $rest_api |
|
74 | + * @param string $api_version |
|
75 | + */ |
|
76 | + public function __construct( |
|
77 | + WP_REST_Server $wp_rest_server, |
|
78 | + EED_Core_Rest_Api $rest_module, |
|
79 | + Read $rest_api, |
|
80 | + $api_version = '4.8.36' |
|
81 | + ) { |
|
82 | + $this->wp_rest_server = $wp_rest_server; |
|
83 | + $this->rest_module = $rest_module; |
|
84 | + $this->rest_controller = $rest_api; |
|
85 | + $this->rest_controller->setRequestedVersion($api_version); |
|
86 | + $this->setUpRestServer(); |
|
87 | + } |
|
88 | 88 | |
89 | 89 | |
90 | - private function setUpRestServer() |
|
91 | - { |
|
92 | - /* @var WP_REST_Server $wp_rest_server */ |
|
93 | - global $wp_rest_server; |
|
94 | - $wp_rest_server = $this->wp_rest_server; |
|
95 | - EED_Core_Rest_Api::set_hooks_both(); |
|
96 | - do_action('rest_api_init', $this->wp_rest_server); |
|
97 | - } |
|
90 | + private function setUpRestServer() |
|
91 | + { |
|
92 | + /* @var WP_REST_Server $wp_rest_server */ |
|
93 | + global $wp_rest_server; |
|
94 | + $wp_rest_server = $this->wp_rest_server; |
|
95 | + EED_Core_Rest_Api::set_hooks_both(); |
|
96 | + do_action('rest_api_init', $this->wp_rest_server); |
|
97 | + } |
|
98 | 98 | |
99 | - /** |
|
100 | - * @param EEM_Base $model |
|
101 | - * @param array $query_params |
|
102 | - * @param string $include |
|
103 | - * @return array |
|
104 | - * @throws EE_Error |
|
105 | - * @throws InvalidArgumentException |
|
106 | - * @throws InvalidDataTypeException |
|
107 | - * @throws InvalidInterfaceException |
|
108 | - * @throws ModelConfigurationException |
|
109 | - * @throws ReflectionException |
|
110 | - * @throws RestException |
|
111 | - * @throws RestPasswordIncorrectException |
|
112 | - * @throws RestPasswordRequiredException |
|
113 | - * @throws UnexpectedEntityException |
|
114 | - * @throws DomainException |
|
115 | - * @since $VID:$ |
|
116 | - */ |
|
117 | - public function getOneApiResult(EEM_Base $model, array $query_params, $include = '') |
|
118 | - { |
|
119 | - if (! array_key_exists('limit', $query_params)) { |
|
120 | - $query_params['limit'] = 1; |
|
121 | - } |
|
122 | - $result = $this->getApiResults($model, $query_params, $include); |
|
123 | - return is_array($result) && isset($result[0]) ? $result[0] : []; |
|
124 | - } |
|
99 | + /** |
|
100 | + * @param EEM_Base $model |
|
101 | + * @param array $query_params |
|
102 | + * @param string $include |
|
103 | + * @return array |
|
104 | + * @throws EE_Error |
|
105 | + * @throws InvalidArgumentException |
|
106 | + * @throws InvalidDataTypeException |
|
107 | + * @throws InvalidInterfaceException |
|
108 | + * @throws ModelConfigurationException |
|
109 | + * @throws ReflectionException |
|
110 | + * @throws RestException |
|
111 | + * @throws RestPasswordIncorrectException |
|
112 | + * @throws RestPasswordRequiredException |
|
113 | + * @throws UnexpectedEntityException |
|
114 | + * @throws DomainException |
|
115 | + * @since $VID:$ |
|
116 | + */ |
|
117 | + public function getOneApiResult(EEM_Base $model, array $query_params, $include = '') |
|
118 | + { |
|
119 | + if (! array_key_exists('limit', $query_params)) { |
|
120 | + $query_params['limit'] = 1; |
|
121 | + } |
|
122 | + $result = $this->getApiResults($model, $query_params, $include); |
|
123 | + return is_array($result) && isset($result[0]) ? $result[0] : []; |
|
124 | + } |
|
125 | 125 | |
126 | - /** |
|
127 | - * @param EEM_Base $model |
|
128 | - * @param array $query_params |
|
129 | - * @param string $include |
|
130 | - * @return array |
|
131 | - * @throws EE_Error |
|
132 | - * @throws InvalidArgumentException |
|
133 | - * @throws InvalidDataTypeException |
|
134 | - * @throws InvalidInterfaceException |
|
135 | - * @throws ModelConfigurationException |
|
136 | - * @throws ReflectionException |
|
137 | - * @throws RestException |
|
138 | - * @throws RestPasswordIncorrectException |
|
139 | - * @throws RestPasswordRequiredException |
|
140 | - * @throws UnexpectedEntityException |
|
141 | - * @throws DomainException |
|
142 | - * @since $VID:$ |
|
143 | - */ |
|
144 | - public function getApiResults(EEM_Base $model, array $query_params, $include = '') |
|
145 | - { |
|
146 | - if (! array_key_exists('caps', $query_params)) { |
|
147 | - $query_params['caps'] = EEM_Base::caps_read_admin; |
|
148 | - } |
|
149 | - if (! array_key_exists('default_where_conditions', $query_params)) { |
|
150 | - $query_params['default_where_conditions'] = 'none'; |
|
151 | - } |
|
152 | - /** @type array $results */ |
|
153 | - $results = $model->get_all_wpdb_results($query_params); |
|
154 | - $rest_request = new WP_REST_Request(); |
|
155 | - $rest_request->set_param('include', $include); |
|
156 | - $rest_request->set_param('caps', 'edit'); |
|
157 | - $nice_results = array(); |
|
158 | - foreach ($results as $result) { |
|
159 | - $nice_results[] = $this->rest_controller->createEntityFromWpdbResult( |
|
160 | - $model, |
|
161 | - $result, |
|
162 | - $rest_request |
|
163 | - ); |
|
164 | - } |
|
165 | - return $nice_results; |
|
166 | - } |
|
126 | + /** |
|
127 | + * @param EEM_Base $model |
|
128 | + * @param array $query_params |
|
129 | + * @param string $include |
|
130 | + * @return array |
|
131 | + * @throws EE_Error |
|
132 | + * @throws InvalidArgumentException |
|
133 | + * @throws InvalidDataTypeException |
|
134 | + * @throws InvalidInterfaceException |
|
135 | + * @throws ModelConfigurationException |
|
136 | + * @throws ReflectionException |
|
137 | + * @throws RestException |
|
138 | + * @throws RestPasswordIncorrectException |
|
139 | + * @throws RestPasswordRequiredException |
|
140 | + * @throws UnexpectedEntityException |
|
141 | + * @throws DomainException |
|
142 | + * @since $VID:$ |
|
143 | + */ |
|
144 | + public function getApiResults(EEM_Base $model, array $query_params, $include = '') |
|
145 | + { |
|
146 | + if (! array_key_exists('caps', $query_params)) { |
|
147 | + $query_params['caps'] = EEM_Base::caps_read_admin; |
|
148 | + } |
|
149 | + if (! array_key_exists('default_where_conditions', $query_params)) { |
|
150 | + $query_params['default_where_conditions'] = 'none'; |
|
151 | + } |
|
152 | + /** @type array $results */ |
|
153 | + $results = $model->get_all_wpdb_results($query_params); |
|
154 | + $rest_request = new WP_REST_Request(); |
|
155 | + $rest_request->set_param('include', $include); |
|
156 | + $rest_request->set_param('caps', 'edit'); |
|
157 | + $nice_results = array(); |
|
158 | + foreach ($results as $result) { |
|
159 | + $nice_results[] = $this->rest_controller->createEntityFromWpdbResult( |
|
160 | + $model, |
|
161 | + $result, |
|
162 | + $rest_request |
|
163 | + ); |
|
164 | + } |
|
165 | + return $nice_results; |
|
166 | + } |
|
167 | 167 | |
168 | 168 | |
169 | - /** |
|
170 | - * @param string $endpoint |
|
171 | - * @return array |
|
172 | - * @throws EE_Error |
|
173 | - * @since $VID:$ |
|
174 | - */ |
|
175 | - public function getModelSchema($endpoint) |
|
176 | - { |
|
177 | - $response = $this->wp_rest_server->dispatch( |
|
178 | - new WP_REST_Request( |
|
179 | - 'OPTIONS', |
|
180 | - "/ee/v4.8.36/{$endpoint}" |
|
181 | - ) |
|
182 | - ); |
|
183 | - return $response->get_data(); |
|
184 | - } |
|
169 | + /** |
|
170 | + * @param string $endpoint |
|
171 | + * @return array |
|
172 | + * @throws EE_Error |
|
173 | + * @since $VID:$ |
|
174 | + */ |
|
175 | + public function getModelSchema($endpoint) |
|
176 | + { |
|
177 | + $response = $this->wp_rest_server->dispatch( |
|
178 | + new WP_REST_Request( |
|
179 | + 'OPTIONS', |
|
180 | + "/ee/v4.8.36/{$endpoint}" |
|
181 | + ) |
|
182 | + ); |
|
183 | + return $response->get_data(); |
|
184 | + } |
|
185 | 185 | } |
@@ -14,80 +14,80 @@ |
||
14 | 14 | */ |
15 | 15 | interface DomainInterface extends InterminableInterface |
16 | 16 | { |
17 | - /** |
|
18 | - * @param string $asset_namespace |
|
19 | - * @return void |
|
20 | - * @since $VID:$ |
|
21 | - */ |
|
22 | - public function initialize($asset_namespace = 'eventespresso'); |
|
17 | + /** |
|
18 | + * @param string $asset_namespace |
|
19 | + * @return void |
|
20 | + * @since $VID:$ |
|
21 | + */ |
|
22 | + public function initialize($asset_namespace = 'eventespresso'); |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * @param string $asset_namespace |
|
27 | - * @return void |
|
28 | - */ |
|
29 | - public function setAssetNamespace($asset_namespace = 'eventespresso'); |
|
25 | + /** |
|
26 | + * @param string $asset_namespace |
|
27 | + * @return void |
|
28 | + */ |
|
29 | + public function setAssetNamespace($asset_namespace = 'eventespresso'); |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - public function pluginFile(); |
|
32 | + /** |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + public function pluginFile(); |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * @return string |
|
40 | - */ |
|
41 | - public function pluginBasename(); |
|
38 | + /** |
|
39 | + * @return string |
|
40 | + */ |
|
41 | + public function pluginBasename(); |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * @param string $additional_path |
|
46 | - * @return string |
|
47 | - */ |
|
48 | - public function pluginPath($additional_path = ''); |
|
44 | + /** |
|
45 | + * @param string $additional_path |
|
46 | + * @return string |
|
47 | + */ |
|
48 | + public function pluginPath($additional_path = ''); |
|
49 | 49 | |
50 | 50 | |
51 | - /** |
|
52 | - * @return string |
|
53 | - */ |
|
54 | - public function pluginUrl(); |
|
51 | + /** |
|
52 | + * @return string |
|
53 | + */ |
|
54 | + public function pluginUrl(); |
|
55 | 55 | |
56 | 56 | |
57 | - /** |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - public function version(); |
|
57 | + /** |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + public function version(); |
|
61 | 61 | |
62 | 62 | |
63 | - /** |
|
64 | - * @return Version |
|
65 | - */ |
|
66 | - public function versionValueObject(); |
|
63 | + /** |
|
64 | + * @return Version |
|
65 | + */ |
|
66 | + public function versionValueObject(); |
|
67 | 67 | |
68 | 68 | |
69 | - /** |
|
70 | - * @return string |
|
71 | - */ |
|
72 | - public function distributionAssetsFolder(); |
|
69 | + /** |
|
70 | + * @return string |
|
71 | + */ |
|
72 | + public function distributionAssetsFolder(); |
|
73 | 73 | |
74 | 74 | |
75 | - /** |
|
76 | - * @param string $additional_path |
|
77 | - * @return string |
|
78 | - */ |
|
79 | - public function distributionAssetsPath($additional_path = ''); |
|
75 | + /** |
|
76 | + * @param string $additional_path |
|
77 | + * @return string |
|
78 | + */ |
|
79 | + public function distributionAssetsPath($additional_path = ''); |
|
80 | 80 | |
81 | 81 | |
82 | - /** |
|
83 | - * @param string $additional_path |
|
84 | - * @return string |
|
85 | - */ |
|
86 | - public function distributionAssetsUrl($additional_path = ''); |
|
82 | + /** |
|
83 | + * @param string $additional_path |
|
84 | + * @return string |
|
85 | + */ |
|
86 | + public function distributionAssetsUrl($additional_path = ''); |
|
87 | 87 | |
88 | 88 | |
89 | - /** |
|
90 | - * @return string |
|
91 | - */ |
|
92 | - public function assetNamespace(); |
|
89 | + /** |
|
90 | + * @return string |
|
91 | + */ |
|
92 | + public function assetNamespace(); |
|
93 | 93 | } |
@@ -17,110 +17,110 @@ |
||
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 $VID:$ |
|
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 $VID:$ |
|
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 $VID:$ |
|
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 $VID:$ |
|
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 $VID:$ |
|
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 | - $type->extendMutations(); |
|
88 | - } |
|
89 | - } |
|
65 | + /** |
|
66 | + * @param TypeInterface $type |
|
67 | + * @since $VID:$ |
|
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 | + $type->extendMutations(); |
|
88 | + } |
|
89 | + } |
|
90 | 90 | |
91 | 91 | |
92 | - /** |
|
93 | - * @param TypeInterface $type |
|
94 | - * @since $VID:$ |
|
95 | - */ |
|
96 | - public function registerType(TypeInterface $type) |
|
97 | - { |
|
98 | - $outputFields = []; |
|
99 | - $inputFields = []; |
|
100 | - foreach ($type->fields() as $field) { |
|
101 | - $fieldName = $field->name(); |
|
102 | - $config = $field->toArray(); |
|
103 | - if ($field->useForInput()) { |
|
104 | - $inputFields[ $fieldName ] = $config; |
|
105 | - } |
|
106 | - if ($field->useForOutput()) { |
|
107 | - $config['resolve'] = [$type, 'resolveField']; |
|
108 | - $outputFields[ $fieldName ] = $config; |
|
109 | - } |
|
110 | - } |
|
111 | - $typeName = $type->name(); |
|
112 | - if (! empty($outputFields)) { |
|
113 | - // Register the object type. |
|
114 | - register_graphql_object_type( |
|
115 | - $typeName, |
|
116 | - [ |
|
117 | - 'description' => $type->description(), |
|
118 | - 'fields' => $outputFields, |
|
119 | - ] |
|
120 | - ); |
|
121 | - } |
|
122 | - if (is_callable([$type, 'registerMutations'])) { |
|
123 | - $type->registerMutations($inputFields); |
|
124 | - } |
|
125 | - } |
|
92 | + /** |
|
93 | + * @param TypeInterface $type |
|
94 | + * @since $VID:$ |
|
95 | + */ |
|
96 | + public function registerType(TypeInterface $type) |
|
97 | + { |
|
98 | + $outputFields = []; |
|
99 | + $inputFields = []; |
|
100 | + foreach ($type->fields() as $field) { |
|
101 | + $fieldName = $field->name(); |
|
102 | + $config = $field->toArray(); |
|
103 | + if ($field->useForInput()) { |
|
104 | + $inputFields[ $fieldName ] = $config; |
|
105 | + } |
|
106 | + if ($field->useForOutput()) { |
|
107 | + $config['resolve'] = [$type, 'resolveField']; |
|
108 | + $outputFields[ $fieldName ] = $config; |
|
109 | + } |
|
110 | + } |
|
111 | + $typeName = $type->name(); |
|
112 | + if (! empty($outputFields)) { |
|
113 | + // Register the object type. |
|
114 | + register_graphql_object_type( |
|
115 | + $typeName, |
|
116 | + [ |
|
117 | + 'description' => $type->description(), |
|
118 | + 'fields' => $outputFields, |
|
119 | + ] |
|
120 | + ); |
|
121 | + } |
|
122 | + if (is_callable([$type, 'registerMutations'])) { |
|
123 | + $type->registerMutations($inputFields); |
|
124 | + } |
|
125 | + } |
|
126 | 126 | } |
@@ -17,31 +17,31 @@ |
||
17 | 17 | */ |
18 | 18 | class DataLoaderManager implements GQLManagerInterface |
19 | 19 | { |
20 | - /** |
|
21 | - * @var DataLoaderCollection|GQLDataDomainInterface[] $data_loaders |
|
22 | - */ |
|
23 | - private $data_loaders; |
|
20 | + /** |
|
21 | + * @var DataLoaderCollection|GQLDataDomainInterface[] $data_loaders |
|
22 | + */ |
|
23 | + private $data_loaders; |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * @param DataLoaderCollection|GQLDataDomainInterface[] $data_loaders |
|
28 | - */ |
|
29 | - public function __construct(DataLoaderCollection $data_loaders) |
|
30 | - { |
|
31 | - $this->data_loaders = $data_loaders; |
|
32 | - } |
|
26 | + /** |
|
27 | + * @param DataLoaderCollection|GQLDataDomainInterface[] $data_loaders |
|
28 | + */ |
|
29 | + public function __construct(DataLoaderCollection $data_loaders) |
|
30 | + { |
|
31 | + $this->data_loaders = $data_loaders; |
|
32 | + } |
|
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * @throws CollectionDetailsException |
|
37 | - * @throws CollectionLoaderException |
|
38 | - * @since $VID:$ |
|
39 | - */ |
|
40 | - public function init() |
|
41 | - { |
|
42 | - $data_loaders = $this->data_loaders->getDataLoaders(); |
|
43 | - foreach ($data_loaders as $data_loader) { |
|
44 | - add_filter('graphql_data_loaders', [$data_loader, 'registerLoaders'], 10, 2); |
|
45 | - } |
|
46 | - } |
|
35 | + /** |
|
36 | + * @throws CollectionDetailsException |
|
37 | + * @throws CollectionLoaderException |
|
38 | + * @since $VID:$ |
|
39 | + */ |
|
40 | + public function init() |
|
41 | + { |
|
42 | + $data_loaders = $this->data_loaders->getDataLoaders(); |
|
43 | + foreach ($data_loaders as $data_loader) { |
|
44 | + add_filter('graphql_data_loaders', [$data_loader, 'registerLoaders'], 10, 2); |
|
45 | + } |
|
46 | + } |
|
47 | 47 | } |
@@ -20,72 +20,72 @@ |
||
20 | 20 | */ |
21 | 21 | class DataLoaderCollection extends Collection |
22 | 22 | { |
23 | - const COLLECTION_NAME = 'espresso_graphql_data_loaders'; |
|
23 | + const COLLECTION_NAME = 'espresso_graphql_data_loaders'; |
|
24 | 24 | |
25 | - const COLLECTION_INTERFACE = 'EventEspresso\core\services\graphql\loaders\GQLDataDomainInterface'; |
|
25 | + const COLLECTION_INTERFACE = 'EventEspresso\core\services\graphql\loaders\GQLDataDomainInterface'; |
|
26 | 26 | |
27 | - /** |
|
28 | - * @var CollectionLoader $loader |
|
29 | - */ |
|
30 | - protected $loader; |
|
27 | + /** |
|
28 | + * @var CollectionLoader $loader |
|
29 | + */ |
|
30 | + protected $loader; |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * DataLoaderCollection constructor |
|
35 | - * |
|
36 | - * @throws InvalidInterfaceException |
|
37 | - */ |
|
38 | - public function __construct() |
|
39 | - { |
|
40 | - parent::__construct( |
|
41 | - DataLoaderCollection::COLLECTION_INTERFACE, |
|
42 | - DataLoaderCollection::COLLECTION_NAME |
|
43 | - ); |
|
44 | - } |
|
33 | + /** |
|
34 | + * DataLoaderCollection constructor |
|
35 | + * |
|
36 | + * @throws InvalidInterfaceException |
|
37 | + */ |
|
38 | + public function __construct() |
|
39 | + { |
|
40 | + parent::__construct( |
|
41 | + DataLoaderCollection::COLLECTION_INTERFACE, |
|
42 | + DataLoaderCollection::COLLECTION_NAME |
|
43 | + ); |
|
44 | + } |
|
45 | 45 | |
46 | 46 | |
47 | - /** |
|
48 | - * @throws CollectionDetailsException |
|
49 | - * @throws CollectionLoaderException |
|
50 | - * @since $VID:$ |
|
51 | - */ |
|
52 | - private function loadCollection() |
|
53 | - { |
|
54 | - if (! $this->loader instanceof CollectionLoader) { |
|
55 | - $this->loader = new CollectionLoader( |
|
56 | - new CollectionDetails( |
|
57 | - // collection name |
|
58 | - DataLoaderCollection::COLLECTION_NAME, |
|
59 | - // collection interface |
|
60 | - DataLoaderCollection::COLLECTION_INTERFACE, |
|
61 | - // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
62 | - apply_filters( |
|
63 | - 'FHEE__EventEspresso_core_services_graphql_DataLoaderCollection__loadCollection__collection_FQCNs', |
|
64 | - ['EventEspresso\core\domain\services\graphql\data\domains'] |
|
65 | - ), |
|
66 | - // filepaths to classes to add |
|
67 | - array(), |
|
68 | - // file mask to use if parsing folder for files to add |
|
69 | - '', |
|
70 | - // what to use as identifier for collection entities |
|
71 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
72 | - CollectionDetails::ID_CLASS_NAME |
|
73 | - ), |
|
74 | - $this |
|
75 | - ); |
|
76 | - } |
|
77 | - } |
|
47 | + /** |
|
48 | + * @throws CollectionDetailsException |
|
49 | + * @throws CollectionLoaderException |
|
50 | + * @since $VID:$ |
|
51 | + */ |
|
52 | + private function loadCollection() |
|
53 | + { |
|
54 | + if (! $this->loader instanceof CollectionLoader) { |
|
55 | + $this->loader = new CollectionLoader( |
|
56 | + new CollectionDetails( |
|
57 | + // collection name |
|
58 | + DataLoaderCollection::COLLECTION_NAME, |
|
59 | + // collection interface |
|
60 | + DataLoaderCollection::COLLECTION_INTERFACE, |
|
61 | + // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
62 | + apply_filters( |
|
63 | + 'FHEE__EventEspresso_core_services_graphql_DataLoaderCollection__loadCollection__collection_FQCNs', |
|
64 | + ['EventEspresso\core\domain\services\graphql\data\domains'] |
|
65 | + ), |
|
66 | + // filepaths to classes to add |
|
67 | + array(), |
|
68 | + // file mask to use if parsing folder for files to add |
|
69 | + '', |
|
70 | + // what to use as identifier for collection entities |
|
71 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
72 | + CollectionDetails::ID_CLASS_NAME |
|
73 | + ), |
|
74 | + $this |
|
75 | + ); |
|
76 | + } |
|
77 | + } |
|
78 | 78 | |
79 | 79 | |
80 | - /** |
|
81 | - * @return CollectionInterface |
|
82 | - * @throws CollectionDetailsException |
|
83 | - * @throws CollectionLoaderException |
|
84 | - * @since $VID:$ |
|
85 | - */ |
|
86 | - public function getDataLoaders() |
|
87 | - { |
|
88 | - $this->loadCollection(); |
|
89 | - return $this->loader->getCollection(); |
|
90 | - } |
|
80 | + /** |
|
81 | + * @return CollectionInterface |
|
82 | + * @throws CollectionDetailsException |
|
83 | + * @throws CollectionLoaderException |
|
84 | + * @since $VID:$ |
|
85 | + */ |
|
86 | + public function getDataLoaders() |
|
87 | + { |
|
88 | + $this->loadCollection(); |
|
89 | + return $this->loader->getCollection(); |
|
90 | + } |
|
91 | 91 | } |
@@ -14,12 +14,12 @@ |
||
14 | 14 | */ |
15 | 15 | interface GQLDataDomainInterface |
16 | 16 | { |
17 | - /** |
|
18 | - * @param array $loaders The loaders accessible in the AppContext |
|
19 | - * @param AppContext $context The AppContext |
|
20 | - * @return array |
|
21 | - * @return array |
|
22 | - * @since $VID:$ |
|
23 | - */ |
|
24 | - public function registerLoaders(array $loaders, AppContext $context): array; |
|
17 | + /** |
|
18 | + * @param array $loaders The loaders accessible in the AppContext |
|
19 | + * @param AppContext $context The AppContext |
|
20 | + * @return array |
|
21 | + * @return array |
|
22 | + * @since $VID:$ |
|
23 | + */ |
|
24 | + public function registerLoaders(array $loaders, AppContext $context): array; |
|
25 | 25 | } |
@@ -14,19 +14,19 @@ |
||
14 | 14 | */ |
15 | 15 | interface ConnectionInterface |
16 | 16 | { |
17 | - /** |
|
18 | - * @return array |
|
19 | - * @since $VID:$ |
|
20 | - */ |
|
21 | - public function config(); |
|
17 | + /** |
|
18 | + * @return array |
|
19 | + * @since $VID:$ |
|
20 | + */ |
|
21 | + public function config(); |
|
22 | 22 | |
23 | - /** |
|
24 | - * @param $entity |
|
25 | - * @param $args |
|
26 | - * @param $context |
|
27 | - * @param $info |
|
28 | - * @return array |
|
29 | - * @since $VID:$ |
|
30 | - */ |
|
31 | - public function resolveConnection($entity, $args, $context, $info); |
|
23 | + /** |
|
24 | + * @param $entity |
|
25 | + * @param $args |
|
26 | + * @param $context |
|
27 | + * @param $info |
|
28 | + * @return array |
|
29 | + * @since $VID:$ |
|
30 | + */ |
|
31 | + public function resolveConnection($entity, $args, $context, $info); |
|
32 | 32 | } |
@@ -20,86 +20,86 @@ |
||
20 | 20 | */ |
21 | 21 | class ConnectionCollection extends Collection |
22 | 22 | { |
23 | - const COLLECTION_NAME = 'espresso_graphql_connections'; |
|
23 | + const COLLECTION_NAME = 'espresso_graphql_connections'; |
|
24 | 24 | |
25 | - /** |
|
26 | - * @var CollectionLoader $loader |
|
27 | - */ |
|
28 | - protected $loader; |
|
25 | + /** |
|
26 | + * @var CollectionLoader $loader |
|
27 | + */ |
|
28 | + protected $loader; |
|
29 | 29 | |
30 | - /** |
|
31 | - * ConnectionCollection constructor |
|
32 | - * |
|
33 | - * @throws InvalidInterfaceException |
|
34 | - */ |
|
35 | - public function __construct() |
|
36 | - { |
|
37 | - parent::__construct( |
|
38 | - 'EventEspresso\core\services\graphql\connections\ConnectionInterface', |
|
39 | - ConnectionCollection::COLLECTION_NAME |
|
40 | - ); |
|
41 | - } |
|
30 | + /** |
|
31 | + * ConnectionCollection constructor |
|
32 | + * |
|
33 | + * @throws InvalidInterfaceException |
|
34 | + */ |
|
35 | + public function __construct() |
|
36 | + { |
|
37 | + parent::__construct( |
|
38 | + 'EventEspresso\core\services\graphql\connections\ConnectionInterface', |
|
39 | + ConnectionCollection::COLLECTION_NAME |
|
40 | + ); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * @throws CollectionDetailsException |
|
46 | - * @throws CollectionLoaderException |
|
47 | - * @since $VID:$ |
|
48 | - */ |
|
49 | - private function loadCollection() |
|
50 | - { |
|
51 | - if (! $this->loader instanceof CollectionLoader) { |
|
52 | - $this->loader = new CollectionLoader( |
|
53 | - new CollectionDetails( |
|
54 | - // collection name |
|
55 | - ConnectionCollection::COLLECTION_NAME, |
|
56 | - // collection interface |
|
57 | - 'EventEspresso\core\services\graphql\connections\ConnectionInterface', |
|
58 | - // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
59 | - apply_filters( |
|
60 | - 'FHEE__EventEspresso_core_services_graphql_ConnectionCollection__loadCollection__collection_FQCNs', |
|
61 | - ['EventEspresso\core\domain\services\graphql\connections'] |
|
62 | - ), |
|
63 | - // filepaths to classes to add |
|
64 | - array(), |
|
65 | - // file mask to use if parsing folder for files to add |
|
66 | - '', |
|
67 | - // what to use as identifier for collection entities |
|
68 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
69 | - CollectionDetails::ID_CLASS_NAME |
|
70 | - ), |
|
71 | - $this |
|
72 | - ); |
|
73 | - } |
|
74 | - } |
|
44 | + /** |
|
45 | + * @throws CollectionDetailsException |
|
46 | + * @throws CollectionLoaderException |
|
47 | + * @since $VID:$ |
|
48 | + */ |
|
49 | + private function loadCollection() |
|
50 | + { |
|
51 | + if (! $this->loader instanceof CollectionLoader) { |
|
52 | + $this->loader = new CollectionLoader( |
|
53 | + new CollectionDetails( |
|
54 | + // collection name |
|
55 | + ConnectionCollection::COLLECTION_NAME, |
|
56 | + // collection interface |
|
57 | + 'EventEspresso\core\services\graphql\connections\ConnectionInterface', |
|
58 | + // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
59 | + apply_filters( |
|
60 | + 'FHEE__EventEspresso_core_services_graphql_ConnectionCollection__loadCollection__collection_FQCNs', |
|
61 | + ['EventEspresso\core\domain\services\graphql\connections'] |
|
62 | + ), |
|
63 | + // filepaths to classes to add |
|
64 | + array(), |
|
65 | + // file mask to use if parsing folder for files to add |
|
66 | + '', |
|
67 | + // what to use as identifier for collection entities |
|
68 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
69 | + CollectionDetails::ID_CLASS_NAME |
|
70 | + ), |
|
71 | + $this |
|
72 | + ); |
|
73 | + } |
|
74 | + } |
|
75 | 75 | |
76 | 76 | |
77 | - /** |
|
78 | - * @return CollectionInterface |
|
79 | - * @throws CollectionDetailsException |
|
80 | - * @throws CollectionLoaderException |
|
81 | - * @since $VID:$ |
|
82 | - */ |
|
83 | - public function loadConnections() |
|
84 | - { |
|
85 | - $this->loadCollection(); |
|
86 | - return $this->loader->getCollection(); |
|
87 | - } |
|
77 | + /** |
|
78 | + * @return CollectionInterface |
|
79 | + * @throws CollectionDetailsException |
|
80 | + * @throws CollectionLoaderException |
|
81 | + * @since $VID:$ |
|
82 | + */ |
|
83 | + public function loadConnections() |
|
84 | + { |
|
85 | + $this->loadCollection(); |
|
86 | + return $this->loader->getCollection(); |
|
87 | + } |
|
88 | 88 | |
89 | 89 | |
90 | - /** |
|
91 | - * getIdentifier |
|
92 | - * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
93 | - * If no $identifier is supplied, then the fully qualified class name is used |
|
94 | - * |
|
95 | - * @param $object |
|
96 | - * @param mixed $identifier |
|
97 | - * @return bool |
|
98 | - */ |
|
99 | - public function getIdentifier($object, $identifier = null) |
|
100 | - { |
|
101 | - return ! empty($identifier) |
|
102 | - ? $identifier |
|
103 | - : get_class($object); |
|
104 | - } |
|
90 | + /** |
|
91 | + * getIdentifier |
|
92 | + * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
93 | + * If no $identifier is supplied, then the fully qualified class name is used |
|
94 | + * |
|
95 | + * @param $object |
|
96 | + * @param mixed $identifier |
|
97 | + * @return bool |
|
98 | + */ |
|
99 | + public function getIdentifier($object, $identifier = null) |
|
100 | + { |
|
101 | + return ! empty($identifier) |
|
102 | + ? $identifier |
|
103 | + : get_class($object); |
|
104 | + } |
|
105 | 105 | } |
@@ -15,76 +15,76 @@ |
||
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 boolean $initialized |
|
45 | - */ |
|
46 | - private $initialized = false; |
|
43 | + /** |
|
44 | + * @var boolean $initialized |
|
45 | + */ |
|
46 | + private $initialized = false; |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * GraphQLManager constructor. |
|
51 | - * |
|
52 | - * @param ConnectionsManager $connections_manager |
|
53 | - * @param DataLoaderManager $data_loader_manager |
|
54 | - * @param EnumsManager $enums_manager |
|
55 | - * @param InputsManager $inputs_manager |
|
56 | - * @param TypesManager $types_manager |
|
57 | - */ |
|
58 | - public function __construct( |
|
59 | - ConnectionsManager $connections_manager, |
|
60 | - DataLoaderManager $data_loader_manager, |
|
61 | - EnumsManager $enums_manager, |
|
62 | - InputsManager $inputs_manager, |
|
63 | - TypesManager $types_manager |
|
64 | - ) { |
|
65 | - $this->connections_manager = $connections_manager; |
|
66 | - $this->data_loader_manager = $data_loader_manager; |
|
67 | - $this->enums_manager = $enums_manager; |
|
68 | - $this->inputs_manager = $inputs_manager; |
|
69 | - $this->types_manager = $types_manager; |
|
70 | - } |
|
49 | + /** |
|
50 | + * GraphQLManager constructor. |
|
51 | + * |
|
52 | + * @param ConnectionsManager $connections_manager |
|
53 | + * @param DataLoaderManager $data_loader_manager |
|
54 | + * @param EnumsManager $enums_manager |
|
55 | + * @param InputsManager $inputs_manager |
|
56 | + * @param TypesManager $types_manager |
|
57 | + */ |
|
58 | + public function __construct( |
|
59 | + ConnectionsManager $connections_manager, |
|
60 | + DataLoaderManager $data_loader_manager, |
|
61 | + EnumsManager $enums_manager, |
|
62 | + InputsManager $inputs_manager, |
|
63 | + TypesManager $types_manager |
|
64 | + ) { |
|
65 | + $this->connections_manager = $connections_manager; |
|
66 | + $this->data_loader_manager = $data_loader_manager; |
|
67 | + $this->enums_manager = $enums_manager; |
|
68 | + $this->inputs_manager = $inputs_manager; |
|
69 | + $this->types_manager = $types_manager; |
|
70 | + } |
|
71 | 71 | |
72 | 72 | |
73 | - /** |
|
74 | - * @throws CollectionDetailsException |
|
75 | - * @throws CollectionLoaderException |
|
76 | - * @since $VID:$ |
|
77 | - */ |
|
78 | - public function init() |
|
79 | - { |
|
80 | - if ($this->initialized) { |
|
81 | - return; |
|
82 | - } |
|
83 | - $this->connections_manager->init(); |
|
84 | - $this->data_loader_manager->init(); |
|
85 | - $this->enums_manager->init(); |
|
86 | - $this->inputs_manager->init(); |
|
87 | - $this->types_manager->init(); |
|
88 | - $this->initialized = true; |
|
89 | - } |
|
73 | + /** |
|
74 | + * @throws CollectionDetailsException |
|
75 | + * @throws CollectionLoaderException |
|
76 | + * @since $VID:$ |
|
77 | + */ |
|
78 | + public function init() |
|
79 | + { |
|
80 | + if ($this->initialized) { |
|
81 | + return; |
|
82 | + } |
|
83 | + $this->connections_manager->init(); |
|
84 | + $this->data_loader_manager->init(); |
|
85 | + $this->enums_manager->init(); |
|
86 | + $this->inputs_manager->init(); |
|
87 | + $this->types_manager->init(); |
|
88 | + $this->initialized = true; |
|
89 | + } |
|
90 | 90 | } |