@@ -18,60 +18,60 @@ |
||
18 | 18 | class EnumsManager implements GQLManagerInterface |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var EnumCollection|EnumInterface[] $enums |
|
23 | - */ |
|
24 | - private $enums; |
|
21 | + /** |
|
22 | + * @var EnumCollection|EnumInterface[] $enums |
|
23 | + */ |
|
24 | + private $enums; |
|
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * EnumsManager constructor. |
|
29 | - * |
|
30 | - * @param EnumCollection|EnumInterface[] $enums |
|
31 | - */ |
|
32 | - public function __construct(EnumCollection $enums) |
|
33 | - { |
|
34 | - $this->enums = $enums; |
|
35 | - } |
|
27 | + /** |
|
28 | + * EnumsManager constructor. |
|
29 | + * |
|
30 | + * @param EnumCollection|EnumInterface[] $enums |
|
31 | + */ |
|
32 | + public function __construct(EnumCollection $enums) |
|
33 | + { |
|
34 | + $this->enums = $enums; |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * @throws CollectionDetailsException |
|
40 | - * @throws CollectionLoaderException |
|
41 | - * @since $VID:$ |
|
42 | - */ |
|
43 | - public function init() |
|
44 | - { |
|
45 | - $this->enums->loadEnums(); |
|
46 | - add_action('graphql_register_types', [$this, 'configureEnums'], 8); |
|
47 | - } |
|
38 | + /** |
|
39 | + * @throws CollectionDetailsException |
|
40 | + * @throws CollectionLoaderException |
|
41 | + * @since $VID:$ |
|
42 | + */ |
|
43 | + public function init() |
|
44 | + { |
|
45 | + $this->enums->loadEnums(); |
|
46 | + add_action('graphql_register_types', [$this, 'configureEnums'], 8); |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * @since $VID:$ |
|
52 | - */ |
|
53 | - public function configureEnums() |
|
54 | - { |
|
55 | - // loop through the collection of enums and register their fields |
|
56 | - foreach ($this->enums as $enum) { |
|
57 | - $this->registerEnum($enum); |
|
58 | - } |
|
59 | - } |
|
50 | + /** |
|
51 | + * @since $VID:$ |
|
52 | + */ |
|
53 | + public function configureEnums() |
|
54 | + { |
|
55 | + // loop through the collection of enums and register their fields |
|
56 | + foreach ($this->enums as $enum) { |
|
57 | + $this->registerEnum($enum); |
|
58 | + } |
|
59 | + } |
|
60 | 60 | |
61 | 61 | |
62 | - /** |
|
63 | - * @param EnumInterface $enum |
|
64 | - * @since $VID:$ |
|
65 | - */ |
|
66 | - public function registerEnum(EnumInterface $enum) |
|
67 | - { |
|
68 | - // Register the enum type. |
|
69 | - register_graphql_enum_type( |
|
70 | - $enum->name(), |
|
71 | - [ |
|
72 | - 'description' => $enum->description(), |
|
73 | - 'values' => $enum->values(), |
|
74 | - ] |
|
75 | - ); |
|
76 | - } |
|
62 | + /** |
|
63 | + * @param EnumInterface $enum |
|
64 | + * @since $VID:$ |
|
65 | + */ |
|
66 | + public function registerEnum(EnumInterface $enum) |
|
67 | + { |
|
68 | + // Register the enum type. |
|
69 | + register_graphql_enum_type( |
|
70 | + $enum->name(), |
|
71 | + [ |
|
72 | + 'description' => $enum->description(), |
|
73 | + 'values' => $enum->values(), |
|
74 | + ] |
|
75 | + ); |
|
76 | + } |
|
77 | 77 | } |
@@ -18,65 +18,65 @@ |
||
18 | 18 | class InputsManager implements GQLManagerInterface |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var InputCollection|InputInterface[] $inputs |
|
23 | - */ |
|
24 | - private $inputs; |
|
21 | + /** |
|
22 | + * @var InputCollection|InputInterface[] $inputs |
|
23 | + */ |
|
24 | + private $inputs; |
|
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * InputsManager constructor. |
|
29 | - * |
|
30 | - * @param InputCollection|InputInterface[] $inputs |
|
31 | - */ |
|
32 | - public function __construct(InputCollection $inputs) |
|
33 | - { |
|
34 | - $this->inputs = $inputs; |
|
35 | - } |
|
27 | + /** |
|
28 | + * InputsManager constructor. |
|
29 | + * |
|
30 | + * @param InputCollection|InputInterface[] $inputs |
|
31 | + */ |
|
32 | + public function __construct(InputCollection $inputs) |
|
33 | + { |
|
34 | + $this->inputs = $inputs; |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * @throws CollectionDetailsException |
|
40 | - * @throws CollectionLoaderException |
|
41 | - * @since $VID:$ |
|
42 | - */ |
|
43 | - public function init() |
|
44 | - { |
|
45 | - $this->inputs->loadInputs(); |
|
46 | - add_action('graphql_register_types', [$this, 'configureInputs'], 9); |
|
47 | - } |
|
38 | + /** |
|
39 | + * @throws CollectionDetailsException |
|
40 | + * @throws CollectionLoaderException |
|
41 | + * @since $VID:$ |
|
42 | + */ |
|
43 | + public function init() |
|
44 | + { |
|
45 | + $this->inputs->loadInputs(); |
|
46 | + add_action('graphql_register_types', [$this, 'configureInputs'], 9); |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * @since $VID:$ |
|
52 | - */ |
|
53 | - public function configureInputs() |
|
54 | - { |
|
55 | - // loop through the collection of inputs and register their fields |
|
56 | - foreach ($this->inputs as $input) { |
|
57 | - $this->registerInput($input); |
|
58 | - } |
|
59 | - } |
|
50 | + /** |
|
51 | + * @since $VID:$ |
|
52 | + */ |
|
53 | + public function configureInputs() |
|
54 | + { |
|
55 | + // loop through the collection of inputs and register their fields |
|
56 | + foreach ($this->inputs as $input) { |
|
57 | + $this->registerInput($input); |
|
58 | + } |
|
59 | + } |
|
60 | 60 | |
61 | 61 | |
62 | - /** |
|
63 | - * @param InputInterface $input |
|
64 | - * @since $VID:$ |
|
65 | - */ |
|
66 | - public function registerInput(InputInterface $input) |
|
67 | - { |
|
68 | - $inputFields = []; |
|
69 | - foreach ($input->fields() as $field) { |
|
70 | - $fieldName = $field->name(); |
|
71 | - $inputFields[ $fieldName ] = $field->toArray(); |
|
72 | - } |
|
73 | - // Register the input type. |
|
74 | - register_graphql_input_type( |
|
75 | - $input->name(), |
|
76 | - [ |
|
77 | - 'description' => $input->description(), |
|
78 | - 'fields' => $inputFields, |
|
79 | - ] |
|
80 | - ); |
|
81 | - } |
|
62 | + /** |
|
63 | + * @param InputInterface $input |
|
64 | + * @since $VID:$ |
|
65 | + */ |
|
66 | + public function registerInput(InputInterface $input) |
|
67 | + { |
|
68 | + $inputFields = []; |
|
69 | + foreach ($input->fields() as $field) { |
|
70 | + $fieldName = $field->name(); |
|
71 | + $inputFields[ $fieldName ] = $field->toArray(); |
|
72 | + } |
|
73 | + // Register the input type. |
|
74 | + register_graphql_input_type( |
|
75 | + $input->name(), |
|
76 | + [ |
|
77 | + 'description' => $input->description(), |
|
78 | + 'fields' => $inputFields, |
|
79 | + ] |
|
80 | + ); |
|
81 | + } |
|
82 | 82 | } |
@@ -18,110 +18,110 @@ |
||
18 | 18 | class TypesManager implements GQLManagerInterface |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var TypeCollection|TypeInterface[] $types |
|
23 | - */ |
|
24 | - private $types; |
|
21 | + /** |
|
22 | + * @var TypeCollection|TypeInterface[] $types |
|
23 | + */ |
|
24 | + private $types; |
|
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * TypesManager constructor. |
|
29 | - * |
|
30 | - * @param TypeCollection|TypeInterface[] $types |
|
31 | - */ |
|
32 | - public function __construct(TypeCollection $types) |
|
33 | - { |
|
34 | - $this->types = $types; |
|
35 | - } |
|
27 | + /** |
|
28 | + * TypesManager constructor. |
|
29 | + * |
|
30 | + * @param TypeCollection|TypeInterface[] $types |
|
31 | + */ |
|
32 | + public function __construct(TypeCollection $types) |
|
33 | + { |
|
34 | + $this->types = $types; |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * @throws CollectionDetailsException |
|
40 | - * @throws CollectionLoaderException |
|
41 | - * @since $VID:$ |
|
42 | - */ |
|
43 | - public function init() |
|
44 | - { |
|
45 | - $this->types->loadTypes(); |
|
46 | - add_action('graphql_register_types', [$this, 'configureTypes'], 10); |
|
47 | - } |
|
38 | + /** |
|
39 | + * @throws CollectionDetailsException |
|
40 | + * @throws CollectionLoaderException |
|
41 | + * @since $VID:$ |
|
42 | + */ |
|
43 | + public function init() |
|
44 | + { |
|
45 | + $this->types->loadTypes(); |
|
46 | + add_action('graphql_register_types', [$this, 'configureTypes'], 10); |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * @since $VID:$ |
|
52 | - */ |
|
53 | - public function configureTypes() |
|
54 | - { |
|
55 | - // loop through the collection of types and register their fields |
|
56 | - foreach ($this->types as $type) { |
|
57 | - if ($type->isCustomPostType()) { |
|
58 | - $this->extendCustomPostType($type); |
|
59 | - } else { |
|
60 | - $this->registerType($type); |
|
61 | - } |
|
62 | - } |
|
63 | - } |
|
50 | + /** |
|
51 | + * @since $VID:$ |
|
52 | + */ |
|
53 | + public function configureTypes() |
|
54 | + { |
|
55 | + // loop through the collection of types and register their fields |
|
56 | + foreach ($this->types as $type) { |
|
57 | + if ($type->isCustomPostType()) { |
|
58 | + $this->extendCustomPostType($type); |
|
59 | + } else { |
|
60 | + $this->registerType($type); |
|
61 | + } |
|
62 | + } |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | - /** |
|
67 | - * @param TypeInterface $type |
|
68 | - * @since $VID:$ |
|
69 | - */ |
|
70 | - public function extendCustomPostType(TypeInterface $type) |
|
71 | - { |
|
72 | - $typeName = $type->name(); |
|
73 | - foreach ($type->fields() as $field) { |
|
74 | - $fieldName = $field->name(); |
|
75 | - $config = $field->toArray(); |
|
76 | - if ($field->useForInput()) { |
|
77 | - // Register input fields for existing mutations. |
|
78 | - register_graphql_field('Update' . $typeName . 'Input', $fieldName, $config); |
|
79 | - register_graphql_field('Create' . $typeName . 'Input', $fieldName, $config); |
|
80 | - } |
|
81 | - if ($field->useForOutput()) { |
|
82 | - $config['resolve'] = [$type, 'resolveField']; |
|
83 | - // Register fields for queries. |
|
84 | - register_graphql_field($typeName, $fieldName, $config); |
|
85 | - } |
|
86 | - } |
|
87 | - if (is_callable([$type, 'extendMutations'])) { |
|
88 | - $type->extendMutations(); |
|
89 | - } |
|
90 | - } |
|
66 | + /** |
|
67 | + * @param TypeInterface $type |
|
68 | + * @since $VID:$ |
|
69 | + */ |
|
70 | + public function extendCustomPostType(TypeInterface $type) |
|
71 | + { |
|
72 | + $typeName = $type->name(); |
|
73 | + foreach ($type->fields() as $field) { |
|
74 | + $fieldName = $field->name(); |
|
75 | + $config = $field->toArray(); |
|
76 | + if ($field->useForInput()) { |
|
77 | + // Register input fields for existing mutations. |
|
78 | + register_graphql_field('Update' . $typeName . 'Input', $fieldName, $config); |
|
79 | + register_graphql_field('Create' . $typeName . 'Input', $fieldName, $config); |
|
80 | + } |
|
81 | + if ($field->useForOutput()) { |
|
82 | + $config['resolve'] = [$type, 'resolveField']; |
|
83 | + // Register fields for queries. |
|
84 | + register_graphql_field($typeName, $fieldName, $config); |
|
85 | + } |
|
86 | + } |
|
87 | + if (is_callable([$type, 'extendMutations'])) { |
|
88 | + $type->extendMutations(); |
|
89 | + } |
|
90 | + } |
|
91 | 91 | |
92 | 92 | |
93 | - /** |
|
94 | - * @param TypeInterface $type |
|
95 | - * @since $VID:$ |
|
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 | - ] |
|
121 | - ); |
|
122 | - } |
|
123 | - if (is_callable([$type, 'registerMutations'])) { |
|
124 | - $type->registerMutations($inputFields); |
|
125 | - } |
|
126 | - } |
|
93 | + /** |
|
94 | + * @param TypeInterface $type |
|
95 | + * @since $VID:$ |
|
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 | + ] |
|
121 | + ); |
|
122 | + } |
|
123 | + if (is_callable([$type, 'registerMutations'])) { |
|
124 | + $type->registerMutations($inputFields); |
|
125 | + } |
|
126 | + } |
|
127 | 127 | } |
@@ -16,10 +16,10 @@ |
||
16 | 16 | interface GQLManagerInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @throws CollectionDetailsException |
|
21 | - * @throws CollectionLoaderException |
|
22 | - * @since $VID:$ |
|
23 | - */ |
|
24 | - public function init(); |
|
19 | + /** |
|
20 | + * @throws CollectionDetailsException |
|
21 | + * @throws CollectionLoaderException |
|
22 | + * @since $VID:$ |
|
23 | + */ |
|
24 | + public function init(); |
|
25 | 25 | } |
@@ -16,67 +16,67 @@ |
||
16 | 16 | class GraphQLManager implements GQLManagerInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var ConnectionsManager $connections_manager |
|
21 | - */ |
|
22 | - protected $connections_manager; |
|
19 | + /** |
|
20 | + * @var ConnectionsManager $connections_manager |
|
21 | + */ |
|
22 | + protected $connections_manager; |
|
23 | 23 | |
24 | - /** |
|
25 | - * @var DataLoaderManager $data_loader_manager |
|
26 | - */ |
|
27 | - protected $data_loader_manager; |
|
24 | + /** |
|
25 | + * @var DataLoaderManager $data_loader_manager |
|
26 | + */ |
|
27 | + protected $data_loader_manager; |
|
28 | 28 | |
29 | - /** |
|
30 | - * @var EnumsManager $enums_manager |
|
31 | - */ |
|
32 | - protected $enums_manager; |
|
29 | + /** |
|
30 | + * @var EnumsManager $enums_manager |
|
31 | + */ |
|
32 | + protected $enums_manager; |
|
33 | 33 | |
34 | - /** |
|
35 | - * @var InputsManager $inputs_manager |
|
36 | - */ |
|
37 | - protected $inputs_manager; |
|
34 | + /** |
|
35 | + * @var InputsManager $inputs_manager |
|
36 | + */ |
|
37 | + protected $inputs_manager; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @var TypesManager $types_manager |
|
41 | - */ |
|
42 | - protected $types_manager; |
|
39 | + /** |
|
40 | + * @var TypesManager $types_manager |
|
41 | + */ |
|
42 | + protected $types_manager; |
|
43 | 43 | |
44 | 44 | |
45 | - /** |
|
46 | - * GraphQLManager constructor. |
|
47 | - * |
|
48 | - * @param ConnectionsManager $connections_manager |
|
49 | - * @param DataLoaderManager $data_loader_manager |
|
50 | - * @param EnumsManager $enums_manager |
|
51 | - * @param InputsManager $inputs_manager |
|
52 | - * @param TypesManager $types_manager |
|
53 | - */ |
|
54 | - public function __construct( |
|
55 | - ConnectionsManager $connections_manager, |
|
56 | - DataLoaderManager $data_loader_manager, |
|
57 | - EnumsManager $enums_manager, |
|
58 | - InputsManager $inputs_manager, |
|
59 | - TypesManager $types_manager |
|
60 | - ) { |
|
61 | - $this->connections_manager = $connections_manager; |
|
62 | - $this->data_loader_manager = $data_loader_manager; |
|
63 | - $this->enums_manager = $enums_manager; |
|
64 | - $this->inputs_manager = $inputs_manager; |
|
65 | - $this->types_manager = $types_manager; |
|
66 | - } |
|
45 | + /** |
|
46 | + * GraphQLManager constructor. |
|
47 | + * |
|
48 | + * @param ConnectionsManager $connections_manager |
|
49 | + * @param DataLoaderManager $data_loader_manager |
|
50 | + * @param EnumsManager $enums_manager |
|
51 | + * @param InputsManager $inputs_manager |
|
52 | + * @param TypesManager $types_manager |
|
53 | + */ |
|
54 | + public function __construct( |
|
55 | + ConnectionsManager $connections_manager, |
|
56 | + DataLoaderManager $data_loader_manager, |
|
57 | + EnumsManager $enums_manager, |
|
58 | + InputsManager $inputs_manager, |
|
59 | + TypesManager $types_manager |
|
60 | + ) { |
|
61 | + $this->connections_manager = $connections_manager; |
|
62 | + $this->data_loader_manager = $data_loader_manager; |
|
63 | + $this->enums_manager = $enums_manager; |
|
64 | + $this->inputs_manager = $inputs_manager; |
|
65 | + $this->types_manager = $types_manager; |
|
66 | + } |
|
67 | 67 | |
68 | 68 | |
69 | - /** |
|
70 | - * @throws CollectionDetailsException |
|
71 | - * @throws CollectionLoaderException |
|
72 | - * @since $VID:$ |
|
73 | - */ |
|
74 | - public function init() |
|
75 | - { |
|
76 | - $this->connections_manager->init(); |
|
77 | - $this->data_loader_manager->init(); |
|
78 | - $this->enums_manager->init(); |
|
79 | - $this->inputs_manager->init(); |
|
80 | - $this->types_manager->init(); |
|
81 | - } |
|
69 | + /** |
|
70 | + * @throws CollectionDetailsException |
|
71 | + * @throws CollectionLoaderException |
|
72 | + * @since $VID:$ |
|
73 | + */ |
|
74 | + public function init() |
|
75 | + { |
|
76 | + $this->connections_manager->init(); |
|
77 | + $this->data_loader_manager->init(); |
|
78 | + $this->enums_manager->init(); |
|
79 | + $this->inputs_manager->init(); |
|
80 | + $this->types_manager->init(); |
|
81 | + } |
|
82 | 82 | } |
@@ -18,31 +18,31 @@ |
||
18 | 18 | class DataLoaderManager implements GQLManagerInterface |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var DataLoaderCollection|GQLDataDomainInterface[] $data_loaders |
|
23 | - */ |
|
24 | - private $data_loaders; |
|
25 | - |
|
26 | - |
|
27 | - /** |
|
28 | - * @param DataLoaderCollection|GQLDataDomainInterface[] $data_loaders |
|
29 | - */ |
|
30 | - public function __construct(DataLoaderCollection $data_loaders) |
|
31 | - { |
|
32 | - $this->data_loaders = $data_loaders; |
|
33 | - } |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * @throws CollectionDetailsException |
|
38 | - * @throws CollectionLoaderException |
|
39 | - * @since $VID:$ |
|
40 | - */ |
|
41 | - public function init() |
|
42 | - { |
|
43 | - $data_loaders = $this->data_loaders->getDataLoaders(); |
|
44 | - foreach ($data_loaders as $data_loader) { |
|
45 | - add_filter('graphql_data_loaders', [$data_loader, 'registerLoaders'], 10, 2); |
|
46 | - } |
|
47 | - } |
|
21 | + /** |
|
22 | + * @var DataLoaderCollection|GQLDataDomainInterface[] $data_loaders |
|
23 | + */ |
|
24 | + private $data_loaders; |
|
25 | + |
|
26 | + |
|
27 | + /** |
|
28 | + * @param DataLoaderCollection|GQLDataDomainInterface[] $data_loaders |
|
29 | + */ |
|
30 | + public function __construct(DataLoaderCollection $data_loaders) |
|
31 | + { |
|
32 | + $this->data_loaders = $data_loaders; |
|
33 | + } |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * @throws CollectionDetailsException |
|
38 | + * @throws CollectionLoaderException |
|
39 | + * @since $VID:$ |
|
40 | + */ |
|
41 | + public function init() |
|
42 | + { |
|
43 | + $data_loaders = $this->data_loaders->getDataLoaders(); |
|
44 | + foreach ($data_loaders as $data_loader) { |
|
45 | + add_filter('graphql_data_loaders', [$data_loader, 'registerLoaders'], 10, 2); |
|
46 | + } |
|
47 | + } |
|
48 | 48 | } |
@@ -21,89 +21,89 @@ |
||
21 | 21 | class TypeCollection extends Collection |
22 | 22 | { |
23 | 23 | |
24 | - const COLLECTION_NAME = 'espresso_graphql_types'; |
|
24 | + const COLLECTION_NAME = 'espresso_graphql_types'; |
|
25 | 25 | |
26 | - const COLLECTION_INTERFACE = 'EventEspresso\core\services\graphql\types\TypeInterface'; |
|
26 | + const COLLECTION_INTERFACE = 'EventEspresso\core\services\graphql\types\TypeInterface'; |
|
27 | 27 | |
28 | - /** |
|
29 | - * @var CollectionLoader $loader |
|
30 | - */ |
|
31 | - protected $loader; |
|
28 | + /** |
|
29 | + * @var CollectionLoader $loader |
|
30 | + */ |
|
31 | + protected $loader; |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * TypeCollection constructor |
|
36 | - * |
|
37 | - * @throws InvalidInterfaceException |
|
38 | - */ |
|
39 | - public function __construct() |
|
40 | - { |
|
41 | - parent::__construct( |
|
42 | - TypeCollection::COLLECTION_INTERFACE, |
|
43 | - TypeCollection::COLLECTION_NAME |
|
44 | - ); |
|
45 | - } |
|
34 | + /** |
|
35 | + * TypeCollection constructor |
|
36 | + * |
|
37 | + * @throws InvalidInterfaceException |
|
38 | + */ |
|
39 | + public function __construct() |
|
40 | + { |
|
41 | + parent::__construct( |
|
42 | + TypeCollection::COLLECTION_INTERFACE, |
|
43 | + TypeCollection::COLLECTION_NAME |
|
44 | + ); |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * @throws CollectionDetailsException |
|
50 | - * @throws CollectionLoaderException |
|
51 | - * @since $VID:$ |
|
52 | - */ |
|
53 | - private function loadCollection() |
|
54 | - { |
|
55 | - if (! $this->loader instanceof CollectionLoader) { |
|
56 | - $this->loader = new CollectionLoader( |
|
57 | - new CollectionDetails( |
|
58 | - // collection name |
|
59 | - TypeCollection::COLLECTION_NAME, |
|
60 | - // collection interface |
|
61 | - TypeCollection::COLLECTION_INTERFACE, |
|
62 | - // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
63 | - apply_filters( |
|
64 | - 'FHEE__EventEspresso_core_services_graphql_TypeCollection__loadCollection__collection_FQCNs', |
|
65 | - ['EventEspresso\core\domain\services\graphql\types'] |
|
66 | - ), |
|
67 | - // filepaths to classes to add |
|
68 | - array(), |
|
69 | - // file mask to use if parsing folder for files to add |
|
70 | - '', |
|
71 | - // what to use as identifier for collection entities |
|
72 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
73 | - CollectionDetails::ID_CLASS_NAME |
|
74 | - ), |
|
75 | - $this |
|
76 | - ); |
|
77 | - } |
|
78 | - } |
|
48 | + /** |
|
49 | + * @throws CollectionDetailsException |
|
50 | + * @throws CollectionLoaderException |
|
51 | + * @since $VID:$ |
|
52 | + */ |
|
53 | + private function loadCollection() |
|
54 | + { |
|
55 | + if (! $this->loader instanceof CollectionLoader) { |
|
56 | + $this->loader = new CollectionLoader( |
|
57 | + new CollectionDetails( |
|
58 | + // collection name |
|
59 | + TypeCollection::COLLECTION_NAME, |
|
60 | + // collection interface |
|
61 | + TypeCollection::COLLECTION_INTERFACE, |
|
62 | + // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
63 | + apply_filters( |
|
64 | + 'FHEE__EventEspresso_core_services_graphql_TypeCollection__loadCollection__collection_FQCNs', |
|
65 | + ['EventEspresso\core\domain\services\graphql\types'] |
|
66 | + ), |
|
67 | + // filepaths to classes to add |
|
68 | + array(), |
|
69 | + // file mask to use if parsing folder for files to add |
|
70 | + '', |
|
71 | + // what to use as identifier for collection entities |
|
72 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
73 | + CollectionDetails::ID_CLASS_NAME |
|
74 | + ), |
|
75 | + $this |
|
76 | + ); |
|
77 | + } |
|
78 | + } |
|
79 | 79 | |
80 | 80 | |
81 | - /** |
|
82 | - * @return CollectionInterface |
|
83 | - * @throws CollectionDetailsException |
|
84 | - * @throws CollectionLoaderException |
|
85 | - * @since $VID:$ |
|
86 | - */ |
|
87 | - public function loadTypes() |
|
88 | - { |
|
89 | - $this->loadCollection(); |
|
90 | - return $this->loader->getCollection(); |
|
91 | - } |
|
81 | + /** |
|
82 | + * @return CollectionInterface |
|
83 | + * @throws CollectionDetailsException |
|
84 | + * @throws CollectionLoaderException |
|
85 | + * @since $VID:$ |
|
86 | + */ |
|
87 | + public function loadTypes() |
|
88 | + { |
|
89 | + $this->loadCollection(); |
|
90 | + return $this->loader->getCollection(); |
|
91 | + } |
|
92 | 92 | |
93 | 93 | |
94 | - /** |
|
95 | - * getIdentifier |
|
96 | - * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
97 | - * If no $identifier is supplied, then the fully qualified class name is used |
|
98 | - * |
|
99 | - * @param $object |
|
100 | - * @param mixed $identifier |
|
101 | - * @return bool |
|
102 | - */ |
|
103 | - public function getIdentifier($object, $identifier = null) |
|
104 | - { |
|
105 | - return ! empty($identifier) |
|
106 | - ? $identifier |
|
107 | - : get_class($object); |
|
108 | - } |
|
94 | + /** |
|
95 | + * getIdentifier |
|
96 | + * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
97 | + * If no $identifier is supplied, then the fully qualified class name is used |
|
98 | + * |
|
99 | + * @param $object |
|
100 | + * @param mixed $identifier |
|
101 | + * @return bool |
|
102 | + */ |
|
103 | + public function getIdentifier($object, $identifier = null) |
|
104 | + { |
|
105 | + return ! empty($identifier) |
|
106 | + ? $identifier |
|
107 | + : get_class($object); |
|
108 | + } |
|
109 | 109 | } |
@@ -21,72 +21,72 @@ |
||
21 | 21 | class DataLoaderCollection extends Collection |
22 | 22 | { |
23 | 23 | |
24 | - const COLLECTION_NAME = 'espresso_graphql_data_loaders'; |
|
24 | + const COLLECTION_NAME = 'espresso_graphql_data_loaders'; |
|
25 | 25 | |
26 | - const COLLECTION_INTERFACE = 'EventEspresso\core\services\graphql\loaders\GQLDataDomainInterface'; |
|
26 | + const COLLECTION_INTERFACE = 'EventEspresso\core\services\graphql\loaders\GQLDataDomainInterface'; |
|
27 | 27 | |
28 | - /** |
|
29 | - * @var CollectionLoader $loader |
|
30 | - */ |
|
31 | - protected $loader; |
|
28 | + /** |
|
29 | + * @var CollectionLoader $loader |
|
30 | + */ |
|
31 | + protected $loader; |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * DataLoaderCollection constructor |
|
36 | - * |
|
37 | - * @throws InvalidInterfaceException |
|
38 | - */ |
|
39 | - public function __construct() |
|
40 | - { |
|
41 | - parent::__construct( |
|
42 | - DataLoaderCollection::COLLECTION_INTERFACE, |
|
43 | - DataLoaderCollection::COLLECTION_NAME |
|
44 | - ); |
|
45 | - } |
|
34 | + /** |
|
35 | + * DataLoaderCollection constructor |
|
36 | + * |
|
37 | + * @throws InvalidInterfaceException |
|
38 | + */ |
|
39 | + public function __construct() |
|
40 | + { |
|
41 | + parent::__construct( |
|
42 | + DataLoaderCollection::COLLECTION_INTERFACE, |
|
43 | + DataLoaderCollection::COLLECTION_NAME |
|
44 | + ); |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * @throws CollectionDetailsException |
|
50 | - * @throws CollectionLoaderException |
|
51 | - * @since $VID:$ |
|
52 | - */ |
|
53 | - private function loadCollection() |
|
54 | - { |
|
55 | - if (! $this->loader instanceof CollectionLoader) { |
|
56 | - $this->loader = new CollectionLoader( |
|
57 | - new CollectionDetails( |
|
58 | - // collection name |
|
59 | - DataLoaderCollection::COLLECTION_NAME, |
|
60 | - // collection interface |
|
61 | - DataLoaderCollection::COLLECTION_INTERFACE, |
|
62 | - // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
63 | - apply_filters( |
|
64 | - 'FHEE__EventEspresso_core_services_graphql_DataLoaderCollection__loadCollection__collection_FQCNs', |
|
65 | - ['EventEspresso\core\domain\services\graphql\data\domains'] |
|
66 | - ), |
|
67 | - // filepaths to classes to add |
|
68 | - array(), |
|
69 | - // file mask to use if parsing folder for files to add |
|
70 | - '', |
|
71 | - // what to use as identifier for collection entities |
|
72 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
73 | - CollectionDetails::ID_CLASS_NAME |
|
74 | - ), |
|
75 | - $this |
|
76 | - ); |
|
77 | - } |
|
78 | - } |
|
48 | + /** |
|
49 | + * @throws CollectionDetailsException |
|
50 | + * @throws CollectionLoaderException |
|
51 | + * @since $VID:$ |
|
52 | + */ |
|
53 | + private function loadCollection() |
|
54 | + { |
|
55 | + if (! $this->loader instanceof CollectionLoader) { |
|
56 | + $this->loader = new CollectionLoader( |
|
57 | + new CollectionDetails( |
|
58 | + // collection name |
|
59 | + DataLoaderCollection::COLLECTION_NAME, |
|
60 | + // collection interface |
|
61 | + DataLoaderCollection::COLLECTION_INTERFACE, |
|
62 | + // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
63 | + apply_filters( |
|
64 | + 'FHEE__EventEspresso_core_services_graphql_DataLoaderCollection__loadCollection__collection_FQCNs', |
|
65 | + ['EventEspresso\core\domain\services\graphql\data\domains'] |
|
66 | + ), |
|
67 | + // filepaths to classes to add |
|
68 | + array(), |
|
69 | + // file mask to use if parsing folder for files to add |
|
70 | + '', |
|
71 | + // what to use as identifier for collection entities |
|
72 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
73 | + CollectionDetails::ID_CLASS_NAME |
|
74 | + ), |
|
75 | + $this |
|
76 | + ); |
|
77 | + } |
|
78 | + } |
|
79 | 79 | |
80 | 80 | |
81 | - /** |
|
82 | - * @return CollectionInterface |
|
83 | - * @throws CollectionDetailsException |
|
84 | - * @throws CollectionLoaderException |
|
85 | - * @since $VID:$ |
|
86 | - */ |
|
87 | - public function getDataLoaders() |
|
88 | - { |
|
89 | - $this->loadCollection(); |
|
90 | - return $this->loader->getCollection(); |
|
91 | - } |
|
81 | + /** |
|
82 | + * @return CollectionInterface |
|
83 | + * @throws CollectionDetailsException |
|
84 | + * @throws CollectionLoaderException |
|
85 | + * @since $VID:$ |
|
86 | + */ |
|
87 | + public function getDataLoaders() |
|
88 | + { |
|
89 | + $this->loadCollection(); |
|
90 | + return $this->loader->getCollection(); |
|
91 | + } |
|
92 | 92 | } |
@@ -15,12 +15,12 @@ |
||
15 | 15 | interface GQLDataDomainInterface |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @param array $loaders The loaders accessible in the AppContext |
|
20 | - * @param AppContext $context The AppContext |
|
21 | - * @return array |
|
22 | - * @return array |
|
23 | - * @since $VID:$ |
|
24 | - */ |
|
25 | - public function registerLoaders($loaders, $context); |
|
18 | + /** |
|
19 | + * @param array $loaders The loaders accessible in the AppContext |
|
20 | + * @param AppContext $context The AppContext |
|
21 | + * @return array |
|
22 | + * @return array |
|
23 | + * @since $VID:$ |
|
24 | + */ |
|
25 | + public function registerLoaders($loaders, $context); |
|
26 | 26 | } |