function entity_defaults_rebuild

7.x entity.module entity_defaults_rebuild($entity_types = NULL)

Rebuild the default entities provided in code.

Exportable entities provided in code get saved to the database once a module providing defaults in code is activated. This allows module and entity_load() to easily deal with exportable entities just by relying on the database.

The defaults get rebuilt if the cache is cleared or new modules providing defaults are enabled, such that the defaults in the database are up to date. A default entity gets updated with the latest defaults in code during rebuild as long as the default has not been overridden. Once a module providing defaults is disabled, its default entities get removed from the database unless they have been overridden. In that case the overridden entity is left in the database, but its status gets updated to 'custom'.


$entity_types: (optional) If specified, only the defaults of the given entity types are rebuilt.

3 calls to entity_defaults_rebuild()
EntityAPIControllerExportable::delete in entity/includes/
Overridden to care about reverted entities.
EntityAPITestCase::testExportables in entity/entity.test
Test loading entities defined in code.
entity_flush_caches in entity/entity.module
Implements hook_flush_caches().


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


function entity_defaults_rebuild($entity_types = NULL) {
  if (!isset($entity_types)) {
    $entity_types = array();
    foreach (entity_crud_get_info() as $type => $info) {
      if (!empty($info['exportable'])) {
        $entity_types[] = $type;
  foreach ($entity_types as $type) {