environnement = $envName; $this->configurationHandler = $handler; $this->installed = false; try { $handler->getSpecification()->getMainConfigurationFile(); $this->installed = true; } catch (\Exception $e) { } } /** * Getter * @return Configuration\Handler */ public function getConfigurationHandler() { return $this->configurationHandler; } /** * Setter * @param Configuration\Handler $configurationHandler */ public function setConfigurationHandler(Configuration\Handler $configurationHandler) { $this->configurationHandler = $configurationHandler; } /** * Return the current used environnement * * @return string */ public function getEnvironnement() { return $this->environnement; } /** * Return the DBAL Doctrine configuration * * @return Array */ public function getDoctrine() { $doctrine = $this->getConfiguration()->get('doctrine', array()); //get doctrine scope if (count($doctrine) > 0) { $doctrine["debug"] = $this->isDebug(); //set debug if (!!$doctrine["log"]['enable']) { $logger = $doctrine["log"]["type"]; if (!in_array($doctrine["log"]["type"], $this->getAvailableDoctrineLogger())) { throw new \Exception(sprintf('Unknow logger %s', $logger)); } $doctrineLogger = $this->getConfiguration()->get($logger); //set logger $doctrine["logger"] = $doctrineLogger; } } return $doctrine; } /** * Check if current environnement is on debug mode * Default to false * @return boolean */ public function isDebug() { $phraseanet = $this->getPhraseanet(); return isset($phraseanet["debug"]) ? !!$phraseanet["debug"] : false; } /** * Check if current environnement should display errors * Default to false * @return boolean */ public function displayErrors() { $phraseanet = $this->getPhraseanet(); return isset($phraseanet["display_errors"]) ? !!$phraseanet["display_errors"] : false; } /** * Return the phraseanet scope configurations values * * @return Array|null */ public function getPhraseanet() { return $this->getConfiguration()->get('phraseanet', array()); } /** * Tell if the application is installed * * @return boolean */ public function isInstalled() { return $this->installed; } /** * Return the configuration * * @return ParameterBag\ParameterBag */ public function getConfiguration() { if (null === $this->configuration) { $this->configuration = new Configuration\Parameter(); if($this->installed) { $configuration = $this->configurationHandler->handle($this->getEnvironnement()); $this->configuration = new Configuration\Parameter($configuration); } } return $this->configuration; } /** * Return Available logger * * @return Array */ public function getAvailableDoctrineLogger() { return array('echo', 'monolog'); } }