Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By jhodgdon on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
7.x
Description:
Note: This change notice was about 8.x too, but the $entity_type argument has been removed again there, as $entity is now an instance of EntityInterface
and the entity type can be checked with $entity->getEntityTypeId()
.
Any label callback defined in an entity now receives two arguments: $entity
and $entity_type
. This allows label callbacks that apply to multiple entity types.
Example:
function example_entity_info() {
...
$entities['example']['label callback'] = 'example_label';
return $entities;
}
// Drupal 7.0 and up:
function example_label($entity) {
...
}
// Drupal 7.2 and up:
function example_label($entity, $entity_type) {
...
}
Impacts:
Module developers
Comments
reversed params in function callback
Actually based on the code and the API docs, params are reversed: