update_manager_archive_extract example

$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.'));
      return;
    }

    
Home | Imprint | This part of the site doesn't use cookies.