You are here

interface EntityInterface in Entity API 7

Interface for class based entities.

Hierarchy

Expanded class hierarchy of EntityInterface

All classes that implement EntityInterface

File

includes/entity.inc, line 11
Provides a base class for entities.

View source
interface EntityInterface {

  /**
   * Returns the internal, numeric identifier.
   *
   * Returns the numeric identifier, even if the entity type has specified a
   * name key. In the latter case, the numeric identifier is supposed to be used
   * when dealing generically with entities or internally to refer to an entity,
   * i.e. in a relational database. If unsure, use Entity:identifier().
   */
  public function internalIdentifier();

  /**
   * Returns the entity identifier, i.e. the entities name or numeric id.
   *
   * @return string|int
   *   The identifier of the entity. If the entity type makes use of a name key,
   *   the name is returned, else the numeric id.
   *
   * @see entity_id()
   */
  public function identifier();

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

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

  /**
   * Returns the bundle of the entity.
   *
   * @return string
   *   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 EntityMetadataWrapper of the entity.
   *
   * @return EntityDrupalWrapper
   *   An EntityMetadataWrapper containing the entity.
   */
  public function wrapper();

  /**
   * Returns the label of the entity.
   *
   * Modules may alter the label by specifying another 'label callback' using
   * hook_entity_info_alter().
   *
   * @see entity_label()
   */
  public function label();

  /**
   * Returns the uri of the entity just as entity_uri().
   *
   * Modules may alter the uri by specifying another 'uri callback' using
   * hook_entity_info_alter().
   *
   * @see entity_uri()
   */
  public function uri();

  /**
   * Checks if the entity has a certain exportable status.
   *
   * @param $status
   *   A status constant, i.e. one of ENTITY_CUSTOM, ENTITY_IN_CODE,
   *   ENTITY_OVERRIDDEN or ENTITY_FIXED.
   *
   * @return bool
   *   For exportable entities TRUE if the entity has the status, else FALSE.
   *   In case the entity is not exportable, NULL is returned.
   *
   * @see entity_has_status()
   */
  public function hasStatus($status);

  /**
   * Permanently saves the entity.
   *
   * @see entity_save()
   */
  public function save();

  /**
   * Permanently deletes the entity.
   *
   * @see entity_delete()
   */
  public function delete();

  /**
   * Exports the entity.
   *
   * @see entity_export()
   */
  public function export($prefix = '');

  /**
   * Generate an array for rendering the entity.
   *
   * @see entity_view()
   */
  public function view($view_mode = 'full', $langcode = NULL, $page = NULL);

  /**
   * Builds a structured array representing the entity's content.
   *
   * @see entity_build_content()
   */
  public function buildContent($view_mode = 'full', $langcode = NULL);

  /**
   * Gets the raw, translated value of a property or field.
   *
   * Supports retrieving field translations as well as i18n string translations.
   *
   * Note that this returns raw data values, which might not reflect what
   * has been declared for hook_entity_property_info() as no 'getter callbacks'
   * are invoked or no referenced entities are loaded. For retrieving values
   * reflecting the property info make use of entity metadata wrappers, see
   * entity_metadata_wrapper().
   *
   * @param $property
   *   The name of the property to return; e.g., 'title'.
   * @param $langcode
   *   (optional) The language code of the language to which the value should
   *   be translated. If set to NULL, the default display language is being
   *   used.
   *
   * @return string
   *   The raw, translated property value; or the raw, un-translated value if no
   *   translation is available.
   *
   * @todo Implement an analogous setTranslation() method for updating.
   */
  public function getTranslation($property, $langcode = NULL);

  /**
   * Checks whether the entity is the default revision.
   *
   * @return bool
   *   TRUE if it is the default revision, FALSE otherwise.
   *
   * @see entity_revision_is_default()
   */
  public function isDefaultRevision();

}

Members

Namesort descending Modifiers Type Description Overrides
EntityInterface::buildContent public function Builds a structured array representing the entity's content. 1
EntityInterface::bundle public function Returns the bundle of the entity. 1
EntityInterface::delete public function Permanently deletes the entity. 1
EntityInterface::entityInfo public function Returns the info of the type of the entity. 1
EntityInterface::entityType public function Returns the type of the entity. 1
EntityInterface::export public function Exports the entity. 1
EntityInterface::getTranslation public function Gets the raw, translated value of a property or field. 1
EntityInterface::hasStatus public function Checks if the entity has a certain exportable status. 1
EntityInterface::identifier public function Returns the entity identifier, i.e. the entities name or numeric id. 1
EntityInterface::internalIdentifier public function Returns the internal, numeric identifier. 1
EntityInterface::isDefaultRevision public function Checks whether the entity is the default revision. 1
EntityInterface::label public function Returns the label of the entity. 1
EntityInterface::save public function Permanently saves the entity. 1
EntityInterface::uri public function Returns the uri of the entity just as entity_uri(). 1
EntityInterface::view public function Generate an array for rendering the entity. 1
EntityInterface::wrapper public function Returns the EntityMetadataWrapper of the entity. 1