1 | <?php |
||
15 | class Behat3SymfonyExtension implements Extension |
||
16 | { |
||
17 | const TEST_CLIENT_SERVICE_ID = 'behat3_symfony_extension.test.client'; |
||
18 | const KERNEL_SERVICE_ID = 'behat3_symfony_extension.kernel'; |
||
19 | |||
20 | /** |
||
21 | * {@inheritdoc} |
||
22 | */ |
||
23 | 1 | public function getConfigKey() |
|
27 | |||
28 | /** |
||
29 | * {@inheritdoc} |
||
30 | */ |
||
31 | 1 | public function initialize(ExtensionManager $extensionManager) |
|
32 | { |
||
33 | 1 | $minExtension = $extensionManager->getExtension('mink'); |
|
34 | 1 | if ($minExtension instanceof MinkExtension) { |
|
35 | 1 | $minExtension->registerDriverFactory(new Behat3SymfonyDriverFactory()); |
|
36 | 1 | } |
|
37 | 1 | } |
|
38 | |||
39 | /** |
||
40 | * {@inheritdoc} |
||
41 | */ |
||
42 | 2 | public function configure(ArrayNodeDefinition $builder) |
|
51 | |||
52 | /** |
||
53 | * {@inheritdoc} |
||
54 | */ |
||
55 | 7 | public function load(ContainerBuilder $container, array $config) |
|
79 | |||
80 | /** |
||
81 | * {@inheritdoc} |
||
82 | */ |
||
83 | 3 | public function process(ContainerBuilder $container) |
|
84 | { |
||
85 | 3 | $bootstrapPath = $container->getParameter('behat3_symfony_extension.kernel.bootstrap'); |
|
86 | 3 | if ($bootstrapPath) { |
|
87 | 2 | require_once($this->normalizePath($container, $bootstrapPath)); |
|
88 | 2 | } |
|
89 | |||
90 | // load kernel |
||
91 | 3 | $container->getDefinition(self::KERNEL_SERVICE_ID) |
|
92 | 3 | ->setFile( |
|
93 | 3 | $this->normalizePath( |
|
94 | 3 | $container, |
|
95 | 3 | $container->getParameter('behat3_symfony_extension.kernel.path') |
|
96 | 3 | ) |
|
97 | 3 | ); |
|
98 | 3 | } |
|
99 | |||
100 | /** |
||
101 | * @param ContainerBuilder $container |
||
102 | * @param string $path |
||
103 | * |
||
104 | * @return string |
||
105 | */ |
||
106 | 3 | protected function normalizePath(ContainerBuilder $container, $path) |
|
107 | { |
||
108 | 3 | $basePath = $container->getParameter('paths.base'); |
|
109 | 3 | $pathUnderBasePath = sprintf('%s/%s', $basePath, $path); |
|
110 | 3 | if (file_exists($pathUnderBasePath)) { |
|
111 | 2 | $path = $pathUnderBasePath; |
|
112 | 2 | } |
|
113 | |||
114 | 3 | return $path; |
|
115 | } |
||
116 | |||
117 | /** |
||
118 | * @param ContainerBuilder $container |
||
119 | * @param array $config |
||
120 | * @param string $baseId |
||
121 | */ |
||
122 | 7 | protected function bindConfigToContainer( |
|
139 | |||
140 | /** |
||
141 | * @param array $config |
||
142 | * @return array |
||
143 | */ |
||
144 | 7 | protected function normalizeConfig(array $config) |
|
152 | |||
153 | /** |
||
154 | * @param ContainerBuilder $container |
||
155 | * @throws \Exception |
||
156 | */ |
||
157 | 6 | protected function checkUtilsExtensionAlreadyLoaded(ContainerBuilder $container) |
|
163 | } |
||
164 |