You are here

function facetapi_get_widgets in Facet API 7.2

Same name and namespace in other branches
  1. 6.3 facetapi.admin.inc \facetapi_get_widgets()
  2. 7 facetapi.admin.inc \facetapi_get_widgets()

Returns the widget plugin definitions available to the facet.

All widget plugins are checked against their requirements. Only widgets that pass all requirements are returned by this function.

Parameters

array $realm: The realm definition.

array $facet: The facet definition.

Return value

array An array of available widget plugins.

1 call to facetapi_get_widgets()
facetapi_facet_display_form in ./facetapi.admin.inc
Form constructor for the facet display settings form.

File

./facetapi.admin.inc, line 324
Admin page callbacks for the Facet API module.

Code

function facetapi_get_widgets(array $realm, array $facet) {
  $plugins = array();

  // Iterates over all defined plugins, initializes requirements.
  foreach (ctools_get_plugins('facetapi', 'widgets') as $id => $plugin) {
    $plugin['handler'] += array(
      'requirements' => array(
        'facetapi_requirement_realm_property' => array(
          'element type' => 'links',
        ),
      ),
      'requirements operator' => 'AND',
    );

    // Checks requirements, only saves widgets that pass all requirements.
    if (facetapi_check_requirements($plugin['handler']['requirements'], $realm, $facet, $plugin['handler']['requirements operator'])) {
      $plugins[$id] = $plugin;
    }
  }
  return $plugins;
}