1 layout.entity.admin.inc | _layout_entity_bundle_label($entity_type, $bundle_arg) |
Get a bundle's label.
This function is a temporary measure until there is a central way to get the label of an entity type's bundles.
@private
Parameters
string $entity_type: The entity type such as "node", "user", "taxonomy_term", etc.
string|stdClass $bundle_arg: The bundle as a string or object. The object may be a TaxonomyVocabulary or stdClass (in the case of a node type).
Return value
string: The label of the given entity bundle.
File
- core/
modules/ layout/ layout.entity.admin.inc, line 457 - Provides a user interface for managing layouts for entity bundles.
Code
function _layout_entity_bundle_label($entity_type, $bundle_arg) {
$entity_info = entity_get_info($entity_type);
$bundle_label = t('Unknown');
if (is_object($bundle_arg) && property_exists($bundle_arg, 'label')) {
$bundle_label = $bundle_arg->label;
}
elseif (is_object($bundle_arg) && property_exists($bundle_arg, 'name')) {
$bundle_label = $bundle_arg->name;
}
// If unable to find a bundle label, fallback to the entity label.
elseif (is_string($bundle_arg)) {
if (isset($entity_info['label'])) {
$bundle_label = $entity_info['label'];
}
}
return $bundle_label;
}