refactor configuration

This commit is contained in:
Nicolas Le Goff
2012-01-03 14:34:43 +01:00
parent b61ef056e2
commit 2968644c73

View File

@@ -40,7 +40,7 @@ class Core extends \Pimple
*/ */
private $configuration; private $configuration;
public function __construct($environnement) public function __construct($environement = null)
{ {
/** /**
@@ -49,10 +49,13 @@ class Core extends \Pimple
static::initAutoloads(); static::initAutoloads();
/** $handler = new \Alchemy\Phrasea\Core\Configuration\Handler(
* Init conf new \Alchemy\Phrasea\Core\Configuration\Application(),
*/ new \Alchemy\Phrasea\Core\Configuration\Parser\Yaml()
$this->init($environnement); );
$this->configuration = new \Alchemy\Phrasea\Core\Configuration($handler);
$this->configuration->setEnvironnement($environement);
/** /**
* Set version * Set version
@@ -65,10 +68,10 @@ class Core extends \Pimple
/** /**
* Set Entity Manager using configuration * Set Entity Manager using configuration
*/ */
$configuration = $this->getConfiguration(); $doctrineConf = $this->configuration->getDoctrine()->all();
$this['EM'] = $this->share(function() use ($configuration) $this['EM'] = $this->share(function() use ($doctrineConf)
{ {
$doctrine = new Core\Service\Doctrine($configuration->getDoctrine()); $doctrine = new Core\Service\Doctrine($doctrineConf);
return $doctrine->getEntityManager(); return $doctrine->getEntityManager();
}); });
@@ -410,19 +413,5 @@ class Core extends \Pimple
return $this->conf->getEnvironnement(); return $this->conf->getEnvironnement();
} }
/**
* Load application configuration
*
* @param type $env
*/
private function loadConf($env)
{
$confHandler = new Configuration\Handler(
new Configuration\Application(),
new Configuration\Parser\Yaml()
);
$this->configuration = new Configuration($env, $confHandler);
}
} }