public function generate(\blaze\lang\StringBuffer $buffer) { $buffer->append("\t" . '/**' . PHP_EOL); $buffer->append("\t" . ' * @var blaze\\collections\\Set[' . $this->classDescriptor->getFullName() . ']' . PHP_EOL); $buffer->append("\t" . ' */' . PHP_EOL); $buffer->append("\t" . 'private $'); $buffer->append($this->fieldDescriptor->getName()); $buffer->append(';' . PHP_EOL . PHP_EOL); $buffer->append("\t" . '/**' . PHP_EOL); $buffer->append("\t" . ' * @return blaze\\collections\\Set[' . $this->classDescriptor->getFullName() . ']' . PHP_EOL); $buffer->append("\t" . ' */' . PHP_EOL); $buffer->append("\t" . 'public function get' . $this->fieldDescriptor->getName()->toUpperCase(true)->toNative() . '(){' . PHP_EOL); $buffer->append("\t" . "\t" . ' return $this->' . $this->fieldDescriptor->getName() . ';' . PHP_EOL); $buffer->append("\t" . '}' . PHP_EOL . PHP_EOL); $buffer->append("\t" . '/**' . PHP_EOL); $buffer->append("\t" . ' * @param blaze\\collections\\Set[' . $this->classDescriptor->getFullName() . '] $' . $this->fieldDescriptor->getName() . PHP_EOL); $buffer->append("\t" . ' */' . PHP_EOL); $buffer->append("\t" . 'public function set' . $this->fieldDescriptor->getName()->toUpperCase(true)->toNative() . '($' . $this->fieldDescriptor->getName() . '){' . PHP_EOL); $buffer->append("\t" . "\t" . ' $this->' . $this->fieldDescriptor->getName() . ' = $' . $this->fieldDescriptor->getName() . ';' . PHP_EOL); $buffer->append("\t" . '}' . PHP_EOL . PHP_EOL); }
/** * * @param \DOMDocument $doc * @return \blaze\persistence\meta\ClassDescriptor */ private function parseDom(\DOMDocument $doc, \blaze\lang\String $name) { if ($doc->documentElement->localName != 'persistence-mapping') { throw new \blaze\lang\Exception($name . ': The first element must be of the type persistence-mapping'); } $xmlNode = $doc->documentElement->firstChild; if ($xmlNode->localName != 'class') { throw new \blaze\lang\Exception($name . ': First element must be of the typ class'); } $class = new \blaze\persistence\meta\ClassDescriptor(); $table = new \blaze\persistence\meta\TableDescriptor(); $class->setName($xmlNode->getAttribute('name')); $class->setPackage($xmlNode->getAttribute('package')); $table->setName($xmlNode->getAttribute('table')); $table->setSchema($xmlNode->getAttribute('schema')); $class->setTableDescriptor($table); foreach ($xmlNode->childNodes as $node) { switch ($node->localName) { case 'id': $class->addIdentifier($this->parseId($node)); break; case 'property': $class->addSingleField($this->parseField($node)); break; case 'many-to-one': $class->addSingleField($this->parseManyToOne($node)); break; case 'one-to-one': // $class->addOneToOneRelation($this->parseOneToOne($node)); break; case 'set': $class->addCollectionField($this->parseCollection($node)); break; default: //Exception break; } } return $class; }