function FieldUiLocalAction::getDerivativeDefinitions

Same name and namespace in other branches
  1. 9 core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalAction.php \Drupal\field_ui\Plugin\Derivative\FieldUiLocalAction::getDerivativeDefinitions()
  2. 8.9.x core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalAction.php \Drupal\field_ui\Plugin\Derivative\FieldUiLocalAction::getDerivativeDefinitions()
  3. 11.x core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalAction.php \Drupal\field_ui\Plugin\Derivative\FieldUiLocalAction::getDerivativeDefinitions()

Overrides DeriverBase::getDerivativeDefinitions

File

core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalAction.php, line 58

Class

FieldUiLocalAction
Provides local action definitions for all entity bundles.

Namespace

Drupal\field_ui\Plugin\Derivative

Code

public function getDerivativeDefinitions($base_plugin_definition) {
  $this->derivatives = [];
  foreach ($this->entityTypeManager
    ->getDefinitions() as $entity_type_id => $entity_type) {
    if ($entity_type->get('field_ui_base_route')) {
      $this->derivatives["field_storage_config_add_{$entity_type_id}"] = [
        'route_name' => "field_ui.field_storage_config_add_{$entity_type_id}",
        'title' => $this->t('Create a new field'),
        'appears_on' => [
          "entity.{$entity_type_id}.field_ui_fields",
        ],
      ];
      $this->derivatives["field_storage_config_reuse_{$entity_type_id}"] = [
        'route_name' => "field_ui.field_storage_config_reuse_{$entity_type_id}",
        'title' => $this->t('Re-use an existing field'),
        'appears_on' => [
          "entity.{$entity_type_id}.field_ui_fields",
        ],
        'options' => [
          'attributes' => [
            'class' => [
              'use-ajax',
              'button',
            ],
            'data-dialog-type' => 'modal',
            'data-dialog-options' => Json::encode([
              'width' => '85vw',
            ]),
          ],
        ],
      ];
    }
  }
  foreach ($this->derivatives as &$entry) {
    $entry += $base_plugin_definition;
  }
  return $this->derivatives;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.