public function Field::offsetGet

Implements ArrayAccess::offsetGet().

File

drupal/core/lib/Drupal/Core/Entity/Field/Type/Field.php, line 140
Definition of Drupal\Core\Entity\Field\Type\Field.

Class

Field
An entity field, i.e. a list of field items.

Namespace

Drupal\Core\Entity\Field\Type

Code

public function offsetGet($offset) {
  if (!is_numeric($offset)) {
    throw new InvalidArgumentException('Unable to get a value with a non-numeric delta in a list.');
  }
  elseif (!isset($this->list[$offset])) {
    $this->list[$offset] = $this
      ->createItem();
  }
  return $this->list[$offset];
}