protected function EntityBundle::getEntityBundleLabel in Chaos Tool Suite (ctools) 8.3
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 37
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,
]);
}