You are here

function facetapi_widgets_filter in Facet API 6

Filters widgets by invoking their access callbacks.

Parameters

$widget: An array containing the widget information.

Return value

A boolean flagging whether the item should be kept in the array.

1 string reference to 'facetapi_widgets_filter'
facetapi_widgets_get in ./facetapi.module
Invokes hook_facetapi_widget_info(), returns all defined widgets.

File

./facetapi.module, line 562
An abstracted facet API that can be used by various search backens.

Code

function facetapi_widgets_filter(array $widget) {

  // Captures variables for code readability.
  $realm_reqs = $widget['variables']['realm']['widget requirements'];
  $facet_reqs = $widget['variables']['facet']['widget requirements'];

  // Gets what requirements we have, what's required, which ones are common.
  $reqs = array_unique(array_merge($realm_reqs, $facet_reqs));
  $required = array_unique($widget['widget requirements']);
  $common = array_intersect($reqs, $required);

  // Makes sure all requirements are met.
  sort($required);
  sort($common);
  return $common == $required;
}