class FieldToolsLocalTask in Field tools 8
Provides local task definitions for all entity bundles.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\field_tools\Plugin\Derivative\FieldToolsLocalTask implements ContainerDeriverInterface uses StringTranslationTrait
Expanded class hierarchy of FieldToolsLocalTask
1 string reference to 'FieldToolsLocalTask'
File
- src/
Plugin/ Derivative/ FieldToolsLocalTask.php, line 16
Namespace
Drupal\field_tools\Plugin\DerivativeView source
class FieldToolsLocalTask extends DeriverBase implements ContainerDeriverInterface {
use StringTranslationTrait;
/**
* The route provider.
*
* @var \Drupal\Core\Routing\RouteProviderInterface
*/
protected $routeProvider;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Creates an FieldToolsLocalTask object.
*
* @param \Drupal\Core\Routing\RouteProviderInterface $route_provider
* The route provider.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The translation manager.
*/
public function __construct(RouteProviderInterface $route_provider, EntityTypeManagerInterface $entity_type_manager, TranslationInterface $string_translation) {
$this->routeProvider = $route_provider;
$this->entityTypeManager = $entity_type_manager;
$this->stringTranslation = $string_translation;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('router.route_provider'), $container
->get('entity_type.manager'), $container
->get('string_translation'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$this->derivatives = array();
foreach ($this->entityTypeManager
->getDefinitions() as $entity_type_id => $entity_type) {
if ($entity_type
->get('field_ui_base_route')) {
// 'Tools' tab.
$this->derivatives["field_tools_field_ui_tools_{$entity_type_id}"] = array(
'route_name' => "field_tools.field_bulk_clone_{$entity_type_id}",
'weight' => 4,
'title' => $this
->t('Tools'),
'base_route' => $entity_type
->get('field_ui_base_route'),
);
// Secondary tools tabs.
// 'Clone fields' tab.
$this->derivatives["field_tools_field_clone_{$entity_type_id}"] = array(
'route_name' => "field_tools.field_bulk_clone_{$entity_type_id}",
'weight' => 0,
'title' => $this
->t('Clone fields'),
'base_route' => $entity_type
->get('field_ui_base_route'),
'parent_id' => "field_tools.field_ui_tools:field_tools_field_ui_tools_{$entity_type_id}",
);
// 'Clone displays' tab.
$this->derivatives["field_tools_displays_clone_{$entity_type_id}"] = array(
'route_name' => "field_tools.displays_clone_{$entity_type_id}",
'weight' => 5,
'title' => $this
->t('Clone displays'),
'base_route' => $entity_type
->get('field_ui_base_route'),
'parent_id' => "field_tools.field_ui_tools:field_tools_field_ui_tools_{$entity_type_id}",
);
// 'Copy display settings' tab.
$this->derivatives["field_tools.displays_settings_copy_{$entity_type_id}"] = array(
'route_name' => "field_tools.displays_settings_copy_{$entity_type_id}",
'weight' => 5,
'title' => $this
->t('Copy display settings'),
'base_route' => $entity_type
->get('field_ui_base_route'),
'parent_id' => "field_tools.field_ui_tools:field_tools_field_ui_tools_{$entity_type_id}",
);
// 'Export to base fields' tab.
$this->derivatives["field_tools.export_to_code_{$entity_type_id}"] = array(
'route_name' => "field_tools.export_to_code_{$entity_type_id}",
'weight' => 5,
'title' => $this
->t('Export to base fields code'),
'base_route' => $entity_type
->get('field_ui_base_route'),
'parent_id' => "field_tools.field_ui_tools:field_tools_field_ui_tools_{$entity_type_id}",
);
// Single field clone tab.
$this->derivatives["field_tools_field_clone_single_{$entity_type_id}"] = array(
'route_name' => "entity.field_config.{$entity_type_id}_field_tools_clone_form",
'title' => $this
->t('Clone'),
'base_route' => "entity.field_config.{$entity_type_id}_field_edit_form",
'weight' => 10,
);
}
}
foreach ($this->derivatives as &$entry) {
$entry += $base_plugin_definition;
}
return $this->derivatives;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
FieldToolsLocalTask:: |
protected | property | The entity type manager. | |
FieldToolsLocalTask:: |
protected | property | The route provider. | |
FieldToolsLocalTask:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
FieldToolsLocalTask:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
FieldToolsLocalTask:: |
public | function | Creates an FieldToolsLocalTask object. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |