You are here

public function WSFieldLocalAction::getDerivativeDefinitions in Web Service Data 8

Same name and namespace in other branches
  1. 2.0.x modules/wsdata_field/src/Plugin/Derivative/WSFieldLocalAction.php \Drupal\wsdata_field\Plugin\Derivative\WSFieldLocalAction::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

modules/wsdata_field/src/Plugin/Derivative/WSFieldLocalAction.php, line 52

Class

WSFieldLocalAction
Provides local action definitions for all entity bundles.

Namespace

Drupal\wsdata_field\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_wsfield_config_add_{$entity_type_id}"] = [
        'route_name' => "wsdata_field.field_wsfield_config_add_{$entity_type_id}",
        'title' => $this
          ->t('Add web service field'),
        'appears_on' => [
          "entity.{$entity_type_id}.field_ui_fields",
        ],
      ];
    }
  }
  foreach ($this->derivatives as &$entry) {
    $entry += $base_plugin_definition;
  }
  return $this->derivatives;
}