Example #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;
 }
 private function makeOneToMany(\blaze\persistence\meta\ClassDescriptor $elem, $column, $ident)
 {
     $property = new \blaze\persistence\meta\CollectionFieldDescriptor();
     $field = new \blaze\persistence\meta\SingleFieldDescriptor();
     $property->setFieldDescriptor($field);
     $ident = $ident > 0 ? '' . $ident : '';
     $field->setName($this->getMemberName($column->getTable()->getTableName() . 's' . $ident));
     //$property->setInverse('true');
     $col = new \blaze\persistence\meta\ColumnDescriptor();
     $col->apply($column);
     $property->setColumnDescriptor($col);
     $property->setClassDescriptor(\blaze\persistence\meta\ClassDescriptor::getClassDescriptor($this->getClassName($column->getTable()->getTableName())));
     $elem->addCollectionField($property);
 }