W3cubDocs

/Drupal 8

function archiver_get_archiver

archiver_get_archiver($file)

Creates the appropriate archiver for the specified file.

Parameters

$file: The full path of the archive file. Note that stream wrapper paths are supported, but not remote ones.

Return value

A newly created instance of the archiver class appropriate for the specified file, already bound to that file. If no appropriate archiver class was found, will return FALSE.

File

core/includes/common.inc, line 1245
Common functions that many Drupal modules will need to reference.

Code

function archiver_get_archiver($file) {
  // Archivers can only work on local paths
  $filepath = drupal_realpath($file);
  if (!is_file($filepath)) {
    throw new Exception(t('Archivers can only operate on local files: %file not supported', array('%file' => $file)));
  }
  return \Drupal::service('plugin.manager.archiver')->getInstance(array('filepath' => $filepath));
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!includes!common.inc/function/archiver_get_archiver/8.1.x