protected function EntityTraversal::getBundleLabel in General Data Protection Regulation 3.0.x
Same name and namespace in other branches
- 8.2 modules/gdpr_fields/src/EntityTraversal.php \Drupal\gdpr_fields\EntityTraversal::getBundleLabel()
- 8 modules/gdpr_fields/src/EntityTraversal.php \Drupal\gdpr_fields\EntityTraversal::getBundleLabel()
Gets the entity bundle label. Useful for display traversal.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity to get the bundle label for.
Return value
string Bundle label
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
2 calls to EntityTraversal::getBundleLabel()
- RightToAccessDisplayTraversal::processEntity in modules/
gdpr_tasks/ src/ Traversal/ RightToAccessDisplayTraversal.php - RightToBeForgottenDisplayTraversal::processEntity in modules/
gdpr_tasks/ src/ Traversal/ RightToBeForgottenDisplayTraversal.php
File
- modules/
gdpr_fields/ src/ EntityTraversal.php, line 299
Class
- EntityTraversal
- Base class for traversing entities.
Namespace
Drupal\gdpr_fieldsCode
protected function getBundleLabel(EntityInterface $entity) {
$entityDefinition = $entity
->getEntityType();
$bundleType = $entityDefinition
->getBundleEntityType();
if ($bundleType) {
$bundleStorage = $this->entityTypeManager
->getStorage($bundleType);
$bundleEntity = $bundleStorage
->load($entity
->bundle());
$bundleLabel = $bundleEntity === NULL ? '' : $bundleEntity
->label();
}
else {
$bundleLabel = $entityDefinition
->getLabel();
}
return $bundleLabel;
}