You are here

public function LingotekContentMetadataFieldItemList::get in Lingotek Translation 8.2

Same name and namespace in other branches
  1. 4.0.x src/Plugin/Field/LingotekContentMetadataFieldItemList.php \Drupal\lingotek\Plugin\Field\LingotekContentMetadataFieldItemList::get()
  2. 3.0.x src/Plugin/Field/LingotekContentMetadataFieldItemList.php \Drupal\lingotek\Plugin\Field\LingotekContentMetadataFieldItemList::get()
  3. 3.1.x src/Plugin/Field/LingotekContentMetadataFieldItemList.php \Drupal\lingotek\Plugin\Field\LingotekContentMetadataFieldItemList::get()
  4. 3.2.x src/Plugin/Field/LingotekContentMetadataFieldItemList.php \Drupal\lingotek\Plugin\Field\LingotekContentMetadataFieldItemList::get()
  5. 3.3.x src/Plugin/Field/LingotekContentMetadataFieldItemList.php \Drupal\lingotek\Plugin\Field\LingotekContentMetadataFieldItemList::get()
  6. 3.4.x src/Plugin/Field/LingotekContentMetadataFieldItemList.php \Drupal\lingotek\Plugin\Field\LingotekContentMetadataFieldItemList::get()
  7. 3.5.x src/Plugin/Field/LingotekContentMetadataFieldItemList.php \Drupal\lingotek\Plugin\Field\LingotekContentMetadataFieldItemList::get()
  8. 3.6.x src/Plugin/Field/LingotekContentMetadataFieldItemList.php \Drupal\lingotek\Plugin\Field\LingotekContentMetadataFieldItemList::get()
  9. 3.7.x src/Plugin/Field/LingotekContentMetadataFieldItemList.php \Drupal\lingotek\Plugin\Field\LingotekContentMetadataFieldItemList::get()
  10. 3.8.x src/Plugin/Field/LingotekContentMetadataFieldItemList.php \Drupal\lingotek\Plugin\Field\LingotekContentMetadataFieldItemList::get()

Returns the item at the specified position in this list.

Parameters

int $index: Index of the item to return.

Return value

\Drupal\Core\TypedData\TypedDataInterface|null The item at the specified position in this list, or NULL if no item exists at that position.

Throws

\Drupal\Core\TypedData\Exception\MissingDataException If the complex data structure is unset and no item can be created.

Overrides ItemList::get

File

src/Plugin/Field/LingotekContentMetadataFieldItemList.php, line 53

Class

LingotekContentMetadataFieldItemList
A computed field that provides a content entity's Lingotek metadata.

Namespace

Drupal\lingotek\Plugin\Field

Code

public function get($index) {
  if ($index !== 0) {
    throw new \InvalidArgumentException('An entity can not have multiple moderation states at the same time.');
  }
  if (isset($this->list[$index]) && !$this->list[$index]
    ->isEmpty()) {
    return $this->list[$index];
  }
  $this
    ->computeLingotekMetadataFieldItemList();
  return isset($this->list[$index]) ? $this->list[$index] : NULL;
}