You are here

public function BundleField::getDerivativeDefinitions in Display Suite 8.4

Same name and namespace in other branches
  1. 8.2 src/Plugin/Derivative/BundleField.php \Drupal\ds\Plugin\Derivative\BundleField::getDerivativeDefinitions()
  2. 8.3 src/Plugin/Derivative/BundleField.php \Drupal\ds\Plugin\Derivative\BundleField::getDerivativeDefinitions()

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/Derivative/BundleField.php, line 62

Class

BundleField
Provides a derivative for bundle fields.

Namespace

Drupal\ds\Plugin\Derivative

Code

public function getDerivativeDefinitions($base_plugin_definition) {
  foreach ($this->entityTypeManager
    ->getDefinitions() as $entity_type_id => $entity_type) {
    $base_table = $entity_type
      ->getBaseTable();
    if ($entity_type
      ->get('field_ui_base_route') && !empty($base_table)) {
      $this->derivatives[$entity_type_id] = $base_plugin_definition;
      $this->derivatives[$entity_type_id] += [
        'provider' => $entity_type_id,
        'title' => 'Bundle name',
        'entity_type' => $entity_type_id,
      ];
    }
  }
  return $this->derivatives;
}