You are here

class FacetapiEmptyBehaviorAjaxFacets in Ajax facets 7.3

Empty behavior plugin that displays markup, usually just some text.

This plugin allows administrators to display markup filtered through text formats as the contents of a facet when it has no items.

Hierarchy

Expanded class hierarchy of FacetapiEmptyBehaviorAjaxFacets

1 string reference to 'FacetapiEmptyBehaviorAjaxFacets'
ajax_facets_facetapi_empty_behaviors in ./ajax_facets.module
Implements hook_facetapi_empty_behaviors().

File

plugins/facetapi/empty_behavior_ajax_facets.inc, line 14
The empty_text empty behavior class.

View source
class FacetapiEmptyBehaviorAjaxFacets extends FacetapiEmptyBehavior {

  /**
   * A boolean flagging whether the input format is set, FALSE means it is
   * being pulled from FacetapiEmptyBehavior::getDefaultSettings().
   *
   * @var bool
   */
  protected $formatSet = FALSE;

  /**
   * Overrides FacetapiEmptyBehavior::__construct().
   *
   * Checks if a format was selected, calls parent's constructor.
   */
  public function __construct(stdClass $settings) {
    if (isset($settings->settings['empty_text']['format'])) {
      $this->formatSet = TRUE;
    }
    parent::__construct($settings);
  }

  /**
   * Implements FacetapiEmptyBehavior::execute().
   */
  public function execute() {
    $class1 = str_replace('facetapi_', '', $this->settings['widget']);
    $class1 = drupal_html_class("facet-wrapper-{$class1}");

    // This class should match facet widget build "id" attribute.
    // Explode configName to searcher, realm name and facet name,
    // and create the class the same way as "id" for widget.
    // @see FacetapiWidget::init()
    $facet_widget_build = explode(':', $this->configName, 3);

    // We shouldn't use drupal_html_id because id shouldn't be changed.
    $id = drupal_html_class("facetapi-facet-{$facet_widget_build[0]}-{$facet_widget_build[1]}-{$facet_widget_build[2]}-wrapper");
    $class2 = drupal_html_class("facetapi-facet-{$facet_widget_build[0]}-{$facet_widget_build[1]}-{$facet_widget_build[2]}");
    $wrapper = '<div class="ajax-facets-empty-behavior ' . $class1 . ' ' . $class2 . '" id="' . $id . '"></div>';
    return [
      '#markup' => $wrapper,
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FacetapiEmptyBehaviorAjaxFacets::$formatSet protected property A boolean flagging whether the input format is set, FALSE means it is being pulled from FacetapiEmptyBehavior::getDefaultSettings().
FacetapiEmptyBehaviorAjaxFacets::execute public function Implements FacetapiEmptyBehavior::execute().
FacetapiEmptyBehaviorAjaxFacets::__construct public function Overrides FacetapiEmptyBehavior::__construct().