Gathers the column definitions as required by the DBAL of all field mappings
found in the given class.

@param ClassMetadata $class
433679
private function gatherColumns($class, Table $table)
    {
        $pkColumns = [];

        foreach ($class->getDeclaredPropertiesIterator() as $fieldName => $property) {
            if (! ($property instanceof FieldMetadata)) {
                continue;
            }

            if ($class->inheritanceType === InheritanceType::SINGLE_TABLE && $class->isInheritedProperty($fieldName)) {
                continue;
            }

            $this->gatherColumn($class, $property, $table);

            if ($property->isPrimaryKey()) {
                $pkColumns[] = $this->platform->quoteIdentifier($property->getColumnName());
            }
        }
    }
1253203
private function buildFieldMappings(Mapping\ClassMetadata $metadata)
    {
        $tableName      = $metadata->getTableName();
        $columns        = $this->tables[$tableName]->getColumns();
        $primaryKeys    = $this->getTablePrimaryKeys($this->tables[$tableName]);
        $foreignKeys    = $this->getTableForeignKeys($this->tables[$tableName]);
        $allForeignKeys = [];

        foreach ($foreignKeys as $foreignKey) {
            $allForeignKeys = array_merge($allForeignKeys, $foreignKey->getLocalColumns());
        }

        $ids = [];

        foreach ($columns as $column) {
            if (in_array($column->getName(), $allForeignKeys, true)) {
                continue;
            }

            $fieldName     = $this->getFieldNameForColumn($tableName, $column->getName(), false);
            $fieldMetadata = $this->convertColumnAnnotationToFieldMetadata($tableName, $column, $fieldName);

            if ($primaryKeys && in_array($column->getName(), $primaryKeys, true)) {
                $fieldMetadata->setPrimaryKey(true);

                $ids[] = $fieldMetadata;
            }

            $metadata->addProperty($fieldMetadata);
        }

        // We need to check for the columns here, because we might have associations as id as well.
        if ($ids && count($primaryKeys) === 1) {
            $ids[0]->setValueGenerator(new Mapping\ValueGeneratorMetadata(Mapping\GeneratorType::AUTO));
        }
    }
1168903
public function classHasTable($class)
    {
        if (!is_subclass_of($class, DataObject::class)) {
            return false;
        }

        $fields = $this->databaseFields($class, false);
        return !empty($fields);
    }
98969
protected function define(ClassDefinition $class)
    {
        $class->property($this->address)->asString();
        $class->property($this->latLng)->asObject(LatLng::class);
    }
556939
public function getRelationshipEntityMetadata($class)
    {
        if (!array_key_exists($class, $this->loadedMetadata)) {
            $metadata = $this->metadataFactory->create($class);
            if (!$metadata instanceof RelationshipEntityMetadata) {
                // $class is not an relationship entity
                throw new MappingException(sprintf('The class "%s" was configured to be an RelationshipEntity but no @OGM\RelationshipEntity class annotation was found', $class));
            }
            $this->loadedMetadata[$class] = $metadata;
        }

        return $this->loadedMetadata[$class];
    }
1027162
protected function define(ClassDefinition $class)
    {
        $class->property($this->name)->asString();

        $class->property($this->image)->asObject(Image::class);

        $class->property($this->altText)->nullable()->asString();
    }
218546
protected static function collectDBFields($class)
    {
        if (isset(self::$collectorCache[$class])) {
            return self::$collectorCache[$class];
        }

        if (isset(self::$collectorLock[$class]) && self::$collectorLock[$class]) {
            return null;
        }
        self::$collectorLock[$class] = true;

        // Get all DB Fields
        $fields = array();
        Config::inst()->get($class, 'db', Config::EXCLUDE_EXTRA_SOURCES, $fields);

        // Get all arguments
        $arguments = self::get_arguments($class);

        $locales = self::get_target_locales();

        // remove the default locale
        if (($index = array_search(Translatable::default_locale(), $locales)) !== false) {
            array_splice($locales, $index, 1);
        }

        // fields that should be translated
        $fieldsToTranslate = array();

        // validate the arguments
        if ($arguments) {
            foreach ($arguments as $field) {
                // only allow fields that are actually in our field list
                if (array_key_exists($field, $fields)) {
                    $fieldsToTranslate[] = $field;
                }
            }
        } else {
            // check for the given default field types and add all fields of that type
            foreach ($fields as $field => $type) {
                $typeClean = (($p = strpos($type, '(')) !== false) ? substr($type, 0, $p) : $type;
                $defaultFields = self::config()->default_field_types;

                if (is_array($defaultFields) && in_array($typeClean, $defaultFields)) {
                    $fieldsToTranslate[] = $field;
                }
            }
        }


        // gather all the DB fields
        $additionalFields = array();
        self::$localizedFields[$class] = array();
        foreach ($fieldsToTranslate as $field) {
            self::$localizedFields[$class][$field] = array();
            foreach ($locales as $locale) {
                $localizedName = self::localized_field($field, $locale);
                self::$localizedFields[$class][$field][] = $localizedName;
                $additionalFields[$localizedName] = $fields[$field];
            }
        }

        self::$collectorCache[$class] = $additionalFields;
        self::$collectorLock[$class] = false;
        return $additionalFields;
    }
