You are here

function entity_create in Entity API 7

Create a new entity object.

Parameters

$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

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

See also

entity_type_supports()

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

... See full list

File

./entity.module, line 468

Code

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;
}