You are here

public function SearchApiFieldTrait::getCombinedPropertyPath in Search API 8

Retrieves the combined property path of this field.

Return value

string The combined property path.

8 calls to SearchApiFieldTrait::getCombinedPropertyPath()
SearchApiEntity::getItems in src/Plugin/views/field/SearchApiEntity.php
Gets an array of items for the field.
SearchApiEntity::preRender in src/Plugin/views/field/SearchApiEntity.php
Runs before any fields are rendered.
SearchApiEntity::query in src/Plugin/views/field/SearchApiEntity.php
Add anything to the query that we might need to.
SearchApiEntityField::getParentPath in src/Plugin/views/field/SearchApiEntityField.php
Retrieves the property path of the parent property.
SearchApiFieldTrait::getDatasourceId in src/Plugin/views/field/SearchApiFieldTrait.php
Retrieves the ID of the datasource to which this field belongs.

... See full list

File

src/Plugin/views/field/SearchApiFieldTrait.php, line 1081

Class

SearchApiFieldTrait
Provides a trait to use for Search API Views field handlers.

Namespace

Drupal\search_api\Plugin\views\field

Code

public function getCombinedPropertyPath() {
  if (!isset($this->combinedPropertyPath)) {

    // Add the property path of any relationships used to arrive at this
    // field.
    $path = $this->realField;
    $relationships = $this->view->relationship;
    $relationship = $this;

    // While doing this, also note which relationships are configured to skip
    // access checks.
    $skip_access = [];
    while (!empty($relationship->options['relationship'])) {
      if (empty($relationships[$relationship->options['relationship']])) {
        break;
      }
      $relationship = $relationships[$relationship->options['relationship']];
      $path = $relationship->realField . ':' . $path;
      foreach ($skip_access as $i => $temp_path) {
        $skip_access[$i] = $relationship->realField . ':' . $temp_path;
      }
      if (!empty($relationship->options['skip_access'])) {
        $skip_access[] = $relationship->realField;
      }
    }
    $this->combinedPropertyPath = $path;

    // Set the field alias to the combined property path so that Views' code
    // can find the raw values, if necessary.
    $this->field_alias = $path;

    // Set the property paths that should skip access checks.
    $this->skipAccessChecks = array_fill_keys($skip_access, TRUE);
  }
  return $this->combinedPropertyPath;
}