function EntityBundle::getEntityBundleLabel
Same name in other branches
- 8.x-3.x src/Plugin/Deriver/EntityBundle.php \Drupal\ctools\Plugin\Deriver\EntityBundle::getEntityBundleLabel()
Provides the bundle label with a fallback when not defined.
Parameters
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type we are looking the bundle label for.
Return value
\Drupal\Core\StringTranslation\TranslatableMarkup The entity bundle label or a fallback label.
1 call to EntityBundle::getEntityBundleLabel()
- EntityBundle::getDerivativeDefinitions in src/
Plugin/ Deriver/ EntityBundle.php - Gets the definition of all derivatives of a base plugin.
File
-
src/
Plugin/ Deriver/ EntityBundle.php, line 44
Class
- EntityBundle
- Deriver that creates a condition for each entity type with bundles.
Namespace
Drupal\ctools\Plugin\DeriverCode
protected function getEntityBundleLabel($entity_type) {
if ($label = $entity_type->getBundleLabel()) {
return $this->t('@label', [
'@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', [
'@label' => $fallback,
]);
}