1 | <?php |
||
8 | class SchemaBuilder { |
||
9 | |||
10 | /** |
||
11 | * Static cache of type system plugin instances. |
||
12 | * |
||
13 | * @var \Drupal\graphql\Plugin\GraphQL\TypeSystemPluginInterface |
||
14 | */ |
||
15 | protected $instances = []; |
||
16 | |||
17 | /** |
||
18 | * Static cache of plugin definitions. |
||
19 | * |
||
20 | * @var array |
||
21 | */ |
||
22 | protected $definitions; |
||
23 | |||
24 | /** |
||
25 | * List of registered type system plugin managers. |
||
26 | * |
||
27 | * @var \Drupal\Component\Plugin\PluginManagerInterface[] |
||
28 | */ |
||
29 | protected $pluginManagers; |
||
30 | |||
31 | /** |
||
32 | * SchemaBuilder constructor. |
||
33 | * |
||
34 | * @param \Drupal\Component\Plugin\PluginManagerInterface[] $pluginManagers |
||
35 | * List of type system plugin managers. |
||
36 | */ |
||
37 | public function __construct(array $pluginManagers) { |
||
40 | |||
41 | /** |
||
42 | * Returns the list of sorted plugin definitions. |
||
43 | * |
||
44 | * @return array |
||
45 | * The list of sorted plugin definitions. |
||
46 | */ |
||
47 | protected function getDefinitions() { |
||
67 | |||
68 | /** |
||
69 | * Search for a specific plugin. |
||
70 | * |
||
71 | * @param callable $selector |
||
72 | * A selector callable that will be used to array_filter the list of |
||
73 | * plugin definitions. |
||
74 | * @param integer[] $types |
||
75 | * A list of type constants. |
||
76 | * @param bool $invert |
||
77 | * Invert the selector result. |
||
78 | * |
||
79 | * @return object[] |
||
80 | * The list of matching plugin instances, keyed by name. |
||
81 | */ |
||
82 | public function find(callable $selector, array $types, $invert = FALSE) { |
||
99 | |||
100 | /** |
||
101 | * Search for a specific plugin. |
||
102 | * |
||
103 | * @param string $name |
||
104 | * The specific plugin name. |
||
105 | * @param integer[] $types |
||
106 | * A list of type constants. |
||
107 | * |
||
108 | * @return object |
||
109 | * The highest weighted plugin with a specific name. |
||
110 | */ |
||
111 | public function findByName($name, array $types) { |
||
122 | |||
123 | /** |
||
124 | * Find the matching GraphQL data type for a Drupal type data identifier. |
||
125 | * |
||
126 | * Respects type chains. `entity:node:article` should return the |
||
127 | * `NodeArticle` type if it is exposed or fall back to either `Node` or even |
||
128 | * `Entity` otherwise. |
||
129 | * |
||
130 | * @param string $dataType |
||
131 | * The typed data identifier. E.g. `string` or `entity:node:article`. |
||
132 | * @param string[] $types |
||
133 | * A list of type constants. |
||
134 | * |
||
135 | * @return object |
||
136 | * The matching type with the highest weight. |
||
137 | */ |
||
138 | public function findByDataType($dataType, array $types = [ |
||
162 | |||
163 | /** |
||
164 | * Retrieve all mutations. |
||
165 | * |
||
166 | * @return object[] |
||
167 | * The list of mutation plugins. |
||
168 | */ |
||
169 | public function getMutations() { |
||
174 | |||
175 | /** |
||
176 | * Retrieve all fields that are not associated with a specific type. |
||
177 | * |
||
178 | * @return object[] |
||
179 | * The list root field plugins. |
||
180 | */ |
||
181 | public function getRootFields() { |
||
193 | |||
194 | /** |
||
195 | * Creates a type system plugin instance for a given plugin manager. |
||
196 | * |
||
197 | * @param \Drupal\Component\Plugin\PluginManagerInterface $manager |
||
198 | * The plugin manager responsible for creation of the plugin instance. |
||
199 | * @param $pluginType |
||
200 | * The plugin type. |
||
201 | * @param $pluginId |
||
202 | * The plugin id. |
||
203 | * |
||
204 | * @return \Drupal\graphql\Plugin\GraphQL\TypeSystemPluginInterface |
||
205 | * The created plugin instance. |
||
206 | */ |
||
207 | protected function getInstance(PluginManagerInterface $manager, $pluginType, $pluginId) { |
||
229 | } |
||
230 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.