interface ComplexDataInterface

Interface for complex data; i.e. data containing named and typed properties.

This is implemented by entities as well as by field item classes of entities.

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 ComplexDataInterface

All classes that implement ComplexDataInterface

6 files declare their use of ComplexDataInterface
EntityInterface.php in drupal/core/lib/Drupal/Core/Entity/EntityInterface.php
Definition of Drupal\Core\Entity\EntityInterface.
EntityTranslation.php in drupal/core/lib/Drupal/Core/Entity/Field/Type/EntityTranslation.php
Definition of Drupal\Core\Entity\Type\EntityTranslation.
EntityTranslationUITest.php in drupal/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationUITest.php
Definition of Drupal\entity\Tests\EntityTranslationUITest.
EntityWrapper.php in drupal/core/lib/Drupal/Core/Entity/Field/Type/EntityWrapper.php
Definition of Drupal\Core\Entity\Field\Type\EntityWrapper.
FieldItemBase.php in drupal/core/lib/Drupal/Core/Entity/Field/FieldItemBase.php
Definition of Drupal\Core\Entity\Field\FieldItemBase.

... See full list

File

drupal/core/lib/Drupal/Core/TypedData/ComplexDataInterface.php, line 21
Definition of Drupal\Core\TypedData\ComplexDataInterface.

Namespace

Drupal\Core\TypedData
View source
interface ComplexDataInterface extends Traversable {

  /**
   * Gets a property object.
   *
   * @param $property_name
   *   The name of the property to get; e.g., 'title' or 'name'.
   *
   * @throws \InvalidArgumentException
   *   If an invalid property name is given.
   *
   * @return \Drupal\Core\TypedData\TypedDataInterface
   *   The property object.
   */
  public function get($property_name);

  /**
   * Sets a 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.
   *
   * @throws \InvalidArgumentException
   *   If the specified property does not exist.
   *
   * @return \Drupal\Core\TypedData\TypedDataInterface
   *   The property object.
   */
  public function set($property_name, $value);

  /**
   * Gets an array of property objects.
   *
   * @param bool $include_computed
   *   If set to TRUE, computed properties are included. Defaults to FALSE.
   *
   * @return array
   *   An array of property objects implementing the TypedDataInterface, keyed
   *   by property name.
   */
  public function getProperties($include_computed = FALSE);

  /**
   * Gets an array of property values.
   *
   * Gets an array of plain property values including all not-computed
   * properties.
   *
   * @return array
   *   An array keyed by property name containing the property value.
   */
  public function getPropertyValues();

  /**
   * Sets multiple property values.
   *
   * @param array
   *   The array of property values to set, keyed by property name.
   *
   * @throws \InvalidArgumentException
   *   If the value of a not existing property is to be set.
   * @throws \Drupal\Core\TypedData\ReadOnlyException
   *   If a read-only property is set.
   */
  public function setPropertyValues($values);

  /**
   * Gets the definition of a contained property.
   *
   * @param string $name
   *   The name of property.
   *
   * @return array|FALSE
   *   The definition of the property or FALSE if the property does not exist.
   */
  public function getPropertyDefinition($name);

  /**
   * Gets an array property definitions of contained properties.
   *
   * @param array $definition
   *   The definition of the container's property, e.g. the definition of an
   *   entity reference property.
   *
   * @return array
   *   An array of property definitions of contained properties, keyed by
   *   property name.
   */
  public function getPropertyDefinitions();

  /**
   * Determines whether the data structure is empty.
   *
   * @return boolean
   *   TRUE if the data structure is empty, FALSE otherwise.
   */
  public function isEmpty();

}

Members

Namesort descending Modifiers Type Description Overrides
ComplexDataInterface::get public function Gets a property object. 5
ComplexDataInterface::getProperties public function Gets an array of property objects. 5
ComplexDataInterface::getPropertyDefinition public function Gets the definition of a contained property. 5
ComplexDataInterface::getPropertyDefinitions public function Gets an array property definitions of contained properties. 12
ComplexDataInterface::getPropertyValues public function Gets an array of property values. 5
ComplexDataInterface::isEmpty public function Determines whether the data structure is empty. 5
ComplexDataInterface::set public function Sets a property value. 5
ComplexDataInterface::setPropertyValues public function Sets multiple property values. 5