You are here

public function FacetapiDependencyBundle::execute in Facet API 6.3

Same name and namespace in other branches
  1. 7.2 plugins/facetapi/dependency_bundle.inc \FacetapiDependencyBundle::execute()
  2. 7 plugins/facetapi/dependency_bundle.inc \FacetapiDependencyBundle::execute()

Executes the dependency check.

Overrides FacetapiDependency::execute

File

plugins/facetapi/dependency_bundle.inc, line 16
Performs a dependency check against the passed bundle.

Class

FacetapiDependencyBundle
Adds a dependency on bundle.

Code

public function execute() {
  switch ($this->settings['bundle']) {
    case 'referenced':

      // Check match between the field's bundles and active bundle items.
      foreach ($this
        ->getEnabledBundleFacets() as $facet) {
        foreach ($this->activeItems[$facet['name']] as $entity => $facet) {
          $field_info = content_fields($this->facet['field api name'], $entity);
          if ($field_info) {
            return NULL;
          }
        }
      }

      // There was no match.
      return FALSE;
    case 'selected':

      // Check match between selected bundles and active bundle items.
      $selected = array_filter($this->settings['bundle_selected']);
      foreach ($this
        ->getEnabledBundleFacets() as $facet) {
        if (array_intersect_key($this->activeItems[$facet['name']], $selected)) {
          return NULL;
        }
      }

      // There was no match.
      return FALSE;
  }
}