public function onVisitedOProperty(OProperty $node) { if (OSchema::isSystemProperty($node->getName())) { return; } $this->_propertySql[] = $this->getCreatePropertySql($node); if ($node->isMandatory()) { $this->_propertySql[] = $this->getAlterPropertySqlForAttribute($node, 'mandatory', true); } if ($node->isReadOnly()) { $this->_propertySql[] = $this->getAlterPropertySqlForAttribute($node, 'readonly', true); } if ($node->isNotNull()) { $this->_propertySql[] = $this->getAlterPropertySqlForAttribute($node, 'notnull', true); } if ($node->getRegExp()) { $this->_propertySql[] = $this->getAlterPropertySqlForAttribute($node, 'regexp', $node->getRegExp()); } $collate = $node->getCollate(); if ($collate && strcasecmp($collate, 'default') !== 0) { $this->_propertySql[] = $this->getAlterPropertySqlForAttribute($node, 'collate', $collate); } }
private function gatherProperties(ClassMetadata $class, OClass $oclass) { foreach ($class->fieldMappings as $mapping) { if (isset($mapping['inherited'])) { continue; } $name = $mapping['name']; if (OSchema::isSystemProperty($name)) { continue; } if (isset($mapping['association'])) { continue; } $options = ['readonly' => $mapping['readonly'], 'mandatory' => $mapping['mandatory'], 'min' => $mapping['min'], 'max' => $mapping['max'], 'regexp' => $mapping['regexp'], 'notNull' => !$mapping['nullable']]; $oclass->addProperty($name, $mapping['type'], $options); } foreach ($class->associationMappings as $mapping) { if (isset($mapping['inherited'])) { continue; } if (isset($mapping['direction'])) { // no in / outgoing references continue; } $name = $mapping['name']; if (isset($mapping['targetDoc'])) { $linkedClass = $this->_dm->getClassMetadata($mapping['targetDoc'])->orientClass; } else { $linkedClass = null; } $options = ['notNull' => !$mapping['nullable'], 'linkedClass' => $linkedClass]; $oclass->addProperty($name, $mapping['type'], $options); } }