You are here

abstract class FacetapiEmptyBehavior in Facet API 6.3

Same name and namespace in other branches
  1. 7.2 plugins/facetapi/empty_behavior.inc \FacetapiEmptyBehavior
  2. 7 plugins/facetapi/empty_behavior.inc \FacetapiEmptyBehavior

Abstract class implemented by all empty behavior plugins.

Hierarchy

Expanded class hierarchy of FacetapiEmptyBehavior

1 string reference to 'FacetapiEmptyBehavior'
facetapi_facetapi_empty_behaviors in ./facetapi.facetapi.inc
Implements hook_facetapi_empty_behaviors().

File

plugins/facetapi/empty_behavior.inc, line 11
Base class for empty behaviors.

View source
abstract class FacetapiEmptyBehavior {

  /**
   * The machine readable name of facet configuration.
   *
   * @var string
   */
  protected $configName;

  /**
   * An array of facet settings.
   *
   * @var array
   */
  protected $settings;

  /**
   * Initializes settings.
   */
  public function __construct(stdClass $settings) {
    $this->configName = $settings->name;
    $this->settings = $settings->settings;
    $this->settings += $this
      ->getDefaultSettings();
  }

  /**
   * Executes the abstract class behavior.
   *
   * @return
   *   The element's render array.
   */
  public abstract function execute();

  /**
   * Allows for backend specific overrides to the settings form.
   */
  public function settingsForm(&$form, &$form_state) {

    // Nothing to do...
  }

  /**
   * Returns an array of default settings.
   */
  public function getDefaultSettings() {
    return array();
  }

  /**
   * Helper function for translating strings.
   *
   * @param string $key
   *   The array key of the element being translated.
   * @param string $string
   *   The string being translated.
   *
   * @return
   *   The translated string.
   *
   * @see facetapi_translate_string()
   */
  public function translate($key, $string) {
    $config_name = preg_replace('@[^a-zA-Z0-9]@', '_', $this->configName);
    $name = 'facetapi:' . $config_name . ':empty_text:' . $key;
    return facetapi_translate_string($name, $string);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FacetapiEmptyBehavior::$configName protected property The machine readable name of facet configuration.
FacetapiEmptyBehavior::$settings protected property An array of facet settings.
FacetapiEmptyBehavior::execute abstract public function Executes the abstract class behavior. 2
FacetapiEmptyBehavior::getDefaultSettings public function Returns an array of default settings. 1
FacetapiEmptyBehavior::settingsForm public function Allows for backend specific overrides to the settings form. 1
FacetapiEmptyBehavior::translate public function Helper function for translating strings.
FacetapiEmptyBehavior::__construct public function Initializes settings. 1