You are here

public function FieldsHelper::getNestedProperties in Search API 8

Retrieves a list of nested properties from a complex property.

Takes care of including bundle-specific properties for entity reference properties.

Parameters

\Drupal\Core\TypedData\ComplexDataDefinitionInterface $property: The base definition.

Return value

\Drupal\Core\TypedData\DataDefinitionInterface[] The nested properties, keyed by property name.

Overrides FieldsHelperInterface::getNestedProperties

1 call to FieldsHelper::getNestedProperties()
FieldsHelper::retrieveNestedProperty in src/Utility/FieldsHelper.php
Retrieves a nested property from a list of properties.

File

src/Utility/FieldsHelper.php, line 334

Class

FieldsHelper
Provides helper methods for dealing with Search API fields and properties.

Namespace

Drupal\search_api\Utility

Code

public function getNestedProperties(ComplexDataDefinitionInterface $property) {
  $nestedProperties = $property
    ->getPropertyDefinitions();
  if ($property instanceof EntityDataDefinitionInterface) {
    $entity_type_id = $property
      ->getEntityTypeId();
    $is_content_type = $this
      ->isContentEntityType($entity_type_id);
    if ($is_content_type) {
      $bundles = $property
        ->getBundles() ?: array_keys($this->entityBundleInfo
        ->getBundleInfo($entity_type_id));
      foreach ($bundles as $bundle) {
        $bundleProperties = $this->entityFieldManager
          ->getFieldDefinitions($entity_type_id, $bundle);
        $nestedProperties += $bundleProperties;
      }
    }
  }
  return $nestedProperties;
}