interface FieldInterface

Interface for fields, being lists of field items.

Contained items must implement the FieldItemInterface. This interface is required for every property of an entity. Some methods are delegated to the first contained item, in particular get() and set() as well as their magic equivalences.

Optionally, a typed data object implementing Drupal\Core\TypedData\TypedDataInterface may be passed to ArrayAccess::offsetSet() instead of a plain value.

When implementing this interface which extends Traversable, make sure to list IteratorAggregate or Iterator before this interface in the implements clause.

Hierarchy

Expanded class hierarchy of FieldInterface

All classes that implement FieldInterface

3 files declare their use of FieldInterface
EntityFieldTest.php in drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php
Definition of Drupal\Core\Entity\Tests\EntityFieldTest.
Field.php in drupal/core/lib/Drupal/Core/Entity/Field/Type/Field.php
Definition of Drupal\Core\Entity\Field\Type\Field.
TaxonomyTermReferenceItemTest.php in drupal/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php
Contains \Drupal\taxonomy\Tests\TaxonomyTermReferenceItemTest.

File

drupal/core/lib/Drupal/Core/Entity/Field/FieldInterface.php, line 30
Definition of Drupal\Core\Entity\Field\FieldInterface.

Namespace

Drupal\Core\Entity\Field
View source
interface FieldInterface extends ListInterface, AccessibleInterface, ContextAwareInterface, TypedDataInterface {

  /**
   * Delegates to the first item.
   *
   * @see \Drupal\Core\Entity\Field\FieldItemInterface::get()
   */
  public function get($property_name);

  /**
   * Magic getter: Delegates to the first item.
   *
   * @see \Drupal\Core\Entity\Field\FieldItemInterface::__get()
   */
  public function __get($property_name);

  /**
   * Magic setter: Delegates to the first item.
   *
   * @see \Drupal\Core\Entity\Field\FieldItemInterface::__set()
   */
  public function __set($property_name, $value);

  /**
   * Magic method for isset(): Delegates to the first item.
   *
   * @see \Drupal\Core\Entity\Field\FieldItemInterface::__isset()
   */
  public function __isset($property_name);

  /**
   * Magic method for unset(): Delegates to the first item.
   *
   * @see \Drupal\Core\Entity\Field\FieldItemInterface::__unset()
   */
  public function __unset($property_name);

  /**
   * Delegates to the first item.
   *
   * @see \Drupal\Core\Entity\Field\FieldItemInterface::getPropertyDefinition()
   */
  public function getPropertyDefinition($name);

  /**
   * Delegates to the first item.
   *
   * @see \Drupal\Core\Entity\Field\FieldItemInterface::getPropertyDefinitions()
   */
  public function getPropertyDefinitions();

}

Members

Namesort ascending Modifiers Type Description Overrides
TypedDataInterface::validate public function Validates the currently set data value. 13
TypedDataInterface::setValue public function Sets the data value. 1
TypedDataInterface::getValue public function Gets the data value. 1
TypedDataInterface::getType public function Gets the data type. 1
TypedDataInterface::getString public function Returns a string representation of the data. 1
TypedDataInterface::getDefinition public function Gets the data definition. 1
ListInterface::isEmpty public function Determines whether the list contains any non-empty items. 1
FieldInterface::__unset public function Magic method for unset(): Delegates to the first item. 1
FieldInterface::__set public function Magic setter: Delegates to the first item. 1
FieldInterface::__isset public function Magic method for isset(): Delegates to the first item. 1
FieldInterface::__get public function Magic getter: Delegates to the first item. 1
FieldInterface::getPropertyDefinitions public function Delegates to the first item. 1
FieldInterface::getPropertyDefinition public function Delegates to the first item. 1
FieldInterface::get public function Delegates to the first item. 1
ContextAwareInterface::setParent public function Sets the parent of a property or item. 6
ContextAwareInterface::setName public function Sets the name of a property or item. 6
ContextAwareInterface::getParent public function Returns the parent data structure; i.e. either complex data or a list. 6
ContextAwareInterface::getName public function Returns the name of a property or item. 6
AccessibleInterface::access public function Checks data value access. 4