You are here

public function ParagraphsItemEntity::delta in Paragraphs 7

Determines the $delta of the reference pointing to this paragraph item.

3 calls to ParagraphsItemEntity::delta()
ParagraphsItemEntity::deleteHostEntityReference in ./ParagraphsItemEntity.inc
Deletes the host entity's reference of the paragraphs item.
ParagraphsItemEntity::langcode in ./ParagraphsItemEntity.inc
Determines the language code under which the item is stored.
ParagraphsItemEntity::save in ./ParagraphsItemEntity.inc
Save the paragraphs item.

File

./ParagraphsItemEntity.inc, line 324

Class

ParagraphsItemEntity
Entity implementation for the paragraphs entity.

Code

public function delta() {
  if (($entity = $this
    ->hostEntity()) && isset($entity->{$this->field_name})) {
    foreach ($entity->{$this->field_name} as $langcode => &$data) {
      foreach ($data as $delta => $item) {
        if (isset($item['value']) && $item['value'] == $this->item_id) {
          $this->langcode = $langcode;
          return $delta;
        }
        elseif (isset($item['entity']) && $item['entity'] === $this) {
          $this->langcode = $langcode;
          return $delta;
        }
      }
    }
  }
}