Example #1
0
 public function __construct($sm, $params = array())
 {
     // initialization
     $this->sm = $sm;
     $this->schema = null;
     $yaml = $this->sm->get('pegase.component.yaml.spyc');
     $mm = $this->sm->get('pegase.core.module_manager');
     if ($params != null) {
         if (!is_array($params)) {
             throw new PegaseException("SchemaManager params must be an array or null.");
         } else {
         }
         $this->schema = new Schema();
         foreach ($params as $name => $class) {
             if (key_exists('import', $class)) {
                 $tmp = $yaml->parse($mm->get_path($class['module'], $class['import']));
                 // we add the elements of tmp in the class
                 foreach ($tmp as $n => $t) {
                     $class[$n] = $t;
                 }
             }
             $table = new Table($name, $class['module'], $class['class'], $class['repo_class'], key_exists('constraints', $class) ? $class['constraints'] : array());
             foreach ($class['columns'] as $n => $col) {
                 $table->add_column($n, $col['type'], $col['size'], $col['constraints']);
             }
             $this->schema->add_table($table);
         }
     } else {
     }
 }