You are here

public static function EntityUpdate::entityUpdateDataRestore in Entity Update 8

Same name and namespace in other branches
  1. 2.0.x src/EntityUpdate.php \Drupal\entity_update\EntityUpdate::entityUpdateDataRestore()

Restore entities after an update.

Return value

bool Restore success

5 calls to EntityUpdate::entityUpdateDataRestore()
drush_entity_update in ./entity_update.drush.inc
Call back function of entity-update.
EntityUpdate::safeUpdateEntityType in src/EntityUpdate.php
Update an entity type.
EntityUpdate::safeUpdateUninstallFields in src/EntityUpdate.php
Update all entities / Uninstall fields.
EntityUpdateExec::submitFormRescue in src/Form/EntityUpdateExec.php
Run rescue entities.
EntityUpdateFunctionsTest::testEntityUpdateAdvanced in modules/entity_update_tests/src/Tests/EntityUpdateFunctionsTest.php
Entity advanced update simulation.

File

src/EntityUpdate.php, line 228

Class

EntityUpdate
EntityUpdate Main Class.

Namespace

Drupal\entity_update

Code

public static function entityUpdateDataRestore() {

  // Get Database connection.
  $con = Database::getConnection();
  $db_data = $con
    ->select('entity_update', 't')
    ->fields('t')
    ->execute()
    ->fetchAll(\PDO::FETCH_ASSOC);
  if (!$db_data) {
    EntityUpdatePrint::drushLog("ERROR, Data read error", 'error');
    return FALSE;
  }
  foreach ($db_data as $row) {
    $entity_class = $row['entity_class'];
    $entity_data = Json::decode($row['data']);

    // Create Entity.
    $entity = $entity_class::create($entity_data);

    // Save entity.
    $entity
      ->save();
  }
  return TRUE;
}