FieldItemInterface.php

Definition of Drupal\Core\Entity\Field\FieldItemInterface.

Namespace

Drupal\Core\Entity\Field

File

drupal/core/lib/Drupal/Core/Entity/Field/FieldItemInterface.php
View source
<?php

/**
 * @file
 * Definition of Drupal\Core\Entity\Field\FieldItemInterface.
 */
namespace Drupal\Core\Entity\Field;

use Drupal\Core\TypedData\ComplexDataInterface;
use Drupal\Core\TypedData\ContextAwareInterface;
use Drupal\Core\TypedData\TypedDataInterface;

/**
 * Interface for entity field items, which are complex data objects
 * containing the values.
 *
 * When implementing this interface which extends Traversable, make sure to list
 * IteratorAggregate or Iterator before this interface in the implements clause.
 *
 * @see \Drupal\Core\Entity\Field\FieldInterface
 * @see \Drupal\Core\Entity\Field\FieldItemBase
 */
interface FieldItemInterface extends ComplexDataInterface, ContextAwareInterface, TypedDataInterface {

  /**
   * Magic getter: Get the property value.
   *
   * @param $property_name
   *   The name of the property to get; e.g., 'title' or 'name'.
   *
   * @throws \InvalidArgumentException
   *   If a not existing property is accessed.
   *
   * @return \Drupal\Core\TypedData\TypedDataInterface
   *   The property object.
   */
  public function __get($property_name);

  /**
   * Magic setter: Set the property value.
   *
   * @param $property_name
   *   The name of the property to set; e.g., 'title' or 'name'.
   * @param $value
   *   The value to set, or NULL to unset the property. Optionally, a typed
   *   data object implementing Drupal\Core\TypedData\TypedDataInterface may be
   *   passed instead of a plain value.
   *
   * @throws \InvalidArgumentException
   *   If a not existing property is set.
   */
  public function __set($property_name, $value);

  /**
   * Magic method for isset().
   *
   * @param $property_name
   *   The name of the property to get; e.g., 'title' or 'name'.
   *
   * @return boolean
   *   Returns TRUE if the property exists and is set, FALSE otherwise.
   */
  public function __isset($property_name);

  /**
   * Magic method for unset().
   *
   * @param $property_name
   *   The name of the property to get; e.g., 'title' or 'name'.
   */
  public function __unset($property_name);

}

Interfaces

Namesort descending Description
FieldItemInterface Interface for entity field items, which are complex data objects containing the values.