BehatServiceProvider::alter()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 2
eloc 3
nc 2
nop 1
1
<?php
2
3
namespace NuvoleWeb\Drupal\DrupalExtension\ServiceProvider;
4
5
use Drupal\Core\DependencyInjection\ContainerBuilder;
6
use Drupal\Core\DependencyInjection\ServiceProviderBase;
7
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
8
9
/**
10
 * Class BehatServiceProvider.
11
 *
12
 * @package NuvoleWeb\Drupal\DrupalExtension\ServiceProvider
13
 */
14
class BehatServiceProvider extends ServiceProviderBase {
15
16
  /**
17
   * {@inheritdoc}
18
   */
19
  public function alter(ContainerBuilder $container) {
20
    foreach ($this->getParameters() as $name => $value) {
21
      $container->setParameter($name, $value);
22
    }
23
  }
24
25
  /**
26
   * Get parameters set in ServiceContainerContext.
27
   *
28
   * @see ServiceContainerContext::overrideParameters()
29
   *
30
   * @return array
31
   *    Array of parameters.
32
   */
33
  protected function getParameters() {
34
    try {
35
      return \Drupal::state()->get('nuvole_web.drupal_extension.parameter_overrides', []);
36
    }
37
    catch (ServiceNotFoundException $e) {
38
      return [];
39
    }
40
  }
41
42
}
43