function ArchiverManager::getExtensions

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

Returns a string of supported archive extensions.

Return value

string A space-separated string of extensions suitable for use by the file validation system.

File

core/lib/Drupal/Core/Archiver/ArchiverManager.php, line 83

Class

ArchiverManager
Provides an Archiver plugin manager.

Namespace

Drupal\Core\Archiver

Code

public function getExtensions() {
    $valid_extensions = [];
    foreach ($this->getDefinitions() as $archive) {
        foreach ($archive['extensions'] as $extension) {
            foreach (explode('.', $extension) as $part) {
                if (!in_array($part, $valid_extensions)) {
                    $valid_extensions[] = $part;
                }
            }
        }
    }
    return implode(' ', $valid_extensions);
}

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