@@ -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, |
@@ -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 | } |
@@ -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 name |
@@ -20,86 +20,86 @@ |
||
20 | 20 | */ |
21 | 21 | class ResolverCollection extends Collection |
22 | 22 | { |
23 | - const COLLECTION_NAME = 'espresso_graphql_resolvers'; |
|
23 | + const COLLECTION_NAME = 'espresso_graphql_resolvers'; |
|
24 | 24 | |
25 | - /** |
|
26 | - * @var CollectionLoader $loader |
|
27 | - */ |
|
28 | - protected $loader; |
|
25 | + /** |
|
26 | + * @var CollectionLoader $loader |
|
27 | + */ |
|
28 | + protected $loader; |
|
29 | 29 | |
30 | - /** |
|
31 | - * ResolverCollection constructor |
|
32 | - * |
|
33 | - * @throws InvalidInterfaceException |
|
34 | - */ |
|
35 | - public function __construct() |
|
36 | - { |
|
37 | - parent::__construct( |
|
38 | - 'EventEspresso\core\services\graphql\ResolverInterface', |
|
39 | - ResolverCollection::COLLECTION_NAME |
|
40 | - ); |
|
41 | - } |
|
30 | + /** |
|
31 | + * ResolverCollection constructor |
|
32 | + * |
|
33 | + * @throws InvalidInterfaceException |
|
34 | + */ |
|
35 | + public function __construct() |
|
36 | + { |
|
37 | + parent::__construct( |
|
38 | + 'EventEspresso\core\services\graphql\ResolverInterface', |
|
39 | + ResolverCollection::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 | - ResolverCollection::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 | - } |
|
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 | + ResolverCollection::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 5.0.0.p |
|
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 5.0.0.p |
|
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 name |
@@ -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 | } |
@@ -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 name |
@@ -20,86 +20,86 @@ |
||
20 | 20 | */ |
21 | 21 | class InputCollection extends Collection |
22 | 22 | { |
23 | - const COLLECTION_NAME = 'espresso_graphql_inputs'; |
|
23 | + const COLLECTION_NAME = 'espresso_graphql_inputs'; |
|
24 | 24 | |
25 | - /** |
|
26 | - * @var CollectionLoader $loader |
|
27 | - */ |
|
28 | - protected $loader; |
|
25 | + /** |
|
26 | + * @var CollectionLoader $loader |
|
27 | + */ |
|
28 | + protected $loader; |
|
29 | 29 | |
30 | - /** |
|
31 | - * InputCollection constructor |
|
32 | - * |
|
33 | - * @throws InvalidInterfaceException |
|
34 | - */ |
|
35 | - public function __construct() |
|
36 | - { |
|
37 | - parent::__construct( |
|
38 | - 'EventEspresso\core\services\graphql\inputs\InputInterface', |
|
39 | - InputCollection::COLLECTION_NAME |
|
40 | - ); |
|
41 | - } |
|
30 | + /** |
|
31 | + * InputCollection constructor |
|
32 | + * |
|
33 | + * @throws InvalidInterfaceException |
|
34 | + */ |
|
35 | + public function __construct() |
|
36 | + { |
|
37 | + parent::__construct( |
|
38 | + 'EventEspresso\core\services\graphql\inputs\InputInterface', |
|
39 | + InputCollection::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 | - InputCollection::COLLECTION_NAME, |
|
56 | - // collection interface |
|
57 | - 'EventEspresso\core\services\graphql\inputs\InputInterface', |
|
58 | - // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
59 | - apply_filters( |
|
60 | - 'FHEE__EventEspresso_core_services_graphql_InputCollection__loadCollection__collection_FQCNs', |
|
61 | - ['EventEspresso\core\domain\services\graphql\inputs'] |
|
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 | + InputCollection::COLLECTION_NAME, |
|
56 | + // collection interface |
|
57 | + 'EventEspresso\core\services\graphql\inputs\InputInterface', |
|
58 | + // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
59 | + apply_filters( |
|
60 | + 'FHEE__EventEspresso_core_services_graphql_InputCollection__loadCollection__collection_FQCNs', |
|
61 | + ['EventEspresso\core\domain\services\graphql\inputs'] |
|
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 loadInputs() |
|
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 loadInputs() |
|
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 name |
@@ -20,89 +20,89 @@ |
||
20 | 20 | */ |
21 | 21 | class TypeCollection extends Collection |
22 | 22 | { |
23 | - const COLLECTION_NAME = 'espresso_graphql_types'; |
|
23 | + const COLLECTION_NAME = 'espresso_graphql_types'; |
|
24 | 24 | |
25 | - const COLLECTION_INTERFACE = 'EventEspresso\core\services\graphql\types\TypeInterface'; |
|
25 | + const COLLECTION_INTERFACE = 'EventEspresso\core\services\graphql\types\TypeInterface'; |
|
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 | - * TypeCollection constructor |
|
35 | - * |
|
36 | - * @throws InvalidInterfaceException |
|
37 | - */ |
|
38 | - public function __construct() |
|
39 | - { |
|
40 | - parent::__construct( |
|
41 | - TypeCollection::COLLECTION_INTERFACE, |
|
42 | - TypeCollection::COLLECTION_NAME |
|
43 | - ); |
|
44 | - } |
|
33 | + /** |
|
34 | + * TypeCollection constructor |
|
35 | + * |
|
36 | + * @throws InvalidInterfaceException |
|
37 | + */ |
|
38 | + public function __construct() |
|
39 | + { |
|
40 | + parent::__construct( |
|
41 | + TypeCollection::COLLECTION_INTERFACE, |
|
42 | + TypeCollection::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 | - TypeCollection::COLLECTION_NAME, |
|
59 | - // collection interface |
|
60 | - TypeCollection::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_TypeCollection__loadCollection__collection_FQCNs', |
|
64 | - ['EventEspresso\core\domain\services\graphql\types'] |
|
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 | + TypeCollection::COLLECTION_NAME, |
|
59 | + // collection interface |
|
60 | + TypeCollection::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_TypeCollection__loadCollection__collection_FQCNs', |
|
64 | + ['EventEspresso\core\domain\services\graphql\types'] |
|
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 loadTypes() |
|
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 loadTypes() |
|
87 | + { |
|
88 | + $this->loadCollection(); |
|
89 | + return $this->loader->getCollection(); |
|
90 | + } |
|
91 | 91 | |
92 | 92 | |
93 | - /** |
|
94 | - * getIdentifier |
|
95 | - * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
96 | - * If no $identifier is supplied, then the fully qualified class name is used |
|
97 | - * |
|
98 | - * @param $object |
|
99 | - * @param mixed $identifier |
|
100 | - * @return bool |
|
101 | - */ |
|
102 | - public function getIdentifier($object, $identifier = null) |
|
103 | - { |
|
104 | - return ! empty($identifier) |
|
105 | - ? $identifier |
|
106 | - : get_class($object); |
|
107 | - } |
|
93 | + /** |
|
94 | + * getIdentifier |
|
95 | + * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
96 | + * If no $identifier is supplied, then the fully qualified class name is used |
|
97 | + * |
|
98 | + * @param $object |
|
99 | + * @param mixed $identifier |
|
100 | + * @return bool |
|
101 | + */ |
|
102 | + public function getIdentifier($object, $identifier = null) |
|
103 | + { |
|
104 | + return ! empty($identifier) |
|
105 | + ? $identifier |
|
106 | + : get_class($object); |
|
107 | + } |
|
108 | 108 | } |
@@ -68,7 +68,7 @@ |
||
68 | 68 | $inputFields = []; |
69 | 69 | foreach ($input->fields() as $field) { |
70 | 70 | $fieldName = $field->name(); |
71 | - $inputFields[ $fieldName ] = $field->toArray(); |
|
71 | + $inputFields[$fieldName] = $field->toArray(); |
|
72 | 72 | } |
73 | 73 | // Register the input type. |
74 | 74 | register_graphql_input_type( |
@@ -17,65 +17,65 @@ |
||
17 | 17 | */ |
18 | 18 | class InputsManager implements GQLManagerInterface |
19 | 19 | { |
20 | - /** |
|
21 | - * @var InputCollection|InputInterface[] $inputs |
|
22 | - */ |
|
23 | - private $inputs; |
|
20 | + /** |
|
21 | + * @var InputCollection|InputInterface[] $inputs |
|
22 | + */ |
|
23 | + private $inputs; |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * InputsManager constructor. |
|
28 | - * |
|
29 | - * @param InputCollection|InputInterface[] $inputs |
|
30 | - */ |
|
31 | - public function __construct(InputCollection $inputs) |
|
32 | - { |
|
33 | - $this->inputs = $inputs; |
|
34 | - } |
|
26 | + /** |
|
27 | + * InputsManager constructor. |
|
28 | + * |
|
29 | + * @param InputCollection|InputInterface[] $inputs |
|
30 | + */ |
|
31 | + public function __construct(InputCollection $inputs) |
|
32 | + { |
|
33 | + $this->inputs = $inputs; |
|
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->inputs->loadInputs(); |
|
45 | - add_action('graphql_register_types', [$this, 'configureInputs'], 9); |
|
46 | - } |
|
37 | + /** |
|
38 | + * @throws CollectionDetailsException |
|
39 | + * @throws CollectionLoaderException |
|
40 | + * @since 5.0.0.p |
|
41 | + */ |
|
42 | + public function init() |
|
43 | + { |
|
44 | + $this->inputs->loadInputs(); |
|
45 | + add_action('graphql_register_types', [$this, 'configureInputs'], 9); |
|
46 | + } |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * @since 5.0.0.p |
|
51 | - */ |
|
52 | - public function configureInputs() |
|
53 | - { |
|
54 | - // loop through the collection of inputs and register their fields |
|
55 | - foreach ($this->inputs as $input) { |
|
56 | - $this->registerInput($input); |
|
57 | - } |
|
58 | - } |
|
49 | + /** |
|
50 | + * @since 5.0.0.p |
|
51 | + */ |
|
52 | + public function configureInputs() |
|
53 | + { |
|
54 | + // loop through the collection of inputs and register their fields |
|
55 | + foreach ($this->inputs as $input) { |
|
56 | + $this->registerInput($input); |
|
57 | + } |
|
58 | + } |
|
59 | 59 | |
60 | 60 | |
61 | - /** |
|
62 | - * @param InputInterface $input |
|
63 | - * @since 5.0.0.p |
|
64 | - */ |
|
65 | - public function registerInput(InputInterface $input) |
|
66 | - { |
|
67 | - $inputFields = []; |
|
68 | - foreach ($input->fields() as $field) { |
|
69 | - $fieldName = $field->name(); |
|
70 | - $inputFields[ $fieldName ] = $field->toArray(); |
|
71 | - } |
|
72 | - // Register the input type. |
|
73 | - register_graphql_input_type( |
|
74 | - $input->name(), |
|
75 | - [ |
|
76 | - 'description' => $input->description(), |
|
77 | - 'fields' => $inputFields, |
|
78 | - ] |
|
79 | - ); |
|
80 | - } |
|
61 | + /** |
|
62 | + * @param InputInterface $input |
|
63 | + * @since 5.0.0.p |
|
64 | + */ |
|
65 | + public function registerInput(InputInterface $input) |
|
66 | + { |
|
67 | + $inputFields = []; |
|
68 | + foreach ($input->fields() as $field) { |
|
69 | + $fieldName = $field->name(); |
|
70 | + $inputFields[ $fieldName ] = $field->toArray(); |
|
71 | + } |
|
72 | + // Register the input type. |
|
73 | + register_graphql_input_type( |
|
74 | + $input->name(), |
|
75 | + [ |
|
76 | + 'description' => $input->description(), |
|
77 | + 'fields' => $inputFields, |
|
78 | + ] |
|
79 | + ); |
|
80 | + } |
|
81 | 81 | } |
@@ -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 name |
@@ -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 | } |
@@ -37,7 +37,7 @@ |
||
37 | 37 | if (get_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, true)) { |
38 | 38 | add_action( |
39 | 39 | 'shutdown', |
40 | - static function () { |
|
40 | + static function() { |
|
41 | 41 | flush_rewrite_rules(); |
42 | 42 | update_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, false); |
43 | 43 | } |
@@ -12,35 +12,35 @@ |
||
12 | 12 | */ |
13 | 13 | class RewriteRules |
14 | 14 | { |
15 | - const OPTION_KEY_FLUSH_REWRITE_RULES = 'ee_flush_rewrite_rules'; |
|
15 | + const OPTION_KEY_FLUSH_REWRITE_RULES = 'ee_flush_rewrite_rules'; |
|
16 | 16 | |
17 | 17 | |
18 | - /** |
|
19 | - * This will flush rewrite rules on demand. This actually gets called around wp init priority level 100. |
|
20 | - * |
|
21 | - * @return void |
|
22 | - */ |
|
23 | - public function flush() |
|
24 | - { |
|
25 | - update_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, true); |
|
26 | - } |
|
18 | + /** |
|
19 | + * This will flush rewrite rules on demand. This actually gets called around wp init priority level 100. |
|
20 | + * |
|
21 | + * @return void |
|
22 | + */ |
|
23 | + public function flush() |
|
24 | + { |
|
25 | + update_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, true); |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * This will flush rewrite rules on demand. This actually gets called around wp init priority level 100. |
|
31 | - * |
|
32 | - * @return void |
|
33 | - */ |
|
34 | - public function flushRewriteRules() |
|
35 | - { |
|
36 | - if (get_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, true)) { |
|
37 | - add_action( |
|
38 | - 'shutdown', |
|
39 | - static function () { |
|
40 | - flush_rewrite_rules(); |
|
41 | - update_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, false); |
|
42 | - } |
|
43 | - ); |
|
44 | - } |
|
45 | - } |
|
29 | + /** |
|
30 | + * This will flush rewrite rules on demand. This actually gets called around wp init priority level 100. |
|
31 | + * |
|
32 | + * @return void |
|
33 | + */ |
|
34 | + public function flushRewriteRules() |
|
35 | + { |
|
36 | + if (get_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, true)) { |
|
37 | + add_action( |
|
38 | + 'shutdown', |
|
39 | + static function () { |
|
40 | + flush_rewrite_rules(); |
|
41 | + update_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, false); |
|
42 | + } |
|
43 | + ); |
|
44 | + } |
|
45 | + } |
|
46 | 46 | } |
@@ -68,7 +68,7 @@ |
||
68 | 68 | */ |
69 | 69 | public function visit($model_objects_to_identify) |
70 | 70 | { |
71 | - if (! $this->isDiscovered()) { |
|
71 | + if ( ! $this->isDiscovered()) { |
|
72 | 72 | $this->discover(); |
73 | 73 | } |
74 | 74 | if ($this->isComplete()) { |
@@ -31,105 +31,105 @@ |
||
31 | 31 | */ |
32 | 32 | abstract class BaseNode |
33 | 33 | { |
34 | - /** |
|
35 | - * @var boolean |
|
36 | - */ |
|
37 | - protected $complete; |
|
34 | + /** |
|
35 | + * @var boolean |
|
36 | + */ |
|
37 | + protected $complete; |
|
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * @var array of model names we don't want to traverse |
|
42 | - */ |
|
43 | - protected $dont_traverse_models; |
|
40 | + /** |
|
41 | + * @var array of model names we don't want to traverse |
|
42 | + */ |
|
43 | + protected $dont_traverse_models; |
|
44 | 44 | |
45 | - /** |
|
46 | - * Whether this item has already been initialized |
|
47 | - */ |
|
48 | - abstract protected function isDiscovered(); |
|
45 | + /** |
|
46 | + * Whether this item has already been initialized |
|
47 | + */ |
|
48 | + abstract protected function isDiscovered(); |
|
49 | 49 | |
50 | - /** |
|
51 | - * Determines if the work is done yet or not. Requires you to have first discovered what work exists by calling |
|
52 | - * discover(). |
|
53 | - * @since 4.10.12.p |
|
54 | - * @return boolean |
|
55 | - */ |
|
56 | - abstract public function isComplete(); |
|
50 | + /** |
|
51 | + * Determines if the work is done yet or not. Requires you to have first discovered what work exists by calling |
|
52 | + * discover(). |
|
53 | + * @since 4.10.12.p |
|
54 | + * @return boolean |
|
55 | + */ |
|
56 | + abstract public function isComplete(); |
|
57 | 57 | |
58 | - /** |
|
59 | - * Discovers what work needs to be done to complete traversing this node and its children. |
|
60 | - * Note that this is separate from the constructor, so we can create child nodes without |
|
61 | - * discovering them immediately. |
|
62 | - * @since 4.10.12.p |
|
63 | - * @return mixed |
|
64 | - */ |
|
65 | - abstract protected function discover(); |
|
58 | + /** |
|
59 | + * Discovers what work needs to be done to complete traversing this node and its children. |
|
60 | + * Note that this is separate from the constructor, so we can create child nodes without |
|
61 | + * discovering them immediately. |
|
62 | + * @since 4.10.12.p |
|
63 | + * @return mixed |
|
64 | + */ |
|
65 | + abstract protected function discover(); |
|
66 | 66 | |
67 | - /** |
|
68 | - * Identifies model objects, up to the limit $model_objects_to_identify. |
|
69 | - * @since 4.10.12.p |
|
70 | - * @param int $model_objects_to_identify |
|
71 | - * @return int units of work done |
|
72 | - */ |
|
73 | - abstract protected function work($model_objects_to_identify); |
|
67 | + /** |
|
68 | + * Identifies model objects, up to the limit $model_objects_to_identify. |
|
69 | + * @since 4.10.12.p |
|
70 | + * @param int $model_objects_to_identify |
|
71 | + * @return int units of work done |
|
72 | + */ |
|
73 | + abstract protected function work($model_objects_to_identify); |
|
74 | 74 | |
75 | - /** |
|
76 | - * Shows the entity/relation node as an array. |
|
77 | - * @since 4.10.12.p |
|
78 | - * @return array |
|
79 | - */ |
|
80 | - abstract public function toArray(); |
|
75 | + /** |
|
76 | + * Shows the entity/relation node as an array. |
|
77 | + * @since 4.10.12.p |
|
78 | + * @return array |
|
79 | + */ |
|
80 | + abstract public function toArray(); |
|
81 | 81 | |
82 | - /** |
|
83 | - * Discovers how much work there is to do, double-checks the work isn't already finished, and then does the work. |
|
84 | - * Note: do not call when site is in maintenance mode level 2. |
|
85 | - * |
|
86 | - * @since 4.10.12.p |
|
87 | - * @param $model_objects_to_identify |
|
88 | - * @return int number of model objects we want to identify during this call. On subsequent calls we'll continue |
|
89 | - * where we left off. |
|
90 | - */ |
|
91 | - public function visit($model_objects_to_identify) |
|
92 | - { |
|
93 | - if (! $this->isDiscovered()) { |
|
94 | - $this->discover(); |
|
95 | - } |
|
96 | - if ($this->isComplete()) { |
|
97 | - return 0; |
|
98 | - } |
|
99 | - return $this->work($model_objects_to_identify); |
|
100 | - } |
|
82 | + /** |
|
83 | + * Discovers how much work there is to do, double-checks the work isn't already finished, and then does the work. |
|
84 | + * Note: do not call when site is in maintenance mode level 2. |
|
85 | + * |
|
86 | + * @since 4.10.12.p |
|
87 | + * @param $model_objects_to_identify |
|
88 | + * @return int number of model objects we want to identify during this call. On subsequent calls we'll continue |
|
89 | + * where we left off. |
|
90 | + */ |
|
91 | + public function visit($model_objects_to_identify) |
|
92 | + { |
|
93 | + if (! $this->isDiscovered()) { |
|
94 | + $this->discover(); |
|
95 | + } |
|
96 | + if ($this->isComplete()) { |
|
97 | + return 0; |
|
98 | + } |
|
99 | + return $this->work($model_objects_to_identify); |
|
100 | + } |
|
101 | 101 | |
102 | - /** |
|
103 | - * Gets the IDs of completely identified model objects that can be deleted. |
|
104 | - * @since 4.10.12.p |
|
105 | - * @return mixed |
|
106 | - */ |
|
107 | - abstract public function getIds(); |
|
102 | + /** |
|
103 | + * Gets the IDs of completely identified model objects that can be deleted. |
|
104 | + * @since 4.10.12.p |
|
105 | + * @return mixed |
|
106 | + */ |
|
107 | + abstract public function getIds(); |
|
108 | 108 | |
109 | - /** |
|
110 | - * Make sure we encode whether its complete or not, but don't use such a long name. |
|
111 | - * @since 4.10.12.p |
|
112 | - * @return array |
|
113 | - */ |
|
114 | - public function __sleep() |
|
115 | - { |
|
116 | - $this->c = $this->complete; |
|
117 | - $this->dtm = $this->dont_traverse_models; |
|
118 | - return [ |
|
119 | - 'c', |
|
120 | - 'dtm' |
|
121 | - ]; |
|
122 | - } |
|
109 | + /** |
|
110 | + * Make sure we encode whether its complete or not, but don't use such a long name. |
|
111 | + * @since 4.10.12.p |
|
112 | + * @return array |
|
113 | + */ |
|
114 | + public function __sleep() |
|
115 | + { |
|
116 | + $this->c = $this->complete; |
|
117 | + $this->dtm = $this->dont_traverse_models; |
|
118 | + return [ |
|
119 | + 'c', |
|
120 | + 'dtm' |
|
121 | + ]; |
|
122 | + } |
|
123 | 123 | |
124 | - /** |
|
125 | - * Use the dynamic property to set the "complete" property. |
|
126 | - * @since 4.10.12.p |
|
127 | - */ |
|
128 | - public function __wakeup() |
|
129 | - { |
|
130 | - $this->complete = $this->c; |
|
131 | - $this->dont_traverse_models = $this->dtm; |
|
132 | - } |
|
124 | + /** |
|
125 | + * Use the dynamic property to set the "complete" property. |
|
126 | + * @since 4.10.12.p |
|
127 | + */ |
|
128 | + public function __wakeup() |
|
129 | + { |
|
130 | + $this->complete = $this->c; |
|
131 | + $this->dont_traverse_models = $this->dtm; |
|
132 | + } |
|
133 | 133 | } |
134 | 134 | // End of file BaseNode.php |
135 | 135 | // Location: EventEspresso\core\services\orm\tree_traversal/BaseNode.php |