Esempio n. 1
0
 /**
  *
  * @param \DOMNode $xmlNode 
  */
 private function parseCollection(\DOMNode $xmlNode)
 {
     $collection = new \blaze\persistence\meta\CollectionFieldDescriptor();
     $field = new \blaze\persistence\meta\SingleFieldDescriptor();
     $field->setName($xmlNode->getAttribute('name'));
     $field->setType(new \blaze\lang\String('blaze\\collections\\Set'));
     $collection->setFieldDescriptor($field);
     $tbl = $xmlNode->getAttribute('table');
     if ($tbl !== '') {
         // many-to-many
         $collection->setTableDescriptor(\blaze\persistence\meta\TableDescriptor::getTableDescriptor($tbl));
         $column = new \blaze\persistence\meta\ColumnDescriptor();
         $column->setName($xmlNode->getAttribute('column'));
         $collection->setColumnDescriptor($column);
         foreach ($xmlNode->childNodes as $node) {
             if ($node->localName === 'many-to-many') {
                 $collection->setClassDescriptor(\blaze\persistence\meta\ClassDescriptor::getClassDescriptor($node->getAttribute('class')));
                 $column = new \blaze\persistence\meta\ColumnDescriptor();
                 $column->setName($node->getAttribute('column'));
                 $collection->setJunctionColumnDescriptor($column);
             }
         }
     } else {
         // one-to-many
         $column = new \blaze\persistence\meta\ColumnDescriptor();
         $column->setName($xmlNode->getAttribute('column'));
         $collection->setColumnDescriptor($column);
         foreach ($xmlNode->childNodes as $node) {
             if ($node->localName === 'one-to-many') {
                 $collection->setClassDescriptor(\blaze\persistence\meta\ClassDescriptor::getClassDescriptor($node->getAttribute('class')));
             }
         }
     }
     return $collection;
 }
Esempio n. 2
0
 private function makeManyToMany(\blaze\persistence\meta\ClassDescriptor $elem, $column, $secondColumn, $otherTable, $ident)
 {
     $property = new \blaze\persistence\meta\CollectionFieldDescriptor();
     $field = new \blaze\persistence\meta\SingleFieldDescriptor();
     $property->setFieldDescriptor($field);
     $ident = $ident > 0 ? '' . $ident : '';
     $field->setName($this->getMemberName($otherTable->getTableName() . 's' . $ident));
     //$property->setSchema($column->getTable()->getSchema()->getSchemaName());
     $property->setTableDescriptor(\blaze\persistence\meta\TableDescriptor::getTableDescriptor($column->getTable()->getTableName()));
     //$property->setCascade('all');
     $col = new \blaze\persistence\meta\ColumnDescriptor();
     $col->apply($column);
     $property->setColumnDescriptor($col);
     $junction = new \blaze\persistence\meta\ColumnDescriptor();
     $junction->apply($secondColumn);
     $property->setJunctionColumnDescriptor($junction);
     $property->setClassDescriptor(\blaze\persistence\meta\ClassDescriptor::getClassDescriptor($this->getClassName($otherTable->getTableName())));
     $elem->addCollectionField($property);
 }