1 | <?php |
||
17 | class VenueConnectionResolver extends AbstractConnectionResolver |
||
18 | { |
||
19 | // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
||
20 | public function get_loader_name() |
||
24 | |||
25 | /** |
||
26 | * @return EEM_Venue |
||
27 | * @throws EE_Error |
||
28 | * @throws InvalidArgumentException |
||
29 | * @throws InvalidDataTypeException |
||
30 | * @throws InvalidInterfaceException |
||
31 | */ |
||
32 | // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
||
33 | public function get_query() |
||
37 | |||
38 | |||
39 | /** |
||
40 | * Return an array of item IDs from the query |
||
41 | * |
||
42 | * @return array |
||
43 | */ |
||
44 | // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
||
45 | public function get_ids() |
||
51 | |||
52 | |||
53 | /** |
||
54 | * Determine whether the Query should execute. If it's determined that the query should |
||
55 | * not be run based on context such as, but not limited to, who the user is, where in the |
||
56 | * ResolveTree the Query is, the relation to the node the Query is connected to, etc |
||
57 | * Return false to prevent the query from executing. |
||
58 | * |
||
59 | * @return bool |
||
60 | */ |
||
61 | // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
||
62 | public function should_execute() |
||
70 | |||
71 | |||
72 | /** |
||
73 | * Here, we map the args from the input, then we make sure that we're only querying |
||
74 | * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
||
75 | * handle batch resolution of the posts. |
||
76 | * |
||
77 | * @return array |
||
78 | */ |
||
79 | // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
||
80 | public function get_query_args() |
||
136 | |||
137 | |||
138 | /** |
||
139 | * This sets up the "allowed" args, and translates the GraphQL-friendly keys to WP_Query |
||
140 | * friendly keys. There's probably a cleaner/more dynamic way to approach this, but |
||
141 | * this was quick. I'd be down to explore more dynamic ways to map this, but for |
||
142 | * now this gets the job done. |
||
143 | * |
||
144 | * @param array $query_args |
||
145 | * @return array |
||
146 | */ |
||
147 | // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
||
148 | public function sanitize_input_fields(array $query_args) |
||
160 | } |
||
161 |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: