Skip to content

Commit

Permalink
Fix driver config loading
Browse files Browse the repository at this point in the history
  • Loading branch information
Tibor Kotosz committed Nov 13, 2015
1 parent 430db65 commit e6e6b19
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions src/Bex/Behat/ExtensionDriverLocator/DriverLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,16 @@ public static function getInstance($namespace, $parent = '')

/**
* @param ContainerBuilder $container
* @param array $configs
* @param array $activeDrivers
* @param array $driverConfigs
*
* @return DriverInterface[]
*/
public function findDrivers(ContainerBuilder $container, array $activeDrivers, array $driverConfigs)
{
$driverConfigs = $this->removeUnusedDrivers($activeDrivers, $driverConfigs);
$this->createDrivers($activeDrivers);
$configTree = $this->configureDrivers($driverConfigs);
$configTree = $this->configureDrivers();
$driverConfigs = $this->processDriverConfiguration($configTree, $driverConfigs);
$this->loadDrivers($container, $driverConfigs);

Expand All @@ -65,6 +67,23 @@ public function getDrivers()
return $this->drivers;
}

/**
* @param array $activeDrivers
* @param array $driverConfigs
*
* @return array
*/
private function removeUnusedDrivers($activeDrivers, $driverConfigs)
{
foreach ($driverConfigs as $driverKey => $driverConfig) {
if (!in_array($driverKey, $activeDrivers)) {
unset($driverConfigs[$driverKey]);
}
}

return $driverConfigs;
}

/**
* @param array $driverKeys
*
Expand All @@ -83,11 +102,9 @@ private function createDrivers($driverKeys)
}

/**
* @param array $driverConfigs
*
* @return NodeInterface
*/
private function configureDrivers($driverConfigs)
private function configureDrivers()
{
$tree = new TreeBuilder();
$root = $tree->root('drivers');
Expand Down

0 comments on commit e6e6b19

Please sign in to comment.