public function load($file, $package = null) { $schema = sfYaml::load($file); foreach ($schema as $className => $cd) { if (!isset($cd['tableName']) && !isset($cd['inheritance'])) { throw new sfDoctrineSchemaException(sprintf('Class "%s" must have either a table or a parent', $className)); } $class = new sfDoctrineClassSchema($className, $cd); // add a table if necessary if (isset($cd['tableName'])) { // this top class is actually a table $table = new sfDoctrineTableSchema($cd['tableName'], $package); $table->addClass($class); $this->tables[$cd['tableName']] = $table; } $this->classes[$className] = $class; } }
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; } }