You are here

public function PanopolyTestServiceProvider::alter in Panopoly 8.2

Modifies existing service definitions.

Parameters

ContainerBuilder $container: The ContainerBuilder whose service definitions can be altered.

Overrides ServiceModifierInterface::alter

File

modules/panopoly/panopoly_test/src/PanopolyTestServiceProvider.php, line 30

Class

PanopolyTestServiceProvider
Registers private file system when path set through Behat Drupal Driver.

Namespace

Drupal\panopoly_test

Code

public function alter(ContainerBuilder $container) {
  $state = $container
    ->get('state');
  if ($state instanceof StateInterface) {
    $panopoly_test_private_file_path = $state
      ->get('panopoly_test_private_file_path');
    if ($panopoly_test_private_file_path) {

      // Rebuild the settings singleton.
      $settings = Settings::getAll();
      $settings['file_private_path'] = $panopoly_test_private_file_path;
      new Settings($settings);
      $container
        ->register('stream_wrapper.private', PrivateStream::class)
        ->addTag('stream_wrapper', [
        'scheme' => 'private',
      ]);
    }
  }
}