You are here

public function FlysystemServiceProvider::register in Flysystem 2.0.x

Same name and namespace in other branches
  1. 8 src/FlysystemServiceProvider.php \Drupal\flysystem\FlysystemServiceProvider::register()
  2. 3.x src/FlysystemServiceProvider.php \Drupal\flysystem\FlysystemServiceProvider::register()
  3. 3.0.x src/FlysystemServiceProvider.php \Drupal\flysystem\FlysystemServiceProvider::register()

Registers services to the container.

Parameters

ContainerBuilder $container: The ContainerBuilder to register services to.

Overrides ServiceProviderInterface::register

File

src/FlysystemServiceProvider.php, line 20

Class

FlysystemServiceProvider
Flysystem dependency injection container.

Namespace

Drupal\flysystem

Code

public function register(ContainerBuilder $container) {
  $this
    ->swapDumper($container, 'js');
  $this
    ->swapDumper($container, 'css');
  foreach (Settings::get('flysystem', []) as $scheme => $settings) {

    // Just some sanity checking, so things don't explode.
    if (empty($settings['driver'])) {
      continue;
    }
    $container
      ->register('flysystem_stream_wrapper.' . $scheme, 'Drupal\\flysystem\\FlysystemBridge')
      ->addTag('stream_wrapper', [
      'scheme' => $scheme,
    ]);

    // Register the path processors for local files.
    if ($settings['driver'] === 'local' && !empty($settings['config']['public'])) {
      $container
        ->register('flysystem.' . $scheme . '.path_processor', 'Drupal\\flysystem\\PathProcessor\\LocalPathProcessor')
        ->addTag('path_processor_inbound', [
        'priority' => 400,
      ])
        ->addArgument($scheme);
    }
  }
}