W3cubDocs

/Drupal 8

function node_get_type_label

node_get_type_label(NodeInterface $node)

Returns the node type label for the passed node.

@todo Add this as generic helper method for config entities representing entity bundles.

Parameters

\Drupal\node\NodeInterface $node: A node entity to return the node type's label for.

Return value

string|false The node type label or FALSE if the node type is not found.

File

core/modules/node/node.module, line 277
The core module that allows content to be submitted to the site.

Code

function node_get_type_label(NodeInterface $node) {
  $type = NodeType::load($node->bundle());
  return $type ? $type->label() : FALSE;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!node!node.module/function/node_get_type_label/8.1.x