You are here

protected static function InPlaceUpdate::processUpdate in Automatic Updates 7

Process update.

Parameters

\ArchiverZip $archive: The archive.

string $project_root: The project root directory.

Return value

bool Return TRUE if update succeeds, FALSE otherwise.

1 call to InPlaceUpdate::processUpdate()
InPlaceUpdate::update in ./InPlaceUpdate.php

File

./InPlaceUpdate.php, line 216

Class

InPlaceUpdate
Class to apply in-place updates.

Code

protected static function processUpdate(\ArchiverZip $archive, $project_root) {
  $archive
    ->extract(self::getTempDirectory());
  foreach (self::getFilesList(self::getTempDirectory()) as $file) {
    $file_real_path = self::getFileRealPath($file);
    $file_path = substr($file_real_path, strlen(self::getTempDirectory() . self::ARCHIVE_DIRECTORY));
    $project_real_path = self::getProjectRealPath($file_path, $project_root);
    $directory = dirname($project_real_path);
    file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
    file_unmanaged_copy($file_real_path, $project_real_path, FILE_EXISTS_REPLACE);
    watchdog('automatic_updates', '"@file" was updated.', [
      '@file' => $project_real_path,
    ], WATCHDOG_INFO);
  }
  foreach (self::getDeletions() as $deletion) {
    $file_deletion = self::getProjectRealPath($deletion, $project_root);
    file_unmanaged_delete($file_deletion);
    watchdog('automatic_updates', '"@file" was deleted.', [
      '@file' => $file_deletion,
    ], WATCHDOG_INFO);
  }
  return TRUE;
}