You are here

class ResultRow in Search API 8

A class representing a result row of a Search API-based view.

@property string search_api_id @property string search_api_datasource @property string search_api_language @property float search_api_relevance @property string|null search_api_excerpt

Hierarchy

Expanded class hierarchy of ResultRow

3 files declare their use of ResultRow
SearchApiQuery.php in src/Plugin/views/query/SearchApiQuery.php
ViewsFieldTraitTest.php in tests/src/Kernel/Views/ViewsFieldTraitTest.php
ViewsPropertyExtractionTest.php in tests/src/Kernel/Views/ViewsPropertyExtractionTest.php

File

src/Plugin/views/ResultRow.php, line 16

Namespace

Drupal\search_api\Plugin\views
View source
class ResultRow extends ViewsResultRow {

  /**
   * The lazy-loaded properties, as property names mapped to item methods.
   *
   * @var string[]
   */
  protected static $lazyLoad = [
    'search_api_id' => 'getId',
    'search_api_datasource' => 'getDatasourceId',
    'search_api_language' => 'getLanguage',
    'search_api_relevance' => 'getScore',
    'search_api_excerpt' => 'getExcerpt',
  ];

  // @codingStandardsIgnoreStart PSR2.Classes.PropertyDeclaration.Underscore

  /**
   * The Search API result item for this row.
   *
   * @var \Drupal\search_api\Item\ItemInterface
   */
  public $_item;

  /**
   * The original object for this row's result item, if retrieved.
   *
   * @var \Drupal\Core\TypedData\ComplexDataInterface|null
   */
  public $_object;

  /**
   * Extracted property values this result row, keyed by combined property path.
   *
   * @var \Drupal\Core\TypedData\TypedDataInterface[][]
   */
  public $_relationship_objects = [];

  /**
   * Array keeping track of the reference tree followed to obtain properties.
   *
   * Keyed by combined property path.
   *
   * @var int[][]
   */
  public $_relationship_parent_indices = [];

  // @codingStandardsIgnoreEnd

  /**
   * Implements the magic __isset() method to lazy-load certain properties.
   */
  public function __isset($name) {
    $properties = get_object_vars($this);
    return isset($properties[$name]) || isset(static::$lazyLoad[$name]) && $this->_item;
  }

  /**
   * Implements the magic __wakeup() method to lazy-load certain properties.
   */
  public function __get($name) {
    $properties = get_object_vars($this);
    if (array_key_exists($name, $properties)) {
      return $properties[$name];
    }
    if (isset(static::$lazyLoad[$name]) && $this->_item) {
      $method = static::$lazyLoad[$name];
      return $this->_item
        ->{$method}();
    }
    $class = get_class($this);
    trigger_error("Undefined property: {$class}::\${$name}");
    return NULL;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ResultRow::$index public property An incremental number which represents the row in the entire result.
ResultRow::$lazyLoad protected static property The lazy-loaded properties, as property names mapped to item methods.
ResultRow::$_entity public property The entity for this result.
ResultRow::$_item public property The Search API result item for this row.
ResultRow::$_object public property The original object for this row's result item, if retrieved.
ResultRow::$_relationship_entities public property An array of relationship entities.
ResultRow::$_relationship_objects public property Extracted property values this result row, keyed by combined property path.
ResultRow::$_relationship_parent_indices public property Array keeping track of the reference tree followed to obtain properties.
ResultRow::resetEntityData public function Resets the _entity and _relationship_entities properties.
ResultRow::__construct public function Constructs a ResultRow object.
ResultRow::__get public function Implements the magic __wakeup() method to lazy-load certain properties.
ResultRow::__isset public function Implements the magic __isset() method to lazy-load certain properties.