public function addFieldMapping(SingleFieldDescriptor $fieldDescriptor, $columnAlias = null) { if ($columnAlias === null) { $columnAlias = $fieldDescriptor->getColumnDescriptor()->getName(); } if ($columnAlias === null) { throw new \blaze\lang\Exception('No column name available'); } $columnAlias = \blaze\lang\String::asNative($columnAlias); $propPath = new PropertyPath(); $propPath->addPathStep($fieldDescriptor->getType(), $fieldDescriptor->getName()); $this->columnAliasToPropertyPathMapping[$columnAlias] = $propPath; }
/** * * @param \DOMNode $parentNode * @param \DOMDocument $doc * @param \blaze\persistence\meta\PropertyDescriptor $property */ private function saveField(\DOMNode $parentNode, \DOMDocument $doc, \blaze\persistence\meta\SingleFieldDescriptor $field) { if ($field->getColumnDescriptor()->isForeignKey()) { $node = $doc->createElement('many-to-one'); $parentNode->appendChild($node); AttributeUtil::set($node, 'name', $field->getName()); AttributeUtil::set($node, 'class', $field->getType()); if ($field->getColumnDescriptor() != null) { AttributeUtil::set($node, 'column', $field->getColumnDescriptor()->getName()); } } else { $node = $doc->createElement('property'); $parentNode->appendChild($node); AttributeUtil::set($node, 'name', $field->getName()); AttributeUtil::set($node, 'type', $field->getType()); if ($field->getColumnDescriptor() != null) { $this->saveColumn($node, $doc, $field->getColumnDescriptor()); } } }