You are here

function entity_defaults_rebuild in Entity API 7

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'.

Parameters

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

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

File

./entity.module, line 858

Code

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) {
    _entity_defaults_rebuild($type);
  }
}