function entity_create

7.x entity.module entity_create($entity_type, array $values)

Create a new entity object.


$entity_type: The type of the entity.

$values: An array of values to set, keyed by property name. If the entity type has bundles the bundle key has to be specified.

Return value

A new instance of the entity type or FALSE if there is no information for the given entity type.

See also


15 calls to entity_create()
EntityAPIi18nItegrationTestCase::testDefaultController in entity/entity.test
Tests the provided default controller.
EntityAPIRulesIntegrationTestCase::testEvents in entity/entity.test
Test the events.
EntityAPITestCase::testCRUD in entity/entity.test
Tests CRUD.
EntityAPITestCase::testCRUDAPIfunctions in entity/entity.test
Tests CRUD API functions: entity_(create|delete|save)
EntityAPITestCase::testCRUDRevisisions in entity/entity.test
Tests CRUD for entities supporting revisions.

... See full list


entity/entity.module, line 458
Module file for the entity API.


function entity_create($entity_type, array $values) {
  $info = entity_get_info($entity_type);
  if (isset($info['creation callback'])) {
    return $info['creation callback']($values, $entity_type);
  elseif (in_array('EntityAPIControllerInterface', class_implements($info['controller class']))) {
    return entity_get_controller($entity_type)->create($values);
  return FALSE;