You are here

public function ContentEntityDeriver::getDerivativeDefinitions in Search API 8

Gets the definition of all derivatives of a base plugin.

Parameters

array $base_plugin_definition: The definition array of the base plugin.

Return value

array An array of full derivative definitions keyed on derivative id.

Overrides DeriverBase::getDerivativeDefinitions

See also

getDerivativeDefinition()

File

src/Plugin/search_api/datasource/ContentEntityDeriver.php, line 76

Class

ContentEntityDeriver
Derives a datasource plugin definition for every content entity type.

Namespace

Drupal\search_api\Plugin\search_api\datasource

Code

public function getDerivativeDefinitions($base_plugin_definition) {
  if (!isset($this->derivatives)) {
    $plugin_derivatives = [];
    foreach ($this
      ->getEntityTypeManager()
      ->getDefinitions() as $entity_type => $entity_type_definition) {

      // We only support content entity types at the moment, since config
      // entities don't implement \Drupal\Core\TypedData\ComplexDataInterface.
      if ($entity_type_definition instanceof ContentEntityType) {
        $plugin_derivatives[$entity_type] = [
          'entity_type' => $entity_type,
          'label' => $entity_type_definition
            ->getLabel(),
          'description' => $this
            ->t('Provides %entity_type entities for indexing and searching.', [
            '%entity_type' => $entity_type_definition
              ->getLabel(),
          ]),
        ] + $base_plugin_definition;
      }
    }
    $this->derivatives = $plugin_derivatives;
  }
  return $this->derivatives;
}