_update_manager_extract_directory example

    $session->set('maintenance_mode', $this->state->get('system.maintenance_mode'));
    if ($form_state->getValue('maintenance_mode') == TRUE) {
      $this->state->set('system.maintenance_mode', TRUE);
    }

    $projects = $session->remove('update_manager_update_projects');
    if ($projects) {
      // Make sure the Updater registry is loaded.       drupal_get_updaters();

      $updates = [];
      $directory = _update_manager_extract_directory();

      $project_real_location = NULL;
      foreach ($projects as $project => $url) {
        $project_location = $directory . '/' . $project;
        $updater = Updater::factory($project_location$this->root);
        $project_real_location = \Drupal::service('file_system')->realpath($project_location);
        $updates[] = [
          'project' => $project,
          'updater_name' => get_class($updater),
          'local_url' => $project_real_location,
        ];
      }
$this->cronRun();
    $this->drupalGet('admin/modules');
    $this->assertSession()->pageTextNotContains('No update information available.');
  }

  /** * Checks that clearing the disk cache works. */
  public function testClearDiskCache() {
    $directories = [
      _update_manager_cache_directory(FALSE),
      _update_manager_extract_directory(FALSE),
    ];
    // Check that update directories does not exists.     foreach ($directories as $directory) {
      $this->assertDirectoryDoesNotExist($directory);
    }

    // Method must not fail if update directories do not exists.     update_clear_update_disk_cache();
  }

  /** * Checks the messages at admin/modules when the site is up to date. */

    elseif (!empty($all_files['project_upload']) && $this->moduleHandler->moduleExists('file')) {
      $validators = ['file_validate_extensions' => [$this->archiverManager->getExtensions()]];
      if (!($finfo = file_save_upload('project_upload', $validators, NULL, 0, FileSystemInterface::EXISTS_REPLACE))) {
        // Failed to upload the file. file_save_upload() calls         // \Drupal\Core\Messenger\MessengerInterface::addError() on failure.         return;
      }
      $local_cache = $finfo->getFileUri();
    }

    $directory = _update_manager_extract_directory();
    try {
      $archive = update_manager_archive_extract($local_cache$directory);
    }
    catch (\Exception $e) {
      $this->messenger()->addError($e->getMessage());
      return;
    }

    $files = $archive->listContents();
    if (!$files) {
      $this->messenger()->addError($this->t('Provided archive contains no files.'));
      
Home | Imprint | This part of the site doesn't use cookies.