Reputation: 56
As an example: I have the machine name of the node bundle present. e.g "basic_page" and want to get the label of that bundle, in that example "Basic Page".
I can get that by loading a node of that bundle and then, geting its bundle and label like so:
node_load($nid)->type->entity->label();
but im searching for a more elegant, straight forward way without the need of loading the node.
Upvotes: 0
Views: 1001
Reputation: 8181
If you already know the machine name, you should be able to use the EntityTypeManager
\Drupal::entityTypeManager()->getDefinition('machine_name')->getLabel();
Upvotes: 1