Ejemplo n.º 1
0
 /**
  * retrieve the database configuration
  *
  * @return array containing the database
  */
 protected function getDatabaseConfig()
 {
     $configPath = THELIA_CONF_DIR . "/database.yml";
     if (!file_exists($configPath)) {
         throw new UpdateException("Thelia is not installed yet");
     }
     $definePropel = new DefinePropel(new DatabaseConfiguration(), Yaml::parse($configPath), $this->getEnvParameters());
     return $definePropel->getConfig();
 }
Ejemplo n.º 2
0
 protected function initPropel()
 {
     if (self::isInstalled() === false) {
         return;
     }
     $definePropel = new DefinePropel(new DatabaseConfiguration(), Yaml::parse(THELIA_CONF_DIR . 'database.yml'));
     $serviceContainer = Propel::getServiceContainer();
     $serviceContainer->setAdapterClass('thelia', 'mysql');
     $manager = new ConnectionManagerSingle();
     $manager->setConfiguration($definePropel->getConfig());
     $serviceContainer->setConnectionManager('thelia', $manager);
     $con = Propel::getConnection(\Thelia\Model\Map\ProductTableMap::DATABASE_NAME);
     $con->setAttribute(ConnectionWrapper::PROPEL_ATTR_CACHE_PREPARES, true);
     if ($this->isDebug()) {
         $serviceContainer->setLogger('defaultLogger', Tlog::getInstance());
         $con->useDebug(true);
     }
 }
Ejemplo n.º 3
0
 /**
  *
  * process the configuration and create a cache.
  *
  * @return array configuration for propel
  */
 protected function getPropelConfig()
 {
     $cachePath = $this->getCacheDir() . DS . 'PropelConfig.php';
     $cache = new ConfigCache($cachePath, $this->debug);
     if (!$cache->isFresh()) {
         if (file_exists(THELIA_CONF_DIR . "database_" . $this->environment . ".yml")) {
             $file = THELIA_CONF_DIR . "database_" . $this->environment . ".yml";
         } else {
             $file = THELIA_CONF_DIR . 'database.yml';
         }
         $definePropel = new DefinePropel(new DatabaseConfiguration(), Yaml::parse($file), $this->getEnvParameters());
         $resource = [new FileResource($file)];
         $config = $definePropel->getConfig();
         $code = sprintf("<?php return %s;", var_export($config, true));
         $cache->write($code, $resource);
     }
     $config = (require $cachePath);
     return $config;
 }