class DynamicAddEntityLocalActions in Apigee Edge 8
Add add entity local actions for Apigee Edge entity's collection routes.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\apigee_edge\Plugin\Derivative\DynamicAddEntityLocalActions implements ContainerDeriverInterface uses StringTranslationTrait
Expanded class hierarchy of DynamicAddEntityLocalActions
1 string reference to 'DynamicAddEntityLocalActions'
File
- src/
Plugin/ Derivative/ DynamicAddEntityLocalActions.php, line 34
Namespace
Drupal\apigee_edge\Plugin\DerivativeView source
class DynamicAddEntityLocalActions extends DeriverBase implements ContainerDeriverInterface {
use StringTranslationTrait;
/**
* The base plugin ID.
*
* @var string
*/
protected $basePluginId;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* The moderation information service.
*
* @var \Drupal\content_moderation\ModerationInformationInterface
*/
protected $moderationInfo;
/**
* Creates an DynamicAddEntityLocalTasks object.
*
* @param string $base_plugin_id
* The base plugin ID.
* @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($base_plugin_id, EntityTypeManagerInterface $entity_type_manager, TranslationInterface $string_translation) {
$this->entityTypeManager = $entity_type_manager;
$this->stringTranslation = $string_translation;
$this->basePluginId = $base_plugin_id;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($base_plugin_id, $container
->get('entity_type.manager'), $container
->get('string_translation'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$this->derivatives = [];
foreach ($this->entityTypeManager
->getDefinitions() as $type) {
if ($type instanceof EdgeEntityTypeInterface) {
foreach ($this->entityTypeManager
->getRouteProviders($type
->id()) as $provider) {
$collection_route_name = "entity.{$type->id()}.collection";
$collection_route = $provider
->getRoutes($type)
->get($collection_route_name);
$add_form_route_name = "entity.{$type->id()}.add_form";
$add_form_route = $provider
->getRoutes($type)
->get($add_form_route_name);
if ($collection_route && $add_form_route) {
$this->derivatives["{$type->getProvider()}.{$type->id()}.add_form"] = [
'route_name' => $add_form_route_name,
'title' => $this
->t('Add @entity-type', [
'@entity-type' => mb_strtolower($type
->getSingularLabel()),
]),
'appears_on' => [
$collection_route_name,
],
] + $base_plugin_definition;
break;
}
}
}
}
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:: |
|
DynamicAddEntityLocalActions:: |
protected | property | The base plugin ID. | |
DynamicAddEntityLocalActions:: |
protected | property | The entity type manager. | |
DynamicAddEntityLocalActions:: |
protected | property | The moderation information service. | |
DynamicAddEntityLocalActions:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
DynamicAddEntityLocalActions:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
DynamicAddEntityLocalActions:: |
public | function | Creates an DynamicAddEntityLocalTasks 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. |