class EntityFieldConditionDeriver in Entity Field Condition 2.0.x
Define the entity field condition deriver.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\entity_field_condition\Plugin\Deriver\EntityFieldConditionDeriver implements ContainerDeriverInterface uses StringTranslationTrait
Expanded class hierarchy of EntityFieldConditionDeriver
File
- src/
Plugin/ Deriver/ EntityFieldConditionDeriver.php, line 19
Namespace
Drupal\entity_field_condition\Plugin\DeriverView source
class EntityFieldConditionDeriver extends DeriverBase implements ContainerDeriverInterface {
use StringTranslationTrait;
/**
* Entity type manager service.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* The entity field condition deriver.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
/**
* {@inheritDoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('entity_type.manager'));
}
/**
* {@inheritDoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) : array {
if (empty($this->derivatives)) {
foreach ($this->entityTypeManager
->getDefinitions() as $type => $definition) {
if (!$definition instanceof ContentEntityTypeInterface || !$definition
->entityClassImplements(FieldableEntityInterface::class)) {
continue;
}
$this->derivatives[$type] = $base_plugin_definition;
$this->derivatives[$type]['label'] = $this
->t('@entity_type Field', [
'@entity_type' => $definition
->getLabel(),
]);
$this->derivatives[$type]['context_definitions'] = [
'entity' => new EntityContextDefinition("entity:{$type}", $this
->t('@entity_type', [
'@entity_type' => $definition
->getLabel(),
])),
];
}
}
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:: |
|
EntityFieldConditionDeriver:: |
protected | property | Entity type manager service. | |
EntityFieldConditionDeriver:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
EntityFieldConditionDeriver:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
EntityFieldConditionDeriver:: |
public | function | The entity field condition deriver. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 4 |
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. |