public function ModerationStateFieldItemList::get in Drupal 10
Same name and namespace in other branches
- 8 core/modules/content_moderation/src/Plugin/Field/ModerationStateFieldItemList.php \Drupal\content_moderation\Plugin\Field\ModerationStateFieldItemList::get()
- 9 core/modules/content_moderation/src/Plugin/Field/ModerationStateFieldItemList.php \Drupal\content_moderation\Plugin\Field\ModerationStateFieldItemList::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
- core/
modules/ content_moderation/ src/ Plugin/ Field/ ModerationStateFieldItemList.php, line 110
Class
- ModerationStateFieldItemList
- A computed field that provides a content entity's moderation state.
Namespace
Drupal\content_moderation\Plugin\FieldCode
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);
}