You are here

class Result in Facets 8

The default implementation of the result interfaces.

Hierarchy

Expanded class hierarchy of Result

39 files declare their use of Result
ActiveWidgetOrderProcessor.php in src/Plugin/facets/processor/ActiveWidgetOrderProcessor.php
ActiveWidgetOrderProcessorTest.php in tests/src/Unit/Plugin/processor/ActiveWidgetOrderProcessorTest.php
BooleanItemProcessorTest.php in tests/src/Unit/Plugin/processor/BooleanItemProcessorTest.php
CountLimitProcessorTest.php in tests/src/Unit/Plugin/processor/CountLimitProcessorTest.php
CountWidgetOrderProcessor.php in src/Plugin/facets/processor/CountWidgetOrderProcessor.php

... See full list

File

src/Result/Result.php, line 11

Namespace

Drupal\facets\Result
View source
class Result implements ResultInterface {

  /**
   * The facet related to the result.
   *
   * @var \Drupal\facets\FacetInterface
   */
  protected $facet;

  /**
   * The facet value.
   *
   * @var string
   */
  protected $displayValue;

  /**
   * The raw facet value.
   *
   * @var string
   */
  protected $rawValue;

  /**
   * The facet count.
   *
   * @var int
   */
  protected $count = 0;

  /**
   * The Url object.
   *
   * @var \Drupal\Core\Url
   */
  protected $url;

  /**
   * Is this a selected value or not.
   *
   * @var bool
   */
  protected $active = FALSE;

  /**
   * Children results.
   *
   * @var \Drupal\facets\Result\ResultInterface[]
   */
  protected $children = [];

  /**
   * Constructs a new result value object.
   *
   * @param \Drupal\facets\FacetInterface $facet
   *   The facet related to the result.
   * @param mixed $raw_value
   *   The raw value.
   * @param mixed $display_value
   *   The formatted value.
   * @param int $count
   *   The amount of items.
   */
  public function __construct(FacetInterface $facet, $raw_value, $display_value, $count) {
    $this->facet = $facet;
    $this->rawValue = $raw_value;
    $this->displayValue = $display_value;
    $this->count = (int) $count;
  }

  /**
   * {@inheritdoc}
   */
  public function getDisplayValue() {
    return $this->displayValue;
  }

  /**
   * {@inheritdoc}
   */
  public function getRawValue() {
    return $this->rawValue;
  }

  /**
   * {@inheritdoc}
   */
  public function getCount() {
    return $this->count;
  }

  /**
   * {@inheritdoc}
   */
  public function setCount($count) {
    $this->count = (int) $count;
  }

  /**
   * {@inheritdoc}
   */
  public function getUrl() {
    return $this->url;
  }

  /**
   * {@inheritdoc}
   */
  public function setUrl(Url $url) {
    $this->url = $url;
  }

  /**
   * {@inheritdoc}
   */
  public function setActiveState($active) {
    $this->active = $active;
  }

  /**
   * {@inheritdoc}
   */
  public function isActive() {
    return $this->active;
  }

  /**
   * {@inheritdoc}
   */
  public function setDisplayValue($display_value) {
    $this->displayValue = $display_value;
  }

  /**
   * {@inheritdoc}
   */
  public function setChildren(array $children) {
    $this->children = $children;
  }

  /**
   * {@inheritdoc}
   */
  public function getChildren() {
    return $this->children;
  }

  /**
   * Returns true if the value has active children(selected).
   *
   * @return bool
   *   A boolean indicating the active state of children.
   */
  public function hasActiveChildren() {
    foreach ($this
      ->getChildren() as $child) {
      if ($child
        ->isActive() || $child
        ->hasActiveChildren()) {
        return TRUE;
      }
    }
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function getFacet() {
    return $this->facet;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Result::$active protected property Is this a selected value or not.
Result::$children protected property Children results.
Result::$count protected property The facet count.
Result::$displayValue protected property The facet value.
Result::$facet protected property The facet related to the result.
Result::$rawValue protected property The raw facet value.
Result::$url protected property The Url object.
Result::getChildren public function Returns children results. Overrides ResultInterface::getChildren
Result::getCount public function Returns the count for the result. Overrides ResultInterface::getCount
Result::getDisplayValue public function Returns the display value as present in the index. Overrides ResultInterface::getDisplayValue
Result::getFacet public function Returns the facet related to the result. Overrides ResultInterface::getFacet
Result::getRawValue public function Returns the raw value as present in the index. Overrides ResultInterface::getRawValue
Result::getUrl public function Returns the url. Overrides ResultInterface::getUrl
Result::hasActiveChildren public function Returns true if the value has active children(selected). Overrides ResultInterface::hasActiveChildren
Result::isActive public function Returns true if the value is active (selected). Overrides ResultInterface::isActive
Result::setActiveState public function Indicates that the value is active (selected). Overrides ResultInterface::setActiveState
Result::setChildren public function Sets children results. Overrides ResultInterface::setChildren
Result::setCount public function Sets the count for the result. Overrides ResultInterface::setCount
Result::setDisplayValue public function Overrides the display value of a result. Overrides ResultInterface::setDisplayValue
Result::setUrl public function Sets the url. Overrides ResultInterface::setUrl
Result::__construct public function Constructs a new result value object.