You are here

public function ModerationStateFieldItemList::get in Config Entity Revisions 8.2

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/ModerationStateFieldItemList.php, line 130

Class

ModerationStateFieldItemList
A computed field that provides a content entity's moderation state.

Namespace

Drupal\content_moderation\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.');
  }
  return $this
    ->traitGet($index);
}