class ArchiverManager

Archiver plugin manager.

Hierarchy

Expanded class hierarchy of ArchiverManager

1 string reference to 'ArchiverManager'
core.services.yml in drupal/core/core.services.yml
drupal/core/core.services.yml

File

drupal/core/lib/Drupal/Core/Archiver/ArchiverManager.php, line 18

Namespace

Drupal\Core\Archiver
View source
class ArchiverManager extends PluginManagerBase {

  /**
   * Constructs a ArchiverManager object.
   *
   * @param \Traversable $namespaces
   *   An object that implements \Traversable which contains the root paths
   *   keyed by the corresponding namespace to look for plugin implementations,
   */
  public function __construct(\Traversable $namespaces) {
    $this->discovery = new AnnotatedClassDiscovery('Archiver', $namespaces);
    $this->discovery = new AlterDecorator($this->discovery, 'archiver_info');
    $this->discovery = new CacheDecorator($this->discovery, 'archiver_info');
  }

  /**
   * Overrides \Drupal\Component\Plugin\PluginManagerBase::createInstance().
   */
  public function createInstance($plugin_id, array $configuration = array()) {
    $plugin_definition = $this->discovery->getDefinition($plugin_id);
    $plugin_class = DefaultFactory::getPluginClass($plugin_id, $plugin_definition);
    return new $plugin_class($configuration['filepath']);
  }

  /**
   * Implements \Drupal\Core\PluginManagerInterface::getInstance().
   */
  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);
        }
      }
    }
  }

}

Members

Contains filters are case sensitive
Namesort descending Modifiers Type Description
ArchiverManager::createInstance public function Overrides \Drupal\Component\Plugin\PluginManagerBase::createInstance(). Overrides PluginManagerBase::createInstance
ArchiverManager::getInstance public function Implements \Drupal\Core\PluginManagerInterface::getInstance(). Overrides PluginManagerBase::getInstance
ArchiverManager::__construct public function Constructs a ArchiverManager object.
PluginManagerBase::$defaults protected property A set of defaults to be referenced by $this->processDefinition() if additional processing of plugins is necessary or helpful for development purposes.
PluginManagerBase::$discovery protected property The object that discovers plugins managed by this manager.
PluginManagerBase::$factory protected property The object that instantiates plugins managed by this manager.
PluginManagerBase::$mapper protected property The object that returns the preconfigured plugin instance appropriate for a particular runtime condition.
PluginManagerBase::clearCachedDefinitions public function
PluginManagerBase::getDefinition public function
PluginManagerBase::getDefinitions public function
PluginManagerBase::processDefinition public function Performs extra processing on plugin definitions.