public function FieldCollectionItem::getHostId in Field collection 8
Same name and namespace in other branches
- 8.3 src/Entity/FieldCollectionItem.php \Drupal\field_collection\Entity\FieldCollectionItem::getHostId()
Returns the id of the host entity for this field collection item.
Return value
string|int|null The id of the host entity for this field collection item, or NULL if the reference doesn't exist in the host yet.
Overrides FieldCollectionItemInterface::getHostId
1 call to FieldCollectionItem::getHostId()
- FieldCollectionItem::getHost in src/
Entity/ FieldCollectionItem.php - Returns the host entity of this field collection item.
File
- src/
Entity/ FieldCollectionItem.php, line 273
Class
- FieldCollectionItem
- Defines the field collection item entity class.
Namespace
Drupal\field_collection\EntityCode
public function getHostId() {
if (!isset($this->host_id)) {
$entity_info = $this
->entityTypeManager()
->getDefinition($this->host_type->value, TRUE);
$host_id_results = \Drupal::entityQuery($entity_info
->id())
->condition($this
->bundle(), $this
->id())
->execute();
$this->host_id = reset($host_id_results);
}
return $this->host_id;
}