interface EntityInterface

Same name in this branch

Defines a common interface for all entity objects.

This interface builds upon the general interfaces provided by the typed data API, while extending them with entity-specific additions. I.e., an entity implements the ComplexDataInterface among others, thus is complex data containing fields as its data properties. The contained fields have to implement the \Drupal\Core\Entity\Field\FieldInterface, which builds upon typed data interfaces as well.

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 EntityInterface

All classes that implement EntityInterface

See also

\Drupal\Core\TypedData\TypedDataManager

\Drupal\Core\Field\FieldInterface

206 files declare their use of EntityInterface
ActionListController.php in drupal/core/modules/action/lib/Drupal/action/ActionListController.php
Contains \Drupal\action\ActionListController.
ActionStorageController.php in drupal/core/modules/system/lib/Drupal/system/ActionStorageController.php
Contains \Drupal\system\ActionStorageController.
aggregator.pages.inc in drupal/core/modules/aggregator/aggregator.pages.inc
User page callbacks for the Aggregator module.
BlockAccessController.php in drupal/core/modules/block/lib/Drupal/block/BlockAccessController.php
Contains \Drupal\block\BlockAccessController.
BlockRenderController.php in drupal/core/modules/block/lib/Drupal/block/BlockRenderController.php
Contains \Drupal\block\BlockRenderController.

... See full list

1 string reference to 'EntityInterface'
ClassMetadataFactoryTest::testMergeParentConstraints in drupal/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/ClassMetadataFactoryTest.php

File

drupal/core/lib/Drupal/Core/Entity/EntityInterface.php, line 30
Contains \Drupal\Core\Entity\EntityInterface.

Namespace

Drupal\Core\Entity
View source
interface EntityInterface extends ComplexDataInterface, AccessibleInterface, TranslatableInterface {

  /**
   * Returns the entity identifier (the entity's machine name or numeric ID).
   *
   * @return
   *   The identifier of the entity, or NULL if the entity does not yet have
   *   an identifier.
   */
  public function id();

  /**
   * Returns the entity UUID (Universally Unique Identifier).
   *
   * The UUID is guaranteed to be unique and can be used to identify an entity
   * across multiple systems.
   *
   * @return string
   *   The UUID of the entity, or NULL if the entity does not have one.
   */
  public function uuid();

  /**
   * Returns whether the entity is new.
   *
   * Usually an entity is new if no ID exists for it yet. However, entities may
   * be enforced to be new with existing IDs too.
   *
   * @return
   *   TRUE if the entity is new, or FALSE if the entity has already been saved.
   *
   * @see \Drupal\Core\Entity\EntityInterface::enforceIsNew()
   */
  public function isNew();

  /**
   * Returns whether a new revision should be created on save.
   *
   * @return bool
   *   TRUE if a new revision should be created.
   *
   * @see \Drupal\Core\Entity\EntityInterface::setNewRevision()
   */
  public function isNewRevision();

  /**
   * Enforces an entity to be saved as a new revision.
   *
   * @param bool $value
   *   (optional) Whether a new revision should be saved.
   *
   * @see \Drupal\Core\Entity\EntityInterface::isNewRevision()
   */
  public function setNewRevision($value = TRUE);

  /**
   * Enforces an entity to be new.
   *
   * Allows migrations to create entities with pre-defined IDs by forcing the
   * entity to be new before saving.
   *
   * @param bool $value
   *   (optional) Whether the entity should be forced to be new. Defaults to
   *   TRUE.
   *
   * @see \Drupal\Core\Entity\EntityInterface::isNew()
   */
  public function enforceIsNew($value = TRUE);

  /**
   * Returns the type of the entity.
   *
   * @return
   *   The type of the entity.
   */
  public function entityType();

  /**
   * Returns the bundle of the entity.
   *
   * @return
   *   The bundle of the entity. Defaults to the entity type if the entity type
   *   does not make use of different bundles.
   */
  public function bundle();

  /**
   * Returns the label of the entity.
   *
   * @param $langcode
   *   (optional) The language code of the language that should be used for
   *   getting the label. If set to NULL, the entity's default language is
   *   used.
   *
   * @return
   *   The label of the entity, or NULL if there is no label defined.
   */
  public function label($langcode = NULL);

  /**
   * Returns the URI elements of the entity.
   *
   * @return
   *   An array containing the 'path' and 'options' keys used to build the URI
   *   of the entity, and matching the signature of url().
   */
  public function uri();

  /**
   * Returns a list of URI relationships supported by this entity.
   *
   * @return array
   *   An array of link relationships supported by this entity.
   */
  public function uriRelationships();

  /**
   * Saves an entity permanently.
   *
   * @return
   *   Either SAVED_NEW or SAVED_UPDATED, depending on the operation performed.
   *
   * @throws \Drupal\Core\Entity\EntityStorageException
   *   In case of failures an exception is thrown.
   */
  public function save();

