You are here

public function FieldCollectionItemEntity::defaultLabel in Field collection 7

Specifies the default label, which is picked up by label() by default.

Overrides Entity::defaultLabel

File

./field_collection.entity.inc, line 139

Class

FieldCollectionItemEntity
Class for field_collection_item entities.

Code

public function defaultLabel() {
  if ($this
    ->fetchHostDetails()) {
    $field = $this
      ->fieldInfo();
    $label = $this
      ->translatedInstanceLabel();
    $host = $this
      ->hostEntity();
    if ($new_label = module_invoke_all('field_collection_item_label', $this, $host, $field, $label)) {
      return array_pop($new_label);
    }
    if ($field['cardinality'] == 1) {
      return $label;
    }
    if ($this->item_id) {
      return t('!instance_label @count', array(
        '!instance_label' => $label,
        '@count' => $this
          ->delta() + 1,
      ));
    }
    return t('New !instance_label', array(
      '!instance_label' => $label,
    ));
  }
  return t('Unconnected field collection item');
}