30371
private function initializeMethodNamesMap($class)
    {
        $this->serviceIdToMethodNameMap = array();
        $this->usedMethodNames = array();

        try {
            $reflectionClass = new \ReflectionClass($class);
            foreach ($reflectionClass->getMethods() as $method) {
                $this->usedMethodNames[strtolower($method->getName())] = true;
            }
        } catch (\ReflectionException $e) {
        }
    }
1003073
private function buildFieldMappings(ClassMetadataInfo $metadata)
    {
        $tableName      = $metadata->table['name'];
        $columns        = $this->tables[$tableName]->getColumns();
        $primaryKeys    = $this->getTablePrimaryKeys($this->tables[$tableName]);
        $foreignKeys    = $this->getTableForeignKeys($this->tables[$tableName]);
        $allForeignKeys = array();

        foreach ($foreignKeys as $foreignKey) {
            $allForeignKeys = array_merge($allForeignKeys, $foreignKey->getLocalColumns());
        }

        $ids           = array();
        $fieldMappings = array();

        foreach ($columns as $column) {
            if (in_array($column->getName(), $allForeignKeys)) {
                continue;
            }

            $fieldMapping = $this->buildFieldMapping($tableName, $column);

            if ($primaryKeys && in_array($column->getName(), $primaryKeys)) {
                $fieldMapping['id'] = true;
                $ids[] = $fieldMapping;
            }

            $fieldMappings[] = $fieldMapping;
        }

        // We need to check for the columns here, because we might have associations as id as well.
        if ($ids && count($primaryKeys) == 1) {
            $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO);
        }

        foreach ($fieldMappings as $fieldMapping) {
            $metadata->mapField($fieldMapping);
        }
    }
913659
protected function defineEntity(ClassDefinition $class)
    {
        $class->property($this->name)->asString();

        $class->property($this->slug)->asString();

        $class->property($this->articles)->asType(BlogArticle::collectionType());

        $class->property($this->published)->asBool();

        $class->property($this->createdAt)->asObject(DateTime::class);

        $class->property($this->updatedAt)->asObject(DateTime::class);

        $this->defineMetadata($class);
    }