  /**
   * Deletes an entity permanently.
   *
   * @throws \Drupal\Core\Entity\EntityStorageException
   *   In case of failures an exception is thrown.
   */
  public function delete();

  /**
   * Creates a duplicate of the entity.
   *
   * @return \Drupal\Core\Entity\EntityInterface
   *   A clone of the current entity with all identifiers unset, so saving
   *   it inserts a new entity into the storage system.
   */
  public function createDuplicate();

  /**
   * Returns the info of the type of the entity.
   *
   * @see entity_get_info()
   */
  public function entityInfo();

  /**
   * Returns the revision identifier of the entity.
   *
   * @return
   *   The revision identifier of the entity, or NULL if the entity does not
   *   have a revision identifier.
   */
  public function getRevisionId();

  /**
   * Checks if this entity is the default revision.
   *
   * @param bool $new_value
   *   (optional) A Boolean to (re)set the isDefaultRevision flag.
   *
   * @return bool
   *   TRUE if the entity is the default revision, FALSE otherwise. If
   *   $new_value was passed, the previous value is returned.
   */
  public function isDefaultRevision($new_value = NULL);

  /**
   * Retrieves the exportable properties of the entity.
   *
   * @return array
   *   An array of exportable properties and their values.
   */
  public function getExportProperties();

  /**
   * Gets a backward compatibility decorator entity.
   *
   * @return \Drupal\Core\Entity\EntityInterface
   *   The backward compatible entity.
   *
   * @see \Drupal\Core\Entity\EntityInterface::getNGEntity()
   */
  public function getBCEntity();

  /**
   * Removes any possible (backward compatibility) decorator in use.
   *
   * @return \Drupal\Core\Entity\EntityInterface
   *   The original, not backward compatible entity object.
   *
   * @see \Drupal\Core\Entity\EntityInterface::getBCEntity()
   */
  public function getNGEntity();

  /**
   * Returns the translation support status.
   *
   * @return bool
   *   TRUE if the entity bundle has translation support enabled.
   */
  public function isTranslatable();

}

Members

Namesort descending Modifiers Type Description Overrides
AccessibleInterface::access public function Checks data value access. 5
ComplexDataInterface::get public function Gets a property object. 7
ComplexDataInterface::getProperties public function Gets an array of property objects. 7
ComplexDataInterface::getPropertyDefinition public function Gets the definition of a contained property. 7
ComplexDataInterface::getPropertyDefinitions public function Gets an array of property definitions of contained properties. 7
ComplexDataInterface::getPropertyValues public function Gets an array of property values. 7
ComplexDataInterface::isEmpty public function Determines whether the data structure is empty. 7
ComplexDataInterface::onChange public function React to changes to a child property. 7
ComplexDataInterface::set public function Sets a property value. 7
ComplexDataInterface::setPropertyValues public function Sets multiple property values. 7
EntityInterface::bundle public function Returns the bundle of the entity. 3
EntityInterface::createDuplicate public function Creates a duplicate of the entity. 3
EntityInterface::delete public function Deletes an entity permanently. 3
EntityInterface::enforceIsNew public function Enforces an entity to be new. 3
EntityInterface::entityInfo public function Returns the info of the type of the entity. 3
EntityInterface::entityType public function Returns the type of the entity. 3
EntityInterface::getBCEntity public function Gets a backward compatibility decorator entity. 3
EntityInterface::getExportProperties public function Retrieves the exportable properties of the entity. 3
EntityInterface::getNGEntity public function Removes any possible (backward compatibility) decorator in use. 3
EntityInterface::getRevisionId public function Returns the revision identifier of the entity. 3
EntityInterface::id public function Returns the entity identifier (the entity's machine name or numeric ID). 3
EntityInterface::isDefaultRevision public function Checks if this entity is the default revision. 3
EntityInterface::isNew public function Returns whether the entity is new. 3
EntityInterface::isNewRevision public function Returns whether a new revision should be created on save. 3
EntityInterface::isTranslatable public function Returns the translation support status. 3
EntityInterface::label public function Returns the label of the entity. 3
EntityInterface::save public function Saves an entity permanently. 3
EntityInterface::setNewRevision public function Enforces an entity to be saved as a new revision. 3
EntityInterface::uri public function Returns the URI elements of the entity. 3
EntityInterface::uriRelationships public function Returns a list of URI relationships supported by this entity. 3
EntityInterface::uuid public function Returns the entity UUID (Universally Unique Identifier). 3
TranslatableInterface::getTranslation public function Gets a translation of the data. 3
TranslatableInterface::getTranslationLanguages public function Returns the languages the data is translated to. 3
TranslatableInterface::language public function Returns the default language. 3
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