public function FieldCollectionItemEntity::delta in Field collection 7
Determines the $delta of the reference pointing to this field collection item.
5 calls to FieldCollectionItemEntity::delta()
- FieldCollectionItemEntity::defaultLabel in ./
field_collection.entity.inc - Specifies the default label, which is picked up by label() by default.
- FieldCollectionItemEntity::deleteHostEntityReference in ./
field_collection.entity.inc - Deletes the host entity's reference of the field collection item.
- FieldCollectionItemEntity::langcode in ./
field_collection.entity.inc - Determines the language code under which the item is stored.
- FieldCollectionItemEntity::save in ./
field_collection.entity.inc - Save the field collection item.
- FieldCollectionItemEntity::updateHostEntity in ./
field_collection.entity.inc - Updates the wrapped host entity object.
File
- ./
field_collection.entity.inc, line 377
Class
- FieldCollectionItemEntity
- Class for field_collection_item entities.
Code
public function delta() {
if (($entity = $this
->hostEntity()) && isset($entity->{$this->field_name})) {
foreach ($entity->{$this->field_name} as $langcode => &$data) {
if (!empty($data)) {
foreach ($data as $delta => $item) {
if (isset($item['value']) && $item['value'] == $this->item_id) {
$this->langcode = $langcode;
return $delta;
}
if (isset($item['entity']) && $item['entity'] === $this) {
$this->langcode = $langcode;
return $delta;
}
}
}
}
// If we don't find the delta in the current values (cause the item
// is being deleted, for example), we search the delta in the originalcontent.
if (!empty($entity->original)) {
foreach ($entity->original->{$this->field_name} as $langcode => &$data) {
if (!empty($data)) {
foreach ($data as $delta => $item) {
if (isset($item['value']) && $item['value'] == $this->item_id) {
$this->langcode = $langcode;
return $delta;
}
if (isset($item['entity']) && $item['entity'] === $this) {
$this->langcode = $langcode;
return $delta;
}
}
}
}
}
}
}