@@ -14,21 +14,21 @@ |
||
14 | 14 | */ |
15 | 15 | interface InputInterface |
16 | 16 | { |
17 | - /** |
|
18 | - * @return string |
|
19 | - */ |
|
20 | - public function name(); |
|
17 | + /** |
|
18 | + * @return string |
|
19 | + */ |
|
20 | + public function name(); |
|
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * @return string |
|
25 | - */ |
|
26 | - public function description(); |
|
23 | + /** |
|
24 | + * @return string |
|
25 | + */ |
|
26 | + public function description(); |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * @return \EventEspresso\core\services\graphql\fields\GraphQLFieldInterface[] |
|
31 | - * @since 5.0.0.p |
|
32 | - */ |
|
33 | - public function fields(); |
|
29 | + /** |
|
30 | + * @return \EventEspresso\core\services\graphql\fields\GraphQLFieldInterface[] |
|
31 | + * @since 5.0.0.p |
|
32 | + */ |
|
33 | + public function fields(); |
|
34 | 34 | } |
@@ -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 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 | - $type->extendMutations(); |
|
88 | - } |
|
89 | - } |
|
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 | + $type->extendMutations(); |
|
88 | + } |
|
89 | + } |
|
90 | 90 | |
91 | 91 | |
92 | - /** |
|
93 | - * @param TypeInterface $type |
|
94 | - * @since 5.0.0.p |
|
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 5.0.0.p |
|
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 | } |
@@ -14,19 +14,19 @@ |
||
14 | 14 | */ |
15 | 15 | interface ConnectionInterface |
16 | 16 | { |
17 | - /** |
|
18 | - * @return array |
|
19 | - * @since 5.0.0.p |
|
20 | - */ |
|
21 | - public function config(); |
|
17 | + /** |
|
18 | + * @return array |
|
19 | + * @since 5.0.0.p |
|
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 5.0.0.p |
|
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 5.0.0.p |
|
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 5.0.0.p |
|
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 5.0.0.p |
|
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 5.0.0.p |
|
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 5.0.0.p |
|
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 | } |
@@ -20,86 +20,86 @@ |
||
20 | 20 | */ |
21 | 21 | class EnumCollection extends Collection |
22 | 22 | { |
23 | - const COLLECTION_NAME = 'espresso_graphql_enums'; |
|
23 | + const COLLECTION_NAME = 'espresso_graphql_enums'; |
|
24 | 24 | |
25 | - /** |
|
26 | - * @var CollectionLoader $loader |
|
27 | - */ |
|
28 | - protected $loader; |
|
25 | + /** |
|
26 | + * @var CollectionLoader $loader |
|
27 | + */ |
|
28 | + protected $loader; |
|
29 | 29 | |
30 | - /** |
|
31 | - * EnumCollection constructor |
|
32 | - * |
|
33 | - * @throws InvalidInterfaceException |
|
34 | - */ |
|
35 | - public function __construct() |
|
36 | - { |
|
37 | - parent::__construct( |
|
38 | - 'EventEspresso\core\services\graphql\enums\EnumInterface', |
|
39 | - EnumCollection::COLLECTION_NAME |
|
40 | - ); |
|
41 | - } |
|
30 | + /** |
|
31 | + * EnumCollection constructor |
|
32 | + * |
|
33 | + * @throws InvalidInterfaceException |
|
34 | + */ |
|
35 | + public function __construct() |
|
36 | + { |
|
37 | + parent::__construct( |
|
38 | + 'EventEspresso\core\services\graphql\enums\EnumInterface', |
|
39 | + EnumCollection::COLLECTION_NAME |
|
40 | + ); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * @throws CollectionDetailsException |
|
46 | - * @throws CollectionLoaderException |
|
47 | - * @since 5.0.0.p |
|
48 | - */ |
|
49 | - private function loadCollection() |
|
50 | - { |
|
51 | - if (! $this->loader instanceof CollectionLoader) { |
|
52 | - $this->loader = new CollectionLoader( |
|
53 | - new CollectionDetails( |
|
54 | - // collection name |
|
55 | - EnumCollection::COLLECTION_NAME, |
|
56 | - // collection interface |
|
57 | - 'EventEspresso\core\services\graphql\enums\EnumInterface', |
|
58 | - // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
59 | - apply_filters( |
|
60 | - 'FHEE__EventEspresso_core_services_graphql_EnumCollection__loadCollection__collection_FQCNs', |
|
61 | - ['EventEspresso\core\domain\services\graphql\enums'] |
|
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 5.0.0.p |
|
48 | + */ |
|
49 | + private function loadCollection() |
|
50 | + { |
|
51 | + if (! $this->loader instanceof CollectionLoader) { |
|
52 | + $this->loader = new CollectionLoader( |
|
53 | + new CollectionDetails( |
|
54 | + // collection name |
|
55 | + EnumCollection::COLLECTION_NAME, |
|
56 | + // collection interface |
|
57 | + 'EventEspresso\core\services\graphql\enums\EnumInterface', |
|
58 | + // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
59 | + apply_filters( |
|
60 | + 'FHEE__EventEspresso_core_services_graphql_EnumCollection__loadCollection__collection_FQCNs', |
|
61 | + ['EventEspresso\core\domain\services\graphql\enums'] |
|
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 5.0.0.p |
|
82 | - */ |
|
83 | - public function loadEnums() |
|
84 | - { |
|
85 | - $this->loadCollection(); |
|
86 | - return $this->loader->getCollection(); |
|
87 | - } |
|
77 | + /** |
|
78 | + * @return CollectionInterface |
|
79 | + * @throws CollectionDetailsException |
|
80 | + * @throws CollectionLoaderException |
|
81 | + * @since 5.0.0.p |
|
82 | + */ |
|
83 | + public function loadEnums() |
|
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 | } |
@@ -12,21 +12,21 @@ |
||
12 | 12 | */ |
13 | 13 | interface EnumInterface |
14 | 14 | { |
15 | - /** |
|
16 | - * @return string |
|
17 | - */ |
|
18 | - public function name(); |
|
15 | + /** |
|
16 | + * @return string |
|
17 | + */ |
|
18 | + public function name(); |
|
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * @return string |
|
23 | - */ |
|
24 | - public function description(); |
|
21 | + /** |
|
22 | + * @return string |
|
23 | + */ |
|
24 | + public function description(); |
|
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * @return array |
|
29 | - * @since 5.0.0.p |
|
30 | - */ |
|
31 | - public function values(); |
|
27 | + /** |
|
28 | + * @return array |
|
29 | + * @since 5.0.0.p |
|
30 | + */ |
|
31 | + public function values(); |
|
32 | 32 | } |
@@ -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 5.0.0.p |
|
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 5.0.0.p |
|
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 | } |
@@ -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 5.0.0.p |
|
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 5.0.0.p |
|
23 | + */ |
|
24 | + public function registerLoaders(array $loaders, AppContext $context): array; |
|
25 | 25 | } |
@@ -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 5.0.0.p |
|
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 5.0.0.p |
|
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 5.0.0.p |
|
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 5.0.0.p |
|
85 | + */ |
|
86 | + public function getDataLoaders() |
|
87 | + { |
|
88 | + $this->loadCollection(); |
|
89 | + return $this->loader->getCollection(); |
|
90 | + } |
|
91 | 91 | } |