$project = IPF_Project::getInstance();
+ $paths = array();
+ foreach ($project->customApps() as $app)
+ $paths[] = $app->getPath();
+
$extraAllowedReferences = $this->frameworkModels($project);
- foreach ($project->customApps() as $app) {
- print $app->getName()."\n";
- $models = IPF_ORM::generateModelsFromYaml($app->getPath(), $extraAllowedReferences);
- $extraAllowedReferences = array_merge($extraAllowedReferences, $models);
- }
+ IPF_ORM::generateModelsFromYaml($paths, $extraAllowedReferences);
}
private function frameworkModels($project)
public static function generateModelsFromYaml($directory, $extraAllwedReferences=array())
{
+ $files = array();
+ foreach ((array)$directory as $dir)
+ $files[] = $dir . '/models.yml';
+
// load schema
$import = new IPF_ORM_Import_Schema;
- $definitions = $import->importSchema($directory . '/models.yml', $extraAllwedReferences);
+ $definitions = $import->importSchema($files, $extraAllwedReferences);
// build
- $targetPath = $directory . '/models';
$models = array();
foreach ($definitions as $name => $definition) {
print " $name\n";
+ $targetPath = substr($definition['input_file'], 0, -4);
$builder = new IPF_ORM_Import_Builder;
$builder->buildRecord($definition, $targetPath);
public function importSchema($filename, $extraAllwedReferences)
{
- $array = $this->parseSchema($filename);
+ $filename = (array)$filename;
+ $array = array();
+ foreach ($filename as $fn) {
+ $definitions = $this->parseSchema($fn);
+ foreach ($definitions as &$definition)
+ $definition['input_file'] = $fn;
+ $array = array_merge($array, $definitions);
+ }
+
$array = $this->_buildRelationships($array, $extraAllwedReferences);
$array = $this->_processInheritance($array);
return $array;