You are here

public function FieldCollectionItem::getHost in Field collection 8

Same name and namespace in other branches
  1. 8.3 src/Entity/FieldCollectionItem.php \Drupal\field_collection\Entity\FieldCollectionItem::getHost()

Returns the host entity of this field collection item.

Parameters

bool: (optional) TRUE to reset the internal cache for the host's entity type. Defaults to FALSE.

Return value

\Drupal\Core\Entity\ContentEntityInterface The host entity of this field collection item or NULL if the reference doesn't exist in the host yet.

Overrides FieldCollectionItemInterface::getHost

4 calls to FieldCollectionItem::getHost()
FieldCollectionItem::delete in src/Entity/FieldCollectionItem.php
Deletes an entity permanently.
FieldCollectionItem::deleteHostEntityReference in src/Entity/FieldCollectionItem.php
Deletes the host entity's reference of the field collection item.
FieldCollectionItem::getDelta in src/Entity/FieldCollectionItem.php
Returns the $delta of the reference to this field collection item.
FieldCollectionItem::save in src/Entity/FieldCollectionItem.php
Save the field collection item.

File

src/Entity/FieldCollectionItem.php, line 257

Class

FieldCollectionItem
Defines the field collection item entity class.

Namespace

Drupal\field_collection\Entity

Code

public function getHost($reset = FALSE) {
  if ($id = $this
    ->getHostId()) {
    $storage = $this
      ->entityTypeManager()
      ->getStorage($this->host_type->value);
    if ($reset) {
      $storage
        ->resetCache([
        $id,
      ]);
    }
    return $storage
      ->load($id);
  }
  else {
    return NULL;
  }
}