add enhancement

This commit is contained in:
Nicolas Le Goff
2011-12-28 19:31:38 +01:00
parent 5e07d736e2
commit bcd6719845
3 changed files with 36 additions and 12 deletions

View File

@@ -38,9 +38,9 @@ class Application implements Specification
*/
public function getConfFileFromEnvName($name)
{
if($name === self::EXTENDED_MAIN_KEYWORD)
if ($name === self::EXTENDED_MAIN_KEYWORD)
{
return $this->getMainFile();
return $this->getMainConfigurationFile();
}
return new \SplFileObject(sprintf("%s/config_%s.%s"
@@ -59,7 +59,11 @@ class Application implements Specification
return __DIR__ . '/../../../../../config';
}
public function getMainFile()
/**
*
* {@inheritdoc}
*/
public function getMainConfigurationFile()
{
$path = __DIR__ . '/../../../../../config/config.yml';
return new \SplFileObject($path);

View File

@@ -40,20 +40,38 @@ class Handler
* @param ConfigurationSpecification $configSpec
* @param Parser\ParserInterface $parser
*/
public function __construct(Application $configSpec, Parser $parser)
public function __construct(Specification $configSpec, Parser $parser)
{
$this->confSpecification = $configSpec;
$this->parser = $parser;
}
/**
* Getter
* @return Specification
*/
public function getSpecification()
{
return $this->confSpecification;
}
/**
* Getter
* @return Parser
*/
public function getParser()
{
return $this->parser;
}
/**
* Stacks all envrironnement in $env that extends the loaded configuration file
*
* @param SplFileObject $file File of the current loaded config file
* @param array $envs A stack of conf environnments
* @return array
*/
private function retrieveExtendedEnvFromFile(\SplFileObject $file, Array $allEnvs = array())
public function retrieveExtendedEnvFromFile(\SplFileObject $file, Array $allEnvs = array())
{
$env = $this->parser->parse($file);
@@ -119,7 +137,6 @@ class Handler
*/
public function handle($name)
{
//get the corresepondant file
$file = $this->confSpecification->getConfFileFromEnvName($name);
@@ -171,10 +188,6 @@ class Handler
$searchArray[$k] = $value;
break; //quit
}
else
{
continue;
}
}
}
};

View File

@@ -29,6 +29,13 @@ interface Specification
*/
const EXTENDED_MAIN_KEYWORD = 'main';
/**
* Return the main configuration file
*
* @return \SplFileObject
*/
public function getMainConfigurationFile();
/**
* Return an array of paths that CAN'T be extended by ONLY one or more of their value
* but must be fully replaced with new values