summaryrefslogtreecommitdiffstatshomepage
path: root/core/lib/Drupal/Core/Archiver/ArchiverInterface.php
blob: 075c6f1da01658a18f19ccc9ebcbb2eb2e90c217 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php

namespace Drupal\Core\Archiver;

/**
 * Defines the common interface for all Archiver classes.
 *
 * @see \Drupal\Core\Archiver\ArchiverManager
 * @see \Drupal\Core\Archiver\Attribute\Archiver
 * @see plugin_api
 */
interface ArchiverInterface {

  /**
   * Adds the specified file or directory to the archive.
   *
   * @param string $file_path
   *   The full system path of the file or directory to add. Only local files
   *   and directories are supported.
   *
   * @return $this
   *   The called object.
   */
  public function add($file_path);

  /**
   * Removes the specified file from the archive.
   *
   * @param string $path
   *   The file name relative to the root of the archive to remove.
   *
   * @return $this
   *   The called object.
   */
  public function remove($path);

  /**
   * Extracts multiple files in the archive to the specified path.
   *
   * @param string $path
   *   A full system path of the directory to which to extract files.
   * @param 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 $this
   *   The called object.
   */
  public function extract($path, array $files = []);

  /**
   * Lists all files in the archive.
   *
   * @return array
   *   An array of file names relative to the root of the archive.
   */
  public function listContents();

}