1 | <?php |
||
16 | class Term_Relationships extends Module { |
||
17 | |||
18 | /** |
||
19 | * Max terms to return in one single query |
||
20 | * |
||
21 | * @access public |
||
22 | * |
||
23 | * @const int |
||
24 | */ |
||
25 | const QUERY_LIMIT = 1000; |
||
26 | |||
27 | /** |
||
28 | * Max mysql integer |
||
29 | * |
||
30 | * @access public |
||
31 | * |
||
32 | * @const int |
||
33 | */ |
||
34 | const MAX_INT = 999999999; |
||
35 | |||
36 | /** |
||
37 | * Sync module name. |
||
38 | * |
||
39 | * @access public |
||
40 | * |
||
41 | * @return string |
||
42 | */ |
||
43 | public function name() { |
||
46 | |||
47 | /** |
||
48 | * The id field in the database. |
||
49 | * |
||
50 | * @access public |
||
51 | * |
||
52 | * @return string |
||
53 | */ |
||
54 | public function id_field() { |
||
57 | |||
58 | /** |
||
59 | * The table in the database. |
||
60 | * |
||
61 | * @access public |
||
62 | * |
||
63 | * @return string |
||
64 | */ |
||
65 | public function table_name() { |
||
68 | |||
69 | /** |
||
70 | * Initialize term relationships action listeners for full sync. |
||
71 | * |
||
72 | * @access public |
||
73 | * |
||
74 | * @param callable $callable Action handler callable. |
||
75 | */ |
||
76 | public function init_full_sync_listeners( $callable ) { |
||
79 | |||
80 | /** |
||
81 | * Initialize the module in the sender. |
||
82 | * |
||
83 | * @access public |
||
84 | */ |
||
85 | public function init_before_send() { |
||
89 | |||
90 | /** |
||
91 | * Enqueue the term relationships actions for full sync. |
||
92 | * |
||
93 | * @access public |
||
94 | * |
||
95 | * @param array $config Full sync configuration for this sync module. |
||
96 | * @param int $max_items_to_enqueue Maximum number of items to enqueue. |
||
97 | * @param object $last_object_enqueued Last object enqueued. |
||
98 | * |
||
99 | * @return array Number of actions enqueued, and next module state. |
||
100 | * @todo This method has similarities with Automattic\Jetpack\Sync\Modules\Module::enqueue_all_ids_as_action. Refactor to keep DRY. |
||
101 | * @see Automattic\Jetpack\Sync\Modules\Module::enqueue_all_ids_as_action |
||
102 | */ |
||
103 | public function enqueue_full_sync_actions( $config, $max_items_to_enqueue, $last_object_enqueued ) { |
||
140 | |||
141 | /** |
||
142 | * |
||
143 | * Enqueue all $items within `jetpack_full_sync_term_relationships` actions. |
||
144 | * |
||
145 | * @param array $items Groups of objects to sync. |
||
146 | * @param array $previous_interval_end Last item enqueued. |
||
147 | * |
||
148 | * @return array Last enqueued object. |
||
149 | */ |
||
150 | public function bulk_enqueue_full_sync_term_relationships( $items, $previous_interval_end ) { |
||
157 | |||
158 | /** |
||
159 | * Retrieve an estimated number of actions that will be enqueued. |
||
160 | * |
||
161 | * @access public |
||
162 | * |
||
163 | * @param array $config Full sync configuration for this sync module. |
||
164 | * @return int Number of items yet to be enqueued. |
||
165 | */ |
||
166 | public function estimate_full_sync_actions( $config ) { |
||
176 | |||
177 | /** |
||
178 | * Use to calculate the new total. |
||
179 | * |
||
180 | * @param array $previous_enqueue_status |
||
181 | * |
||
182 | * @return int The number of items that we should be sending. |
||
183 | */ |
||
184 | public function recalculate_total( $previous_enqueue_status ) { |
||
194 | |||
195 | /** |
||
196 | * Helper function that counts the remaining items give the last object enqueued. |
||
197 | * |
||
198 | * @param array $last_object_enqueued Array containing the place where we last left of. |
||
199 | * |
||
200 | * @return int The number of term relationships that are left to enqueue. |
||
201 | */ |
||
202 | private function count_remaining_items( $last_object_enqueued ) { |
||
207 | |||
208 | /** |
||
209 | * Retrieve the actions that will be sent for this module during a full sync. |
||
210 | * |
||
211 | * @access public |
||
212 | * |
||
213 | * @return array Full sync actions of this module. |
||
214 | */ |
||
215 | public function get_full_sync_actions() { |
||
218 | |||
219 | /** |
||
220 | * Expand the term relationships within a hook before they are serialized and sent to the server. |
||
221 | * |
||
222 | * @access public |
||
223 | * |
||
224 | * @param array $args The hook parameters. |
||
225 | * @return array $args The expanded hook parameters. |
||
226 | */ |
||
227 | public function expand_term_relationships( $args ) { |
||
235 | } |
||
236 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.