Пример #1
0
 /**
  * Construct database definition.
  *
  * @param Definition[]|DatabaseDefinition $definitions Associative array of
  * table names and definitions or another instance of {@see DatabaseDefinition}.
  * @param boolean $dynamic
  */
 public function __construct($definitions = array())
 {
     if ($definitions instanceof DatabaseDefinitionBuilder) {
         $this->tables = $definitions->tables;
         $this->definitions = $definitions->definitions;
     } elseif ($definitions instanceof DatabaseDefinition) {
         foreach ($definitions->getTables() as $table) {
             $this->addDefinition($table, $definitions->getDefinition($table));
         }
     } else {
         foreach ($definitions as $table => $definition) {
             $this->addDefinition($table, $definition);
         }
     }
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function setDefinition(DatabaseDefinition $definition)
 {
     $this->definition = $definition;
     foreach ($definition->getTables() as $table) {
         $tableDefinition = $definition->getDefinition($table);
         if (!in_array($table, $this->tableNames)) {
             $this->tableNames[] = $table;
             $this->tables[$table] = $this->getTable($table);
         }
         $this->{$table}->setDefinition($tableDefinition);
     }
 }