function Zip::extract

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Archiver/Zip.php \Drupal\Core\Archiver\Zip::extract()
  2. 8.9.x core/lib/Drupal/Core/Archiver/Zip.php \Drupal\Core\Archiver\Zip::extract()
  3. 11.x core/lib/Drupal/Core/Archiver/Zip.php \Drupal\Core\Archiver\Zip::extract()

Extracts multiple files in the archive to the specified path.

Parameters

string $path: A full system path of the directory to which to extract files.

array $files: Optionally specify a list of files to be extracted. Files are relative to the root of the archive. If not specified, all files in the archive will be extracted.

Return value

$this The called object.

Overrides ArchiverInterface::extract

File

core/lib/Drupal/Core/Archiver/Zip.php, line 60

Class

Zip
Defines an archiver implementation for .zip files.

Namespace

Drupal\Core\Archiver

Code

public function extract($path, array $files = []) {
    if ($files) {
        $this->zip
            ->extractTo($path, $files);
    }
    else {
        $this->zip
            ->extractTo($path);
    }
    return $this;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.