class EckEntityContentLocalTask in Entity Construction Kit (ECK) 8
Provides local task definitions for all entity bundles.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\eck\Plugin\Derivative\EckEntityContentLocalTask implements ContainerDeriverInterface uses StringTranslationTrait
Expanded class hierarchy of EckEntityContentLocalTask
1 string reference to 'EckEntityContentLocalTask'
File
- src/
Plugin/ Derivative/ EckEntityContentLocalTask.php, line 15
Namespace
Drupal\eck\Plugin\DerivativeView source
class EckEntityContentLocalTask extends DeriverBase implements ContainerDeriverInterface {
use StringTranslationTrait;
private $basePluginDefinition;
/**
* The constructor.
*
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The translation manager.
*/
public function __construct(TranslationInterface $string_translation) {
$this->stringTranslation = $string_translation;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('string_translation'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($basePluginDefinition) {
$this->basePluginDefinition = $basePluginDefinition;
$derivatives = [];
/** @var \Drupal\eck\Entity\EckEntityType $type */
foreach (EckEntityType::loadMultiple() as $type) {
$entity_type = $type
->id();
$base_route = "entity.{$entity_type}.canonical";
$derivative = $this
->createDerivativeDefinition("entity.{$entity_type}.canonical", 1, 'View', $base_route);
$derivatives["{$entity_type}.eck_canonical_tab"] = $derivative;
$derivative = $this
->createDerivativeDefinition("entity.{$entity_type}.edit_form", 2, 'Edit', $base_route);
$derivatives["{$entity_type}.eck_edit_tab"] = $derivative;
$derivative = $this
->createDerivativeDefinition("entity.{$entity_type}.delete_form", 3, 'Delete', $base_route);
$derivatives["{$entity_type}.eck_delete_tab"] = $derivative;
}
return $derivatives;
}
/**
* Creates a derivative definition.
*
* @param string $routeName
* The route name.
* @param int $weight
* The weight.
* @param string $title
* The title.
* @param string $base_route
* The base route.
*
* @return array
* The created derivative definition.
*/
private function createDerivativeDefinition($routeName, $weight, $title, $base_route) {
$derivative = [
'route_name' => $routeName,
'weight' => $weight,
'title' => $this
->t($title),
'base_route' => $base_route,
] + $this->basePluginDefinition;
return $derivative;
}
}
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:: |
|
EckEntityContentLocalTask:: |
private | property | ||
EckEntityContentLocalTask:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
EckEntityContentLocalTask:: |
private | function | Creates a derivative definition. | |
EckEntityContentLocalTask:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
EckEntityContentLocalTask:: |
public | function | The constructor. | |
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. |