private function importEntity($name) { if (!isset($this->entitiesNodes[$name])) { return null; } if ($this->ormDomain->classExists($name)) { return $this->ormDomain->getClass($name); } $entity = $this->entitiesNodes[$name]; $prevClass = $this->currentClass; $this->processingStack[$name] = $class = $this->currentClass = $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); $class->setIdentifier($id); } foreach ($this->getChildNodeSet($entity->properties, 'property') as $property) { $property = $this->generateProperty($property); $class->addProperty($property); } foreach ($this->getChildNodeSet($entity->properties, 'container') as $container) { $container = $this->generateContainer($class, $container); $class->addProperty($container); } $this->currentClass = $prevClass; return $class; }
/** * Resolution order: * - IDaoRelated (check a class existance within the global scope and withing the domain scope) --> AssociationPropertyType * - IOrmRelated --> CompositionPropertyType (not implemented) * - IOrmPropertyAssignable --> IOrmPropertyAssignable::getOrmProperty() * - IBoxable --> BoxablePropertyType * - DBType * - any type with public ctor * @return OrmPropertyType */ private function getPropertyType($name, AssociationMultiplicity $multiplicity, array $parameters = array()) { if ($this->ormDomain->classExists($name)) { $class = $this->ormDomain->getClass($name); if ($class->hasDao() && $class->getIdentifier()) { return new AssociationPropertyType($class, $multiplicity, AssociationBreakAction::cascade()); } else { return new CompositePropertyType($class); } } else { if (DBType::hasMember($name)) { $parameters['id'] = $name; if (!isset($parameters['nullable'])) { $parameters['nullable'] = $multiplicity->isNullable() ? 'true' : 'false'; } $dbType = $this->makeObject('DBType', $parameters); return $dbType->getOrmPropertyType(); } else { if (class_exists($name, true)) { if (TypeUtils::isChild($name, 'IDaoRelated')) { return new AssociationPropertyType(call_user_func(array($name, 'orm')), $multiplicity, AssociationBreakAction::cascade()); } else { if (TypeUtils::isChild($name, 'IOrmRelated')) { $orm = call_user_func(array($name, 'orm')); return new CompositePropertyType($orm); } else { if (TypeUtils::isChild($name, 'IOrmPropertyAssignable')) { return call_user_func(array($name, 'getOrmPropertyType'), $multiplicity); } else { if (TypeUtils::isChild($name, 'IBoxable')) { $parameters['id'] = DBType::VARCHAR; if (!isset($parameters['nullable'])) { $parameters['nullable'] = $multiplicity->isNullable() ? 'true' : 'false'; } return new BoxablePropertyType($name, $this->makeObject('DBType', $parameters)); } else { if (TypeUtils::isChild($name, 'ISqlType')) { // for RawSqlType return new PrimitivePropertyType($this->makeObject($name, $parameters)); } else { //$this->makeObject($name, $parameters); } } } } } } } } throw new OrmModelIntegrityException('do not know how to map ' . $name); }