You are here

public function ViewsParityRowEntityRow::getDerivativeDefinitions in Views Parity Row 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 DeriverInterface::getDerivativeDefinitions

See also

getDerivativeDefinition()

1 call to ViewsParityRowEntityRow::getDerivativeDefinitions()
ViewsParityRowEntityRow::getDerivativeDefinition in src/Plugin/Derivative/ViewsParityRowEntityRow.php
Gets the definition of a derivative plugin.

File

src/Plugin/Derivative/ViewsParityRowEntityRow.php, line 91

Class

ViewsParityRowEntityRow
Provides views row plugin definitions for all non-special entity types.

Namespace

Drupal\views_parity_row\Plugin\Derivative

Code

public function getDerivativeDefinitions($base_plugin_definition) {
  foreach ($this->entityTypeManager
    ->getDefinitions() as $entity_type_id => $entity_type) {

    // Just add support for entity types which have a views integration.
    if (($base_table = $entity_type
      ->getBaseTable()) && $this->viewsData
      ->get($base_table) && $this->entityTypeManager
      ->hasHandler($entity_type_id, 'view_builder')) {
      $this->derivatives[$entity_type_id] = [
        'id' => 'views_parity_row_entity:' . $entity_type_id,
        'provider' => 'views_parity_row',
        'title' => $entity_type
          ->getLabel() . ' (alternate)',
        'help' => t('Display the @label', [
          '@label' => $entity_type
            ->getLabel(),
        ]),
        'base' => [
          $entity_type
            ->getDataTable() ?: $entity_type
            ->getBaseTable(),
        ],
        'entity_type' => $entity_type_id,
        'display_types' => [
          'normal',
        ],
        'class' => $base_plugin_definition['class'],
      ];
    }
  }
  return $this->derivatives;
}