You are here

public function FieldCollection::getEntityIdFromFieldItem in Reference Table Formatter 8

The the entity ID from the field value.

Parameters

\Drupal\Core\Field\FieldItemInterface $item: The reference field to gain the ID for.

Return value

int An entity ID.

Overrides FormatterInterface::getEntityIdFromFieldItem

File

src/Plugin/Field/FieldFormatter/FieldCollection.php, line 65

Class

FieldCollection
A field formatter to display a table.

Namespace

Drupal\reference_table_formatter\Plugin\Field\FieldFormatter

Code

public function getEntityIdFromFieldItem(FieldItemInterface $item) {
  $value = $item
    ->getValue();
  return isset($value['target_id']) ? $value['target_id'] : $value['value'];
}