function getReferenceType(AssociationMultiplicity $multiplicity) { $type = clone $this->type; if ($type->canBeGenerated()) { $type->setGenerated(false); } $type->setIsNullable($multiplicity->is(AssociationMultiplicity::ZERO_OR_ONE)); return new self($type); }
/** * @return string */ function toPhpCall() { $fields = array(); foreach ($this->fields as $field) { $fields[] = '\'' . $field . '\''; } $ctorArguments = array("'{$this->name}'", 'array(' . join(', ', $fields) . ')', $this->type->toPhpCodeCall(), "new OrmPropertyVisibility(OrmPropertyVisibility::{$this->visibility->getId()})", "new AssociationMultiplicity(AssociationMultiplicity::{$this->multiplicity->getId()})", $this->isUnique ? 'true' : 'false', $this->isIdentifier ? 'true' : 'false'); return join('', array('new OrmProperty(', join(', ', $ctorArguments), ')')); }
static function getOrmPropertyType(AssociationMultiplicity $multiplicity) { $type = new DBType(DBType::VARCHAR, $multiplicity->isNullable(), null, null, null, false); return $type->getOrmPropertyType(); }
protected function getCtorArgumentsPhpCode() { return array($this->container->getLogicalSchema()->getEntityName() . '::orm()', 'new AssociationMultiplicity(AssociationMultiplicity::' . $this->multiplicity->getId() . ')', 'new AssociationBreakAction(AssociationBreakAction::' . $this->action->getId() . ')'); }
/** * Resolution order: * - IDaoRelated (check a class existance within the global scope and withing the domain scope) --> AssociationPropertyType * - IOrmRelated --> CompositionPropertyType * - IOrmPropertyAssignable --> IOrmPropertyAssignable::getOrmProperty() * - IBoxable --> BoxablePropertyType * - DBType * - any type with public ctor * @return OrmPropertyType */ private function getPropertyType(SimpleXMLElement $element, AssociationMultiplicity $multiplicity) { $name = (string) $element['type']; $parameters = $this->getTypeParameters($element); if ($class = $this->importEntity($name)) { // force recursion 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::isInherits($name, 'IDaoRelated')) { return new AssociationPropertyType(call_user_func(array($name, 'orm')), $multiplicity, AssociationBreakAction::cascade()); } else { if (TypeUtils::isInherits($name, 'IOrmRelated')) { $orm = call_user_func(array($name, 'orm')); return new CompositePropertyType($orm); } else { if (TypeUtils::isInherits($name, 'IOrmPropertyAssignable')) { return call_user_func(array($name, 'getOrmPropertyType'), $multiplicity); } else { if (TypeUtils::isInherits($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::isInherits($name, 'ISqlType')) { // for RawSqlType return new PrimitivePropertyType($this->makeObject($name, $parameters)); } else { if (TypeUtils::isInherits($name, 'OrmPropertyType')) { // OrmPropertyType with public ctor return $this->makeObject($name, $parameters); } } } } } } } } } throw new OrmModelIntegrityException('Unknown type of ' . (string) $element['name'] . ' property: ' . $name); }
/** * 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); }