Example #1
0
 /**
  * Clears and repopulates the DatabaseMap with new TableMap classes
  * 
  * @param type $name
  * @param type $tableMapClassNames 
  */
 protected function resetDatabaseMap($name, array $tableMapClassNames)
 {
     $dbMap = new DatabaseMap($name);
     foreach ($tableMapClassNames as $tableMapClassName) {
         $dbMap->addTableFromMapClass($tableMapClassName);
     }
     Propel::setDatabaseMap($name, $dbMap);
 }
 /**
  * Loads all map builders for a given connection name
  *
  * Use sfFileCache to cache propel databaseMap
  *
  * @throws sfException If the class cannot be found
  */
 protected function loadMapBuilders($connectionName)
 {
     $cacheKey = 'dbMap-' . $connectionName;
     if (!($dbMap = $this->cache->get($cacheKey))) {
         $dbMap = Propel::getDatabaseMap();
         $files = sfFinder::type('file')->name('*TableMap.php')->in(sfProjectConfiguration::getActive()->getModelDirs());
         foreach ($files as $file) {
             $omClass = basename($file, 'TableMap.php');
             if (class_exists($omClass) && is_subclass_of($omClass, 'BaseObject') && constant($omClass . 'Peer::DATABASE_NAME') == $connectionName) {
                 $tableMapClass = basename($file, '.php');
                 $dbMap->addTableFromMapClass($tableMapClass);
             }
         }
         $dbMap = serialize($dbMap);
         $this->cache->set($cacheKey, $dbMap, $this->cacheKeepDuration);
     }
     Propel::setDatabaseMap($connectionName, unserialize($dbMap));
 }