243538
private function completeIdGeneratorMapping(ClassMetadataInfo $class)
    {
        $idGenType = $class->generatorType;
        if ($idGenType == ClassMetadata::GENERATOR_TYPE_AUTO) {
            if ($this->getTargetPlatform()->prefersSequences()) {
                $class->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_SEQUENCE);
            } else if ($this->getTargetPlatform()->prefersIdentityColumns()) {
                $class->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_IDENTITY);
            } else {
                $class->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_TABLE);
            }
        }

        // Create & assign an appropriate ID generator instance
        switch ($class->generatorType) {
            case ClassMetadata::GENERATOR_TYPE_IDENTITY:
                $sequenceName = null;
                $fieldName    = $class->identifier ? $class->getSingleIdentifierFieldName() : null;

                // Platforms that do not have native IDENTITY support need a sequence to emulate this behaviour.
                if ($this->getTargetPlatform()->usesSequenceEmulatedIdentityColumns()) {
                    $columnName     = $class->getSingleIdentifierColumnName();
                    $quoted         = isset($class->fieldMappings[$fieldName]['quoted']) || isset($class->table['quoted']);
                    $sequencePrefix = $class->getSequencePrefix($this->getTargetPlatform());
                    $sequenceName   = $this->getTargetPlatform()->getIdentitySequenceName($sequencePrefix, $columnName);
                    $definition     = array(
                        'sequenceName' => $this->getTargetPlatform()->fixSchemaElementName($sequenceName)
                    );

                    if ($quoted) {
                        $definition['quoted'] = true;
                    }

                    $sequenceName = $this
                        ->em
                        ->getConfiguration()
                        ->getQuoteStrategy()
                        ->getSequenceName($definition, $class, $this->getTargetPlatform());
                }

                $generator = ($fieldName && $class->fieldMappings[$fieldName]['type'] === 'bigint')
                    ? new BigIntegerIdentityGenerator($sequenceName)
                    : new IdentityGenerator($sequenceName);

                $class->setIdGenerator($generator);

                break;

            case ClassMetadata::GENERATOR_TYPE_SEQUENCE:
                // If there is no sequence definition yet, create a default definition
                $definition = $class->sequenceGeneratorDefinition;

                if ( ! $definition) {
                    $fieldName      = $class->getSingleIdentifierFieldName();
                    $sequenceName   = $class->getSequenceName($this->getTargetPlatform());
                    $quoted         = isset($class->fieldMappings[$fieldName]['quoted']) || isset($class->table['quoted']);

                    $definition = array(
                        'sequenceName'      => $this->getTargetPlatform()->fixSchemaElementName($sequenceName),
                        'allocationSize'    => 1,
                        'initialValue'      => 1,
                    );

                    if ($quoted) {
                        $definition['quoted'] = true;
                    }

                    $class->setSequenceGeneratorDefinition($definition);
                }

                $sequenceGenerator = new \Doctrine\ORM\Id\SequenceGenerator(
                    $this->em->getConfiguration()->getQuoteStrategy()->getSequenceName($definition, $class, $this->getTargetPlatform()),
                    $definition['allocationSize']
                );
                $class->setIdGenerator($sequenceGenerator);
                break;

            case ClassMetadata::GENERATOR_TYPE_NONE:
                $class->setIdGenerator(new \Doctrine\ORM\Id\AssignedGenerator());
                break;

            case ClassMetadata::GENERATOR_TYPE_UUID:
                $class->setIdGenerator(new \Doctrine\ORM\Id\UuidGenerator());
                break;

            case ClassMetadata::GENERATOR_TYPE_TABLE:
                throw new ORMException("TableGenerator not yet implemented.");
                break;

            case ClassMetadata::GENERATOR_TYPE_CUSTOM:
                $definition = $class->customGeneratorDefinition;
                if ( ! class_exists($definition['class'])) {
                    throw new ORMException("Can't instantiate custom generator : " .
                        $definition['class']);
                }
                $class->setIdGenerator(new $definition['class']);
                break;

            default:
                throw new ORMException("Unknown generator type: " . $class->generatorType);
        }
    }
699605
private function getParentFields(ClassMetadata $class, $fields = array())
    {
        if ($parent = $this->classStore->getParent($class)) {
            $parentFields = $parent->getFieldNames();

            foreach ($parentFields as $field) {
                if (!in_array($field, $fields)) {
                    $fields[] = $field;
                }
            }

            $fields = $this->getParentFields($parent, $fields);
        }

        return $fields;
    }
863249
protected function define(ClassDefinition $class)
    {
        $class->property($this->object)->asObject();

        $class->property($this->data)->nullable()->asObject();
    }
1023900
public function BuildClassBody($tableColumnsMetadata) {
        $this->AddConstants($tableColumnsMetadata);
        $this->AddFields($tableColumnsMetadata);
        $this->AddSetters($tableColumnsMetadata);
        $this->AddGetters($tableColumnsMetadata);
    }
740726
protected function makeSchema(string $class): array
    {
        //Using as basement
        $schema = $this->schema;
        unset($schema[Record::MORPHED_ALIASES]);

        //We do not have this information in morphed relation but it's required for ManyToMany
        $schema[Record::WHERE] = [];

        //This must be unified in future, for now we can fetch columns directly from there
        $recordSchema = $this->orm->define($class, ORMInterface::R_SCHEMA);
        $schema[Record::RELATION_COLUMNS] = array_keys($recordSchema[Record::SH_DEFAULTS]);

        return $schema;
    }
224804
public function loadMetadataForClass(\ReflectionClass $class)
    {
        foreach ($this->drivers as $driver) {
            if (null !== $metadata = $driver->loadMetadataForClass($class)) {
                return $metadata;
            }
        }
    }
1368415
private function validateFieldCriteria(ClassMetadata $class, $fieldName): void
    {
        if (!$class->hasField($fieldName) && !$class->hasAssociation($fieldName)) {
            throw new ConstraintDefinitionException(sprintf("The field '%s' is not mapped by Doctrine, so it cannot be validated for uniqueness.", $fieldName));
        }
    }