function ArchiverManager::getInstance
Same name in other branches
- 9 core/lib/Drupal/Core/Archiver/ArchiverManager.php \Drupal\Core\Archiver\ArchiverManager::getInstance()
- 8.9.x core/lib/Drupal/Core/Archiver/ArchiverManager.php \Drupal\Core\Archiver\ArchiverManager::getInstance()
- 11.x core/lib/Drupal/Core/Archiver/ArchiverManager.php \Drupal\Core\Archiver\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\ArchiverCode
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);
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.