PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.8.16
VikBooking Hotel Booking Engine & PMS v1.8.16
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
← All changes | admin/helpers/admin_widget.php +78 -4 1.6.6 → 1.8.16 View file →
@@ -121,8 +121,44 @@
121 121 $this->options = VBOMultitaskOptions::getInstance();
122 122 }
123 123
124 124 /**
125 + * Tells if the admin-widget can be installed on the current environment.
126 + *
127 + * @return bool
128 + *
129 + * @since 1.16.10 (J) - 1.6.10 (WP)
130 + */
131 + public function preflight()
132 + {
133 + /**
134 + * Trigger event to let external plugins to choose whether this widget should be supported or not.
135 + *
136 + * @param string $widgetId The widget identifier.
137 + *
138 + * @return bool False to drop support to this widget.
139 + *
140 + * @since 1.18 (J) - 1.8 (WP)
141 + */
142 + $results = VBOFactory::getPlatform()->getDispatcher()->filter('onPreflightAdminWidget', [$this->widgetId]);
143 +
144 + // supported only in case none of the plugins attached to this event returned FALSE
145 + return !in_array(false, $results, true);
146 + }
147 +
148 + /**
149 + * Returns the admin-widget priority for a custom ordering.
150 + *
151 + * @return int
152 + *
153 + * @since 1.16.10 (J) - 1.6.10 (WP)
154 + */
155 + public function getPriority()
156 + {
157 + return 10;
158 + }
159 +
160 + /**
125 161 * Gets the name of the current widget.
126 162 *
127 163 * @return string the widget name.
128 164 */
@@ -220,9 +256,9 @@
220 256 * Extending classes needing to periodically watch for new events and capable
221 257 * of emitting browser notifications, can override this method. The last data
222 258 * to watch should be returned during the preloading. To be used with list().
223 259 *
224 - * @param VBONotificationWatchdata $watch_data the preloaded watch-data object.
260 + * @param ?VBONotificationWatchdata $watch_data the preloaded watch-data object.
225 261 *
226 262 * @return array data object to watch next and notifications array.
227 263 *
228 264 * @see preload()
@@ -228,9 +264,9 @@
228 264 * @see preload()
229 265 *
230 266 * @since 1.15.0 (J) - 1.5.0 (WP)
231 267 */
232 - public function getNotifications(VBONotificationWatchdata $watch_data = null)
268 + public function getNotifications(?VBONotificationWatchdata $watch_data = null)
233 269 {
234 270 $watch_next = null;
235 271 $notifications = null;
236 272
@@ -237,8 +273,26 @@
237 273 return [$watch_next, $notifications];
238 274 }
239 275
240 276 /**
277 + * Default method to return a list of browser events to dispatch.
278 + * Extending classes needing to periodically watch for new events
279 + * and capable of emitting browser events, can override this method.
280 + *
281 + * @param ?VBONotificationWatchdata $watch_data the preloaded watch-data object.
282 + *
283 + * @return array list of browser events to emit.
284 + *
285 + * @see preload()
286 + *
287 + * @since 1.16.8 (J) - 1.6.8 (WP)
288 + */
289 + public function getNotificationEvents(?VBONotificationWatchdata $watch_data = null)
290 + {
291 + return [];
292 + }
293 +
294 + /**
241 295 * Binds the widget options at runtime when multitask data is available.
242 296 * Options live on a separate layer than regular multitask data.
243 297 *
244 298 * @param VBOMultitaskData|VBOMultitaskOptions|array|object $options options to bind.
@@ -322,16 +376,36 @@
322 376 return $this->options->get($key, $default);
323 377 }
324 378
325 379 /**
380 + * Returns an associative array with the current widget details.
381 + * Method's visibility should never change from public, because
382 + * the controller may call it, and widgets may override it.
383 + *
384 + * @return array
385 + *
386 + * @since 1.16.7 (J) - 1.6.7 (WP)
387 + */
388 + public function getWidgetDetails()
389 + {
390 + return [
391 + 'id' => $this->getIdentifier(),
392 + 'name' => $this->getName(),
393 + 'descr' => $this->getDescription(),
394 + 'icon' => $this->getIcon(),
395 + 'style' => $this->getStyleName(),
396 + ];
397 + }
398 +
399 + /**
326 400 * Extending Classes should define this method to render the actual
327 401 * output of the admin widget. Multitask data can be passed along.
328 402 *
329 - * @param VBOMultitaskData $data optional multitask data object.
403 + * @param ?VBOMultitaskData $data optional multitask data object.
330 404 *
331 405 * @since 1.15.0 (J) - 1.5.0 (WP) type hint added for $data argument.
332 406 */
333 - abstract public function render(VBOMultitaskData $data = null);
407 + abstract public function render(?VBOMultitaskData $data = null);
334 408
335 409 /**
336 410 * Returns the default icon for a widget.
337 411 *