Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ArchiverManager.php

function ArchiverManager::getInstance

Overrides PluginManagerBase::getInstance

File

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

Class

ArchiverManager
Provides an Archiver plugin manager.

Namespace

Drupal\Core\Archiver

Code

public function getInstance(array $options) {
    $filepath = $options['filepath'];
    foreach ($this->getDefinitions() as $plugin_id => $definition) {
        foreach ($definition['extensions'] as $extension) {
            // Because extensions may be multi-part, such as .tar.gz,
            // we cannot use simpler approaches like substr() or pathinfo().
            // This method isn't quite as clean but gets the job done.
            // Also note that the file may not yet exist, so we cannot rely
            // on fileinfo() or other disk-level utilities.
            if (strrpos($filepath, '.' . $extension) === strlen($filepath) - strlen('.' . $extension)) {
                return $this->createInstance($plugin_id, $options);
            }
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal