You are here

protected function FlysystemFactory::getAdapter in Flysystem 3.x

Same name and namespace in other branches
  1. 8 src/FlysystemFactory.php \Drupal\flysystem\FlysystemFactory::getAdapter()
  2. 7 src/FlysystemFactory.php \Drupal\flysystem\FlysystemFactory::getAdapter()
  3. 2.0.x src/FlysystemFactory.php \Drupal\flysystem\FlysystemFactory::getAdapter()
  4. 3.0.x src/FlysystemFactory.php \Drupal\flysystem\FlysystemFactory::getAdapter()

Returns the adapter for a scheme.

Parameters

string $scheme: The scheme to find an adapter for.

Return value

\League\Flysystem\AdapterInterface The correct adapter from settings.

1 call to FlysystemFactory::getAdapter()
FlysystemFactory::getFilesystem in src/FlysystemFactory.php
Returns the filesystem for a given scheme.

File

src/FlysystemFactory.php, line 210

Class

FlysystemFactory
A factory for Flysystem filesystems.

Namespace

Drupal\flysystem

Code

protected function getAdapter($scheme) {
  $settings = $this
    ->getSettings($scheme);
  $adapter = $this
    ->getPlugin($scheme)
    ->getAdapter();
  if ($settings['replicate']) {
    $replica = $this
      ->getAdapter($settings['replicate']);
    $adapter = new ReplicateAdapter($adapter, $replica);
  }
  if ($settings['cache']) {
    $cache_item_backend = new CacheItemBackend($scheme, $this->cacheBackend);
    $adapter = new DrupalCacheAdapter($scheme, $adapter, $cache_item_backend);
  }
  return $adapter;
}