public function load($file, $package = null) { // we figure out what kind of file we are given $type = array_pop(explode('.', $file)); $type2method = array('yml' => 'loadYAML', 'xml' => 'loadXML'); if (isset($type2method[$type])) { $method = $type2method[$type]; } else { throw new sfDoctrineSchemaException(sprintf('Unkwnown method for extension "%s"', $type)); } $propelDatabaseSchema = new sfPropelDatabaseSchema(); $propelDatabaseSchema->{$method}($file); $data = $propelDatabaseSchema->asArray(); foreach ($propelDatabaseSchema->getTables() as $tb_name => $tableDesc) { // special table class // propel has only such classes (no inheritance support) $table = new sfDoctrineTableSchema($tb_name, $package); $this->tables[$tb_name] = $table; if (!($className = $this->getAttribute($tableDesc, 'phpName'))) { $className = sfInflector::camelize($tb_name); } // wild guess $class = new sfDoctrineClassSchema($className); $table->addClass($class); // columns foreach ($propelDatabaseSchema->getChildren($tableDesc) as $col_name => $columnDescription) { if ($col_name == 'id') { // id is automatically generated in doctrine continue; } $docCol = new sfDoctrineColumnSchema($col_name, $columnDescription, true); $class->addColumn($docCol); } $this->classes[$class->getPhpName()] = $class; } }
/** * Get tables from schema * * @param string $schema_path * @return array * @author Sergey Startsev */ private function getSchemaTables($schema_path) { $dbSchema = new sfPropelDatabaseSchema(); $dbSchema->loadYAML($schema_path); return array_keys($dbSchema->getTables()); }