/** * @return void */ private function generateDomain() { if (isset($this->xmlElement['db-schema'])) { $this->ormDomain->setDbSchema((string) $this->xmlElement['db-schema']); } // scan entity nodes (expanding inclusions) // and put them into internal hashmap foreach ($this->getChildNodeSet($this->xmlElement->entities, 'entity') as $entity) { $this->entitiesNodes[(string) $entity['name']] = $entity; } // then traverse over them, and build each recursively foreach (array_keys($this->entitiesNodes) as $name) { $this->importEntity($name); } }
/** * @return void */ private function generateDomain() { $classEntities = array(); $classProperties = array(); $classContainers = array(); if (isset($this->xmlElement['db-schema'])) { $this->ormDomain->setDbSchema((string) $this->xmlElement['db-schema']); } foreach ($this->xmlElement->entities->entity as $entity) { $class = $this->generateEntity($entity); $this->ormDomain->addClass($class); // process an identifier (if specified). However, entity CAN BE identifierless if (isset($entity->properties->identifier)) { $id = $this->generateIdentifier($entity->properties->identifier); // we should generate an identifier (if any) before properties // because type juggling depends on the identifier availabilty $class->setIdentifier($id); } else { if ($class->hasDao()) { // throw new OrmModelIntegrityException( // $class->getName() . 'marked as dao-related and thus should be identifiable' // ); } } // collect props and containers for further processing $name = $class->getName(); $classEntities[$name] = $class; $classProperties[$name] = $this->getChildNodeSet($entity->properties, 'property'); $classContainers[$name] = $this->getChildNodeSet($entity->properties, 'container'); } // firsly, we process props as they can have one-to-one associations only foreach ($classProperties as $name => $properties) { $this->obtainClassProperties($classEntities[$name], $properties); } // for now we can process containers foreach ($classContainers as $name => $containers) { $this->obtainClassContainers($classEntities[$name], $containers); } }