Starting in Backdrop 1.32.0, hook_entity_info() now re-introduces the label callback property. It was believed this property was no longer necessary and was removed in Backdrop 1.0.0, but recent developments in internationalization demonstrated use-cases for why label callback is still useful. As such, this property is restored in Backdrop 1.32.0, the same as it was in Drupal 7.

Before Backdrop 1.32.0: (example from User module)

In user.module:

/**
 * Implements hook_entity_info().
 */
function user_entity_info() {
  $entity_info = array(
    'user' => array(
      'label' => t('User account'),
      'entity class' => 'User',
      ...
    ),
  );
}

In user.entity.inc:

/**

 * Implements EntityInterface::label().

 */

public function label() {

  return user_format_name($this);

}

After Backdrop 1.32.0:

/**
 * Implements hook_entity_info().
 */
function user_entity_info() {
  $entity_info = array(
    'user' => array(
      'label' => t('User account'),
      'entity class' => 'User',
      'label callback' => 'user_format_name', // <- New property.
      ...
    ),
  );
}

The addition of label callback to hook_entity_info() allows 3rd-party modules to specify a different label callback without overriding or wrapping the entire User class. It also makes it so that most entity types no longer need to implement the label() method, since the Entity::label() base method will be suitable in most cases. If wanting to use the base method, the label entity key should be provided, as below.

Before Backdrop 1.32.0: (example from Node module)

In node.module:

/**
 * Implements hook_entity_info().
 */
function node_entity_info() {
  $entity_info = array(
    'node' => array(
      ...
      'entity keys' => array(
        'id' => 'nid',
        'revision' => 'vid',
        'bundle' => 'type',
      ),
      ...
    ),
  );
}

In node.entity.inc:

/**
 * Implements EntityInterface::label().
 */
public function label() {
  return $this->title;
}

After Backdrop 1.32.0:

/**
 * Implements hook_entity_info().
 */
function node_entity_info() {
  $entity_info = array(
    'node' => array(
      ...
      'entity keys' => array(
        'id' => 'nid',
        'revision' => 'vid',
        'bundle' => 'type',
        'label' => 'title', // <- New property.
      ),
      ...
    ),
  );
}

In Backdrop 1.32.0 and higher, implementing the label() callback is no longer necessary if a label entity key is provided.

Introduced in branch: 
1.x
Introduced in version: 
1.32.0
Impacts: 
Module developers