1 | <?php |
||
19 | abstract class AbstractConnectionResolver extends WPGraphQLConnectionResolver |
||
20 | { |
||
21 | |||
22 | |||
23 | /** |
||
24 | * @var Utilities |
||
25 | */ |
||
26 | private $utilities; |
||
27 | |||
28 | |||
29 | /** |
||
30 | * @return Utilities |
||
31 | */ |
||
32 | public function getUtilities() |
||
39 | |||
40 | /** |
||
41 | * Determine whether the Query should execute. If it's determined that the query should |
||
42 | * not be run based on context such as, but not limited to, who the user is, where in the |
||
43 | * ResolveTree the Query is, the relation to the node the Query is connected to, etc |
||
44 | * Return false to prevent the query from executing. |
||
45 | * |
||
46 | * @return bool |
||
47 | */ |
||
48 | // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
||
49 | public function should_execute() |
||
53 | |||
54 | /** |
||
55 | * Set limit the highest value of first and last, with a (filterable) max of 100 |
||
56 | * |
||
57 | * @return array |
||
58 | */ |
||
59 | protected function getLimit() |
||
71 | |||
72 | /** |
||
73 | * Get_amount_requested |
||
74 | * |
||
75 | * This checks the $args to determine the amount requested |
||
76 | * |
||
77 | * @return int|null |
||
78 | * @throws Exception |
||
79 | */ |
||
80 | // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
||
81 | public function get_amount_requested() |
||
95 | |||
96 | /** |
||
97 | * Determine whether or not the the offset is valid, i.e the entity corresponding to the |
||
98 | * offset exists. Offset is equivalent to entity ID. So this function is equivalent to |
||
99 | * checking if the entity with the given ID exists. |
||
100 | * |
||
101 | * @access public |
||
102 | * |
||
103 | * @param int $offset The ID of the node used for the cursor offset |
||
104 | * |
||
105 | * @return bool |
||
106 | */ |
||
107 | // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
||
108 | public function is_valid_offset($offset) |
||
114 | |||
115 | /** |
||
116 | * Validates Model. |
||
117 | * |
||
118 | * @param array $entity Entity node. |
||
119 | * |
||
120 | * @return bool |
||
121 | */ |
||
122 | // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
||
123 | protected function is_valid_model($entity) |
||
127 | |||
128 | |||
129 | /** |
||
130 | * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
||
131 | * friendly keys. |
||
132 | * |
||
133 | * @param array $query_args |
||
134 | * @param array $where_params |
||
135 | * @param string $primary_key |
||
136 | * @return array |
||
137 | */ |
||
138 | protected function mapOrderbyInputArgs(array $query_args, array $where_params, $primary_key) |
||
156 | |||
157 | |||
158 | /** |
||
159 | * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
||
160 | * friendly keys. |
||
161 | * |
||
162 | * @param array $where_args |
||
163 | * @param array $arg_mapping |
||
164 | * @param array $id_fields The fields to convert from global IDs to DB IDs. |
||
165 | * @return array |
||
166 | */ |
||
167 | protected function sanitizeWhereArgsForInputFields(array $where_args, array $arg_mapping, array $id_fields) |
||
172 | |||
173 | |||
174 | /** |
||
175 | * This returns the sanitized "search" keywords from where_args |
||
176 | * |
||
177 | * @param array $where_args |
||
178 | * @return string |
||
179 | */ |
||
180 | protected function getSearchKeywords(array $where_args) |
||
188 | } |
||
189 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
integer
values, zero is a special case, in particular the following results might be unexpected: