I am learning how to work with this new entity functionality using the 7.x-1.x-dev of Entity API, so pardon me if this is a foolish issue.

I defined my entity according to the guidelines, specifically 'label callback' with my own function in hook_entity_info() and wrote that label function properly. When I went to test it, via my_entity->label(), I received these errors:

Notice: Undefined variable: entity_type in Entity->label() (line 101 of .../sites/all/modules/entity/includes/entity.inc).
Notice: Undefined variable: entity in Entity->label() (line 101 of .../sites/all/modules/entity/includes/entity.inc).

After a long while of scrutinizing my own code, I checked out the line in entity.inc and there it has:

public function label() {
  if (isset($this->entityInfo['label callback']) && $this->entityInfo['label callback'] == 'entity_class_label') {
    return $this->defaultLabel();
  }
  return entity_label($entity_type, $entity); //<--------------- ERROR POINTS HERE
}

$entity_type and $entity are not defined in the function and look as if it was copied & pasted from the API page. So, by OOP theory, I changed the line to:

  return entity_label($this->entityType, $this);

just like the uri function just below it and it worked perfectly.

-Marcus

Comments

fago’s picture

Status: Active » Fixed

Indeed, what a dumb mistake. Thanks for pointing that out.

However, please provide your fixes as patch, such that the fix runs through the automated testing infrastructure and can be seamlessly taken over by other devs.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.