public function FieldCollectionItem::getDelta in Field collection 8.3
Same name and namespace in other branches
- 8 src/Entity/FieldCollectionItem.php \Drupal\field_collection\Entity\FieldCollectionItem::getDelta()
Returns the $delta of the reference to this field collection item.
Return value
int|null The $delta of the reference to this field collection item, or NULL if the reference doesn't exist in the host yet.
Overrides FieldCollectionItemInterface::getDelta
3 calls to FieldCollectionItem::getDelta()
- FieldCollectionItem::deleteHostEntityReference in src/
Entity/ FieldCollectionItem.php - Deletes the host entity's reference of the field collection item.
- FieldCollectionItem::label in src/
Entity/ FieldCollectionItem.php - Overrides \Drupal\Core\Entity\label().
- FieldCollectionItem::save in src/
Entity/ FieldCollectionItem.php - Save the field collection item.
File
- src/
Entity/ FieldCollectionItem.php, line 250
Class
- FieldCollectionItem
- Defines the field collection item entity class.
Namespace
Drupal\field_collection\EntityCode
public function getDelta() {
if (($host = $this
->getHost()) && isset($host->{$this
->bundle()})) {
foreach ($host->{$this
->bundle()} as $delta => $item) {
if (isset($item->target_id) && $item->target_id == $this
->id()) {
return $delta;
}
elseif (isset($item->entity) && $item->entity === $this) {
return $delta;
}
}
}
}