class EntityReplicateActions in Replicate UI 8
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\replicate_ui\Plugin\Derivative\EntityReplicateActions implements ContainerDeriverInterface uses StringTranslationTrait
Expanded class hierarchy of EntityReplicateActions
File
- src/
Plugin/ Derivative/ EntityReplicateActions.php, line 13
Namespace
Drupal\replicate_ui\Plugin\DerivativeView source
class EntityReplicateActions extends DeriverBase implements ContainerDeriverInterface {
use StringTranslationTrait;
/**
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/**
* Creates a new RouteSubscriber instance.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
* The entity type manager.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory.
*/
public function __construct(EntityTypeManagerInterface $entityTypeManager, ConfigFactoryInterface $config_factory) {
$this->entityTypeManager = $entityTypeManager;
$this->configFactory = $config_factory;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('entity_type.manager'), $container
->get('config.factory'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$config = $this->configFactory
->get('replicate_ui.settings');
foreach ($this->entityTypeManager
->getDefinitions() as $entity_type_id => $entity_type) {
if ($entity_type instanceof ContentEntityTypeInterface && in_array($entity_type_id, $config
->get('entity_types')) && $entity_type
->hasLinkTemplate('canonical')) {
$replicate_route_name = "entity.{$entity_type_id}.replicate";
// Allow for exporting in things such as VBO by ensuring that the action
// names will pass validation in ConfigBase.
$safe_action_name = str_replace('.', '_', $replicate_route_name);
$this->derivatives[$safe_action_name] = [
'label' => $this
->t('Delete @entity_type', [
'@entity_type' => $entity_type
->getLabel(),
]),
'type' => $entity_type_id,
'config_form_route_name' => "entity.{$entity_type_id}.replicate",
] + $base_plugin_definition;
}
}
return parent::getDerivativeDefinitions($base_plugin_definition);
}
}
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:: |
|
EntityReplicateActions:: |
protected | property | ||
EntityReplicateActions:: |
protected | property | ||
EntityReplicateActions:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
EntityReplicateActions:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
EntityReplicateActions:: |
public | function | Creates a new RouteSubscriber instance. | |
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. |