@@ -13,50 +13,50 @@ |
||
13 | 13 | interface ModelObjectToJsonConverterInterface |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @param array $entities |
|
18 | - * @return array |
|
19 | - * @since $VID:$ |
|
20 | - */ |
|
21 | - public function convertAndEncodeArrayOf(array $entities); |
|
22 | - |
|
23 | - |
|
24 | - /** |
|
25 | - * @param $entity |
|
26 | - * @return false|string |
|
27 | - * @since $VID:$ |
|
28 | - */ |
|
29 | - public function convertAndEncode($entity); |
|
30 | - |
|
31 | - |
|
32 | - /** |
|
33 | - * @param array $entities |
|
34 | - * @return array |
|
35 | - * @since $VID:$ |
|
36 | - */ |
|
37 | - public function convertArrayOf(array $entities); |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * @param $entity |
|
42 | - * @return array |
|
43 | - * @since $VID:$ |
|
44 | - */ |
|
45 | - public function convert($entity); |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * @param array $entities |
|
50 | - * @return array |
|
51 | - * @since $VID:$ |
|
52 | - */ |
|
53 | - public function encodeArrayOf(array $entities); |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * @param array $entity_array |
|
58 | - * @return false|string |
|
59 | - * @since $VID:$ |
|
60 | - */ |
|
61 | - public function encode(array $entity_array); |
|
16 | + /** |
|
17 | + * @param array $entities |
|
18 | + * @return array |
|
19 | + * @since $VID:$ |
|
20 | + */ |
|
21 | + public function convertAndEncodeArrayOf(array $entities); |
|
22 | + |
|
23 | + |
|
24 | + /** |
|
25 | + * @param $entity |
|
26 | + * @return false|string |
|
27 | + * @since $VID:$ |
|
28 | + */ |
|
29 | + public function convertAndEncode($entity); |
|
30 | + |
|
31 | + |
|
32 | + /** |
|
33 | + * @param array $entities |
|
34 | + * @return array |
|
35 | + * @since $VID:$ |
|
36 | + */ |
|
37 | + public function convertArrayOf(array $entities); |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * @param $entity |
|
42 | + * @return array |
|
43 | + * @since $VID:$ |
|
44 | + */ |
|
45 | + public function convert($entity); |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * @param array $entities |
|
50 | + * @return array |
|
51 | + * @since $VID:$ |
|
52 | + */ |
|
53 | + public function encodeArrayOf(array $entities); |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * @param array $entity_array |
|
58 | + * @return false|string |
|
59 | + * @since $VID:$ |
|
60 | + */ |
|
61 | + public function encode(array $entity_array); |
|
62 | 62 | } |
@@ -15,29 +15,29 @@ |
||
15 | 15 | interface ConnectionInterface |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @return array |
|
20 | - * @since $VID:$ |
|
21 | - */ |
|
22 | - public function config(); |
|
18 | + /** |
|
19 | + * @return array |
|
20 | + * @since $VID:$ |
|
21 | + */ |
|
22 | + public function config(); |
|
23 | 23 | |
24 | - /** |
|
25 | - * @param $entity |
|
26 | - * @param $args |
|
27 | - * @param $context |
|
28 | - * @param $info |
|
29 | - * @return array |
|
30 | - * @since $VID:$ |
|
31 | - */ |
|
32 | - public function resolveConnection($entity, $args, $context, $info); |
|
24 | + /** |
|
25 | + * @param $entity |
|
26 | + * @param $args |
|
27 | + * @param $context |
|
28 | + * @param $info |
|
29 | + * @return array |
|
30 | + * @since $VID:$ |
|
31 | + */ |
|
32 | + public function resolveConnection($entity, $args, $context, $info); |
|
33 | 33 | |
34 | - /** |
|
35 | - * @param $id |
|
36 | - * @param $args |
|
37 | - * @param $context |
|
38 | - * @param $info |
|
39 | - * @return EE_Base_Class |
|
40 | - * @since $VID:$ |
|
41 | - */ |
|
42 | - public function resolveNode($id, $args, $context, $info); |
|
34 | + /** |
|
35 | + * @param $id |
|
36 | + * @param $args |
|
37 | + * @param $context |
|
38 | + * @param $info |
|
39 | + * @return EE_Base_Class |
|
40 | + * @since $VID:$ |
|
41 | + */ |
|
42 | + public function resolveNode($id, $args, $context, $info); |
|
43 | 43 | } |
@@ -21,85 +21,85 @@ |
||
21 | 21 | class ConnectionCollection extends Collection |
22 | 22 | { |
23 | 23 | |
24 | - const COLLECTION_NAME = 'espresso_graphql_connections'; |
|
24 | + const COLLECTION_NAME = 'espresso_graphql_connections'; |
|
25 | 25 | |
26 | - /** |
|
27 | - * @var CollectionLoader $loader |
|
28 | - */ |
|
29 | - protected $loader; |
|
26 | + /** |
|
27 | + * @var CollectionLoader $loader |
|
28 | + */ |
|
29 | + protected $loader; |
|
30 | 30 | |
31 | - /** |
|
32 | - * ConnectionCollection constructor |
|
33 | - * |
|
34 | - * @throws InvalidInterfaceException |
|
35 | - */ |
|
36 | - public function __construct() |
|
37 | - { |
|
38 | - parent::__construct( |
|
39 | - 'EventEspresso\core\services\graphql\connections\ConnectionInterface', |
|
40 | - ConnectionCollection::COLLECTION_NAME |
|
41 | - ); |
|
42 | - } |
|
31 | + /** |
|
32 | + * ConnectionCollection constructor |
|
33 | + * |
|
34 | + * @throws InvalidInterfaceException |
|
35 | + */ |
|
36 | + public function __construct() |
|
37 | + { |
|
38 | + parent::__construct( |
|
39 | + 'EventEspresso\core\services\graphql\connections\ConnectionInterface', |
|
40 | + ConnectionCollection::COLLECTION_NAME |
|
41 | + ); |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | - /** |
|
46 | - * @throws CollectionDetailsException |
|
47 | - * @throws CollectionLoaderException |
|
48 | - * @since $VID:$ |
|
49 | - */ |
|
50 | - private function loadCollection() |
|
51 | - { |
|
52 | - if (! $this->loader instanceof CollectionLoader) { |
|
53 | - $this->loader = new CollectionLoader( |
|
54 | - new CollectionDetails( |
|
55 | - // collection nameConnectionCollection::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 | - } |
|
45 | + /** |
|
46 | + * @throws CollectionDetailsException |
|
47 | + * @throws CollectionLoaderException |
|
48 | + * @since $VID:$ |
|
49 | + */ |
|
50 | + private function loadCollection() |
|
51 | + { |
|
52 | + if (! $this->loader instanceof CollectionLoader) { |
|
53 | + $this->loader = new CollectionLoader( |
|
54 | + new CollectionDetails( |
|
55 | + // collection nameConnectionCollection::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 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | */ |
50 | 50 | private function loadCollection() |
51 | 51 | { |
52 | - if (! $this->loader instanceof CollectionLoader) { |
|
52 | + if ( ! $this->loader instanceof CollectionLoader) { |
|
53 | 53 | $this->loader = new CollectionLoader( |
54 | 54 | new CollectionDetails( |
55 | 55 | // collection nameConnectionCollection::COLLECTION_NAME, |
@@ -16,13 +16,13 @@ |
||
16 | 16 | interface ResolverInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @param $source |
|
21 | - * @param array $args |
|
22 | - * @param AppContext $context |
|
23 | - * @param ResolveInfo $info |
|
24 | - * @return mixed |
|
25 | - * @since $VID:$ |
|
26 | - */ |
|
27 | - public function resolve($source, array $args, AppContext $context, ResolveInfo $info); |
|
19 | + /** |
|
20 | + * @param $source |
|
21 | + * @param array $args |
|
22 | + * @param AppContext $context |
|
23 | + * @param ResolveInfo $info |
|
24 | + * @return mixed |
|
25 | + * @since $VID:$ |
|
26 | + */ |
|
27 | + public function resolve($source, array $args, AppContext $context, ResolveInfo $info); |
|
28 | 28 | } |
@@ -21,85 +21,85 @@ |
||
21 | 21 | class ResolverCollection extends Collection |
22 | 22 | { |
23 | 23 | |
24 | - const COLLECTION_NAME = 'espresso_graphql_resolvers'; |
|
24 | + const COLLECTION_NAME = 'espresso_graphql_resolvers'; |
|
25 | 25 | |
26 | - /** |
|
27 | - * @var CollectionLoader $loader |
|
28 | - */ |
|
29 | - protected $loader; |
|
26 | + /** |
|
27 | + * @var CollectionLoader $loader |
|
28 | + */ |
|
29 | + protected $loader; |
|
30 | 30 | |
31 | - /** |
|
32 | - * ResolverCollection constructor |
|
33 | - * |
|
34 | - * @throws InvalidInterfaceException |
|
35 | - */ |
|
36 | - public function __construct() |
|
37 | - { |
|
38 | - parent::__construct( |
|
39 | - 'EventEspresso\core\services\graphql\ResolverInterface', |
|
40 | - ResolverCollection::COLLECTION_NAME |
|
41 | - ); |
|
42 | - } |
|
31 | + /** |
|
32 | + * ResolverCollection constructor |
|
33 | + * |
|
34 | + * @throws InvalidInterfaceException |
|
35 | + */ |
|
36 | + public function __construct() |
|
37 | + { |
|
38 | + parent::__construct( |
|
39 | + 'EventEspresso\core\services\graphql\ResolverInterface', |
|
40 | + ResolverCollection::COLLECTION_NAME |
|
41 | + ); |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | - /** |
|
46 | - * @throws CollectionDetailsException |
|
47 | - * @throws CollectionLoaderException |
|
48 | - * @since $VID:$ |
|
49 | - */ |
|
50 | - private function loadCollection() |
|
51 | - { |
|
52 | - if (! $this->loader instanceof CollectionLoader) { |
|
53 | - $this->loader = new CollectionLoader( |
|
54 | - new CollectionDetails( |
|
55 | - // collection nameResolverCollection::COLLECTION_NAME, |
|
56 | - // collection interface |
|
57 | - 'EventEspresso\core\services\graphql\ResolverInterface', |
|
58 | - // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
59 | - apply_filters( |
|
60 | - 'FHEE__EventEspresso_core_services_graphql_ResolverCollection__loadCollection__collection_FQCNs', |
|
61 | - ['EventEspresso\core\domain\services\graphql\resolvers'] |
|
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 | - } |
|
45 | + /** |
|
46 | + * @throws CollectionDetailsException |
|
47 | + * @throws CollectionLoaderException |
|
48 | + * @since $VID:$ |
|
49 | + */ |
|
50 | + private function loadCollection() |
|
51 | + { |
|
52 | + if (! $this->loader instanceof CollectionLoader) { |
|
53 | + $this->loader = new CollectionLoader( |
|
54 | + new CollectionDetails( |
|
55 | + // collection nameResolverCollection::COLLECTION_NAME, |
|
56 | + // collection interface |
|
57 | + 'EventEspresso\core\services\graphql\ResolverInterface', |
|
58 | + // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
59 | + apply_filters( |
|
60 | + 'FHEE__EventEspresso_core_services_graphql_ResolverCollection__loadCollection__collection_FQCNs', |
|
61 | + ['EventEspresso\core\domain\services\graphql\resolvers'] |
|
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 loadResolvers() |
|
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 loadResolvers() |
|
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 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | */ |
50 | 50 | private function loadCollection() |
51 | 51 | { |
52 | - if (! $this->loader instanceof CollectionLoader) { |
|
52 | + if ( ! $this->loader instanceof CollectionLoader) { |
|
53 | 53 | $this->loader = new CollectionLoader( |
54 | 54 | new CollectionDetails( |
55 | 55 | // collection nameResolverCollection::COLLECTION_NAME, |
@@ -18,110 +18,110 @@ |
||
18 | 18 | class TypesManager |
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 | } |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | $config = $field->toArray(); |
76 | 76 | if ($field->useForInput()) { |
77 | 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); |
|
78 | + register_graphql_field('Update'.$typeName.'Input', $fieldName, $config); |
|
79 | + register_graphql_field('Create'.$typeName.'Input', $fieldName, $config); |
|
80 | 80 | } |
81 | 81 | if ($field->useForOutput()) { |
82 | 82 | $config['resolve'] = [$type, 'resolveField']; |
@@ -102,15 +102,15 @@ discard block |
||
102 | 102 | $fieldName = $field->name(); |
103 | 103 | $config = $field->toArray(); |
104 | 104 | if ($field->useForInput()) { |
105 | - $inputFields[ $fieldName ] = $config; |
|
105 | + $inputFields[$fieldName] = $config; |
|
106 | 106 | } |
107 | 107 | if ($field->useForOutput()) { |
108 | 108 | $config['resolve'] = [$type, 'resolveField']; |
109 | - $outputFields[ $fieldName ] = $config; |
|
109 | + $outputFields[$fieldName] = $config; |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | $typeName = $type->name(); |
113 | - if (! empty($outputFields)) { |
|
113 | + if ( ! empty($outputFields)) { |
|
114 | 114 | // Register the object type. |
115 | 115 | register_graphql_object_type( |
116 | 116 | $typeName, |
@@ -16,38 +16,38 @@ |
||
16 | 16 | class GraphQLManager |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var TypesManager $types_manager |
|
21 | - */ |
|
22 | - protected $types_manager; |
|
23 | - |
|
24 | - /** |
|
25 | - * @var ConnectionsManager $connections_manager |
|
26 | - */ |
|
27 | - protected $connections_manager; |
|
28 | - |
|
29 | - |
|
30 | - /** |
|
31 | - * GraphQLManager constructor. |
|
32 | - * |
|
33 | - * @param TypesManager $types_manager |
|
34 | - * @param ConnectionsManager $connections_manager |
|
35 | - */ |
|
36 | - public function __construct(TypesManager $types_manager, ConnectionsManager $connections_manager) |
|
37 | - { |
|
38 | - $this->types_manager = $types_manager; |
|
39 | - $this->connections_manager = $connections_manager; |
|
40 | - } |
|
41 | - |
|
42 | - |
|
43 | - /** |
|
44 | - * @throws CollectionDetailsException |
|
45 | - * @throws CollectionLoaderException |
|
46 | - * @since $VID:$ |
|
47 | - */ |
|
48 | - public function init() |
|
49 | - { |
|
50 | - $this->types_manager->init(); |
|
51 | - $this->connections_manager->init(); |
|
52 | - } |
|
19 | + /** |
|
20 | + * @var TypesManager $types_manager |
|
21 | + */ |
|
22 | + protected $types_manager; |
|
23 | + |
|
24 | + /** |
|
25 | + * @var ConnectionsManager $connections_manager |
|
26 | + */ |
|
27 | + protected $connections_manager; |
|
28 | + |
|
29 | + |
|
30 | + /** |
|
31 | + * GraphQLManager constructor. |
|
32 | + * |
|
33 | + * @param TypesManager $types_manager |
|
34 | + * @param ConnectionsManager $connections_manager |
|
35 | + */ |
|
36 | + public function __construct(TypesManager $types_manager, ConnectionsManager $connections_manager) |
|
37 | + { |
|
38 | + $this->types_manager = $types_manager; |
|
39 | + $this->connections_manager = $connections_manager; |
|
40 | + } |
|
41 | + |
|
42 | + |
|
43 | + /** |
|
44 | + * @throws CollectionDetailsException |
|
45 | + * @throws CollectionLoaderException |
|
46 | + * @since $VID:$ |
|
47 | + */ |
|
48 | + public function init() |
|
49 | + { |
|
50 | + $this->types_manager->init(); |
|
51 | + $this->connections_manager->init(); |
|
52 | + } |
|
53 | 53 | } |
@@ -23,79 +23,79 @@ |
||
23 | 23 | interface TypeInterface |
24 | 24 | { |
25 | 25 | |
26 | - /** |
|
27 | - * @return string |
|
28 | - */ |
|
29 | - public function name(); |
|
30 | - |
|
31 | - |
|
32 | - /** |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - public function description(); |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * @return \EventEspresso\core\services\graphql\fields\GraphQLFieldInterface[] |
|
40 | - * @since $VID:$ |
|
41 | - */ |
|
42 | - public function fields(); |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * Creates a key map for internal resolver. |
|
47 | - * |
|
48 | - * @return array |
|
49 | - * @since $VID:$ |
|
50 | - */ |
|
51 | - public function getFieldsForResolver(); |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * @return bool |
|
56 | - */ |
|
57 | - public function isCustomPostType(); |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * @param int $value |
|
62 | - * @return int |
|
63 | - * @since $VID:$ |
|
64 | - */ |
|
65 | - public function parseInfiniteValue($value); |
|
66 | - |
|
67 | - |
|
68 | - /** |
|
69 | - * @param mixed $source The source that's passed down the GraphQL queries |
|
70 | - * @param array $args The inputArgs on the field |
|
71 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
72 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
73 | - * @return string |
|
74 | - * @throws EE_Error |
|
75 | - * @throws InvalidDataTypeException |
|
76 | - * @throws InvalidInterfaceException |
|
77 | - * @throws UnexpectedEntityException |
|
78 | - * @throws UserError |
|
79 | - * @throws InvalidArgumentException |
|
80 | - * @throws ReflectionException |
|
81 | - * @since $VID:$ |
|
82 | - */ |
|
83 | - public function resolveField($source, $args, AppContext $context, ResolveInfo $info); |
|
84 | - |
|
85 | - |
|
86 | - /** |
|
87 | - * @param mixed $payload The payload returned after mutation |
|
88 | - * @param array $args The inputArgs on the field |
|
89 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
90 | - * @return string |
|
91 | - * @throws EE_Error |
|
92 | - * @throws InvalidDataTypeException |
|
93 | - * @throws InvalidInterfaceException |
|
94 | - * @throws UnexpectedEntityException |
|
95 | - * @throws UserError |
|
96 | - * @throws InvalidArgumentException |
|
97 | - * @throws ReflectionException |
|
98 | - * @since $VID:$ |
|
99 | - */ |
|
100 | - public function resolveFromPayload($payload, $args, AppContext $context); |
|
26 | + /** |
|
27 | + * @return string |
|
28 | + */ |
|
29 | + public function name(); |
|
30 | + |
|
31 | + |
|
32 | + /** |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + public function description(); |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * @return \EventEspresso\core\services\graphql\fields\GraphQLFieldInterface[] |
|
40 | + * @since $VID:$ |
|
41 | + */ |
|
42 | + public function fields(); |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * Creates a key map for internal resolver. |
|
47 | + * |
|
48 | + * @return array |
|
49 | + * @since $VID:$ |
|
50 | + */ |
|
51 | + public function getFieldsForResolver(); |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * @return bool |
|
56 | + */ |
|
57 | + public function isCustomPostType(); |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * @param int $value |
|
62 | + * @return int |
|
63 | + * @since $VID:$ |
|
64 | + */ |
|
65 | + public function parseInfiniteValue($value); |
|
66 | + |
|
67 | + |
|
68 | + /** |
|
69 | + * @param mixed $source The source that's passed down the GraphQL queries |
|
70 | + * @param array $args The inputArgs on the field |
|
71 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
72 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
73 | + * @return string |
|
74 | + * @throws EE_Error |
|
75 | + * @throws InvalidDataTypeException |
|
76 | + * @throws InvalidInterfaceException |
|
77 | + * @throws UnexpectedEntityException |
|
78 | + * @throws UserError |
|
79 | + * @throws InvalidArgumentException |
|
80 | + * @throws ReflectionException |
|
81 | + * @since $VID:$ |
|
82 | + */ |
|
83 | + public function resolveField($source, $args, AppContext $context, ResolveInfo $info); |
|
84 | + |
|
85 | + |
|
86 | + /** |
|
87 | + * @param mixed $payload The payload returned after mutation |
|
88 | + * @param array $args The inputArgs on the field |
|
89 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
90 | + * @return string |
|
91 | + * @throws EE_Error |
|
92 | + * @throws InvalidDataTypeException |
|
93 | + * @throws InvalidInterfaceException |
|
94 | + * @throws UnexpectedEntityException |
|
95 | + * @throws UserError |
|
96 | + * @throws InvalidArgumentException |
|
97 | + * @throws ReflectionException |
|
98 | + * @since $VID:$ |
|
99 | + */ |
|
100 | + public function resolveFromPayload($payload, $args, AppContext $context); |
|
101 | 101 | } |
@@ -21,86 +21,86 @@ |
||
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 | - /** |
|
27 | - * @var CollectionLoader $loader |
|
28 | - */ |
|
29 | - protected $loader; |
|
26 | + /** |
|
27 | + * @var CollectionLoader $loader |
|
28 | + */ |
|
29 | + protected $loader; |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * TypeCollection constructor |
|
34 | - * |
|
35 | - * @throws InvalidInterfaceException |
|
36 | - */ |
|
37 | - public function __construct() |
|
38 | - { |
|
39 | - parent::__construct( |
|
40 | - 'EventEspresso\core\services\graphql\types\TypeInterface', |
|
41 | - TypeCollection::COLLECTION_NAME |
|
42 | - ); |
|
43 | - } |
|
32 | + /** |
|
33 | + * TypeCollection constructor |
|
34 | + * |
|
35 | + * @throws InvalidInterfaceException |
|
36 | + */ |
|
37 | + public function __construct() |
|
38 | + { |
|
39 | + parent::__construct( |
|
40 | + 'EventEspresso\core\services\graphql\types\TypeInterface', |
|
41 | + TypeCollection::COLLECTION_NAME |
|
42 | + ); |
|
43 | + } |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * @throws CollectionDetailsException |
|
48 | - * @throws CollectionLoaderException |
|
49 | - * @since $VID:$ |
|
50 | - */ |
|
51 | - private function loadCollection() |
|
52 | - { |
|
53 | - if (! $this->loader instanceof CollectionLoader) { |
|
54 | - $this->loader = new CollectionLoader( |
|
55 | - new CollectionDetails( |
|
56 | - // collection nameTypeCollection::COLLECTION_NAME, |
|
57 | - // collection interface |
|
58 | - 'EventEspresso\core\services\graphql\types\TypeInterface', |
|
59 | - // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
60 | - apply_filters( |
|
61 | - 'FHEE__EventEspresso_core_services_graphql_TypeCollection__loadCollection__collection_FQCNs', |
|
62 | - ['EventEspresso\core\domain\services\graphql\types'] |
|
63 | - ), |
|
64 | - // filepaths to classes to add |
|
65 | - array(), |
|
66 | - // file mask to use if parsing folder for files to add |
|
67 | - '', |
|
68 | - // what to use as identifier for collection entities |
|
69 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
70 | - CollectionDetails::ID_CLASS_NAME |
|
71 | - ), |
|
72 | - $this |
|
73 | - ); |
|
74 | - } |
|
75 | - } |
|
46 | + /** |
|
47 | + * @throws CollectionDetailsException |
|
48 | + * @throws CollectionLoaderException |
|
49 | + * @since $VID:$ |
|
50 | + */ |
|
51 | + private function loadCollection() |
|
52 | + { |
|
53 | + if (! $this->loader instanceof CollectionLoader) { |
|
54 | + $this->loader = new CollectionLoader( |
|
55 | + new CollectionDetails( |
|
56 | + // collection nameTypeCollection::COLLECTION_NAME, |
|
57 | + // collection interface |
|
58 | + 'EventEspresso\core\services\graphql\types\TypeInterface', |
|
59 | + // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
60 | + apply_filters( |
|
61 | + 'FHEE__EventEspresso_core_services_graphql_TypeCollection__loadCollection__collection_FQCNs', |
|
62 | + ['EventEspresso\core\domain\services\graphql\types'] |
|
63 | + ), |
|
64 | + // filepaths to classes to add |
|
65 | + array(), |
|
66 | + // file mask to use if parsing folder for files to add |
|
67 | + '', |
|
68 | + // what to use as identifier for collection entities |
|
69 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
70 | + CollectionDetails::ID_CLASS_NAME |
|
71 | + ), |
|
72 | + $this |
|
73 | + ); |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | - /** |
|
79 | - * @return CollectionInterface |
|
80 | - * @throws CollectionDetailsException |
|
81 | - * @throws CollectionLoaderException |
|
82 | - * @since $VID:$ |
|
83 | - */ |
|
84 | - public function loadTypes() |
|
85 | - { |
|
86 | - $this->loadCollection(); |
|
87 | - return $this->loader->getCollection(); |
|
88 | - } |
|
78 | + /** |
|
79 | + * @return CollectionInterface |
|
80 | + * @throws CollectionDetailsException |
|
81 | + * @throws CollectionLoaderException |
|
82 | + * @since $VID:$ |
|
83 | + */ |
|
84 | + public function loadTypes() |
|
85 | + { |
|
86 | + $this->loadCollection(); |
|
87 | + return $this->loader->getCollection(); |
|
88 | + } |
|
89 | 89 | |
90 | 90 | |
91 | - /** |
|
92 | - * getIdentifier |
|
93 | - * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
94 | - * If no $identifier is supplied, then the fully qualified class name is used |
|
95 | - * |
|
96 | - * @param $object |
|
97 | - * @param mixed $identifier |
|
98 | - * @return bool |
|
99 | - */ |
|
100 | - public function getIdentifier($object, $identifier = null) |
|
101 | - { |
|
102 | - return ! empty($identifier) |
|
103 | - ? $identifier |
|
104 | - : get_class($object); |
|
105 | - } |
|
91 | + /** |
|
92 | + * getIdentifier |
|
93 | + * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
94 | + * If no $identifier is supplied, then the fully qualified class name is used |
|
95 | + * |
|
96 | + * @param $object |
|
97 | + * @param mixed $identifier |
|
98 | + * @return bool |
|
99 | + */ |
|
100 | + public function getIdentifier($object, $identifier = null) |
|
101 | + { |
|
102 | + return ! empty($identifier) |
|
103 | + ? $identifier |
|
104 | + : get_class($object); |
|
105 | + } |
|
106 | 106 | } |
@@ -50,7 +50,7 @@ |
||
50 | 50 | */ |
51 | 51 | private function loadCollection() |
52 | 52 | { |
53 | - if (! $this->loader instanceof CollectionLoader) { |
|
53 | + if ( ! $this->loader instanceof CollectionLoader) { |
|
54 | 54 | $this->loader = new CollectionLoader( |
55 | 55 | new CollectionDetails( |
56 | 56 | // collection nameTypeCollection::COLLECTION_NAME, |