You are here

public function S3fsServiceProvider::alter in S3 File System 8.3

Same name and namespace in other branches
  1. 8.2 src/S3fsServiceProvider.php \Drupal\s3fs\S3fsServiceProvider::alter()
  2. 4.0.x src/S3fsServiceProvider.php \Drupal\s3fs\S3fsServiceProvider::alter()

Modifies existing service definitions.

Parameters

\Drupal\Core\DependencyInjection\ContainerBuilder $container: The ContainerBuilder whose service definitions can be altered.

Overrides ServiceProviderBase::alter

File

src/S3fsServiceProvider.php, line 24

Class

S3fsServiceProvider
The stream wrapper class.

Namespace

Drupal\s3fs

Code

public function alter(ContainerBuilder $container) {
  if (Settings::get('s3fs.use_s3_for_public')) {

    // Replace the public stream wrapper with S3fsStream.
    $container
      ->getDefinition('stream_wrapper.public')
      ->setClass('Drupal\\s3fs\\StreamWrapper\\PublicS3fsStream');

    // Fix CSS static urls.
    $container
      ->getDefinition('asset.css.optimizer')
      ->setClass('Drupal\\s3fs\\Asset\\S3fsCssOptimizer')
      ->addArgument(new Reference('config.factory'));
  }
  if (Settings::get('s3fs.use_s3_for_private') && $container
    ->hasDefinition('stream_wrapper.private')) {

    // Replace the private stream wrapper with S3fsStream.
    $container
      ->getDefinition('stream_wrapper.private')
      ->setClass('Drupal\\s3fs\\StreamWrapper\\PrivateS3fsStream');
  }
}