class EntityFieldDeriver in Context entity field 8
Deriver that creates a condition for each entity type with bundles.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\ctools\Plugin\Deriver\EntityDeriverBase implements ContainerDeriverInterface uses StringTranslationTrait
- class \Drupal\ctools\Plugin\Deriver\EntityBundle
- class \Drupal\context_entity_field\Plugin\Deriver\EntityFieldDeriver
- class \Drupal\ctools\Plugin\Deriver\EntityBundle
- class \Drupal\ctools\Plugin\Deriver\EntityDeriverBase implements ContainerDeriverInterface uses StringTranslationTrait
Expanded class hierarchy of EntityFieldDeriver
File
- src/
Plugin/ Deriver/ EntityFieldDeriver.php, line 10
Namespace
Drupal\context_entity_field\Plugin\DeriverView source
class EntityFieldDeriver extends EntityBundle {
/**
* Provides the bundle label with a fallback when not defined.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type we are looking the bundle label for.
*
* @return \Drupal\Core\StringTranslation\TranslatableMarkup
* The entity bundle label or a fallback label.
*/
protected function getEntityBundleLabel($entity_type) {
if ($label = $entity_type
->getBundleLabel()) {
return $this
->t('@label field', [
'@label' => $label,
]);
}
$fallback = $entity_type
->getLabel();
if ($bundle_entity_type = $entity_type
->getBundleEntityType()) {
// This is a better fallback.
$fallback = $this->entityTypeManager
->getDefinition($bundle_entity_type)
->getLabel();
}
return $this
->t('@label bundle field', [
'@label' => $fallback,
]);
}
}
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:: |
|
EntityBundle:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
EntityDeriverBase:: |
protected | property | The entity field manager. | |
EntityDeriverBase:: |
protected | property | The entity type manager. | |
EntityDeriverBase:: |
protected | property | The entity type repository. | |
EntityDeriverBase:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
EntityDeriverBase:: |
public | function | Constructs new EntityViewDeriver. | |
EntityFieldDeriver:: |
protected | function |
Provides the bundle label with a fallback when not defined. Overrides EntityBundle:: |
|
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. |