interface FieldInterface

Same name in this branch

Interface for fields, being lists of field items.

This interface must be implemented by every entity field, whereas contained field items must implement the FieldItemInterface. Some methods of the fields 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

13 files declare their use of FieldInterface
EmailItemTest.php in drupal/core/modules/email/lib/Drupal/email/Tests/EmailItemTest.php
Contains \Drupal\email\Tests\EmailItemTest.
EntityFieldTest.php in drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php
Definition of Drupal\system\Tests\Entity\EntityFieldTest.
EntityReferenceItemTest.php in drupal/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceItemTest.php
Contains \Drupal\entity_reference\Tests\EntityReferenceItemTest.
EntityValidationTest.php in drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityValidationTest.php
Contains \Drupal\system\Tests\Entity\EntityValidationTest.
Field.php in drupal/core/lib/Drupal/Core/Entity/Field/Type/Field.php
Contains \Drupal\Core\Entity\Field\Type\Field.

... See full list

File

drupal/core/lib/Drupal/Core/Entity/Field/FieldInterface.php, line 28
Contains \Drupal\Core\Entity\Field\FieldInterface.

Namespace

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

  /**
   * Filters out empty field items and re-numbers the item deltas.
   */
  public function filterEmptyValues();

  /**
   * Gets a property object from the first field item.
   *
   * @see \Drupal\Core\Entity\Field\FieldItemInterface::get()
   */
  public function get($property_name);

  /**
   * Magic method: Gets a property value of to the first field item.
   *
   * @see \Drupal\Core\Entity\Field\FieldItemInterface::__get()
   */
  public function __get($property_name);

  /**
   * Magic method: Sets a property value of the first field item.
   *
   * @see \Drupal\Core\Entity\Field\FieldItemInterface::__set()
   */
  public function __set($property_name, $value);

  /**
   * Magic method: Determines whether a property of the first field item is set.
   *
   * @see \Drupal\Core\Entity\Field\FieldItemInterface::__isset()
   */
  public function __isset($property_name);

  /**
   * Magic method: Unsets a property of the first field item.
   *
   * @see \Drupal\Core\Entity\Field\FieldItemInterface::__unset()
   */
  public function __unset($property_name);

  /**
   * Gets the definition of a property of the first field item.
   *
   * @see \Drupal\Core\Entity\Field\FieldItemInterface::getPropertyDefinition()
   */
  public function getPropertyDefinition($name);

  /**
   * Gets an array of property definitions of the first field item.
   *
   * @see \Drupal\Core\Entity\Field\FieldItemInterface::getPropertyDefinitions()
   */
  public function getPropertyDefinitions();

}

Members

Namesort descending Modifiers Type Description Overrides
AccessibleInterface::access public function Checks data value access. 5
FieldInterface::filterEmptyValues public function Filters out empty field items and re-numbers the item deltas. 1
FieldInterface::get public function Gets a property object from the first field item. 1
FieldInterface::getPropertyDefinition public function Gets the definition of a property of the first field item. 1
FieldInterface::getPropertyDefinitions public function Gets an array of property definitions of the first field item. 1
FieldInterface::__get public function Magic method: Gets a property value of to the first field item. 1
FieldInterface::__isset public function Magic method: Determines whether a property of the first field item is set. 1
FieldInterface::__set public function Magic method: Sets a property value of the first field item. 1
FieldInterface::__unset public function Magic method: Unsets a property of the first field item. 1
ListInterface::getItemDefinition public function Gets the definition of a contained item. 2
ListInterface::isEmpty public function Determines whether the list contains any non-empty items. 2
ListInterface::onChange public function React to changes to a child item. 2
TypedDataInterface::getConstraints public function Gets a list of validation constraints. 4
TypedDataInterface::getDefinition public function Gets the data definition. 4
TypedDataInterface::getName public function Returns the name of a property or item. 4
TypedDataInterface::getParent public function Returns the parent data structure; i.e. either complex data or a list. 4
TypedDataInterface::getPropertyPath public function Returns the property path of the data. 4
TypedDataInterface::getRoot public function Returns the root of the typed data tree. 4
TypedDataInterface::getString public function Returns a string representation of the data. 4
TypedDataInterface::getType public function Gets the data type. 5
TypedDataInterface::getValue public function Gets the data value. 4
TypedDataInterface::setContext public function Sets the context of a property or item via a context aware parent. 4
TypedDataInterface::setValue public function Sets the data value. 4
TypedDataInterface::validate public function Validates the currently set data value. 4