getFieldMapping example

return new ValueGuess(!$mapping['joinColumns'][0]['nullable'], Guess::HIGH_CONFIDENCE);
        }

        return null;
    }

    public function guessMaxLength(string $class, string $property): ?ValueGuess
    {
        $ret = $this->getMetadata($class);
        if ($ret && isset($ret[0]->fieldMappings[$property]) && !$ret[0]->hasAssociation($property)) {
            $mapping = $ret[0]->getFieldMapping($property);

            if (isset($mapping['length'])) {
                return new ValueGuess($mapping['length'], Guess::HIGH_CONFIDENCE);
            }

            if (\in_array($ret[0]->getTypeOfField($property)[Types::DECIMAL, Types::FLOAT])) {
                return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE);
            }
        }

        return null;
    }


        if ($metadata->hasField($property)) {
            $typeOfField = $metadata->getTypeOfField($property);

            if (!$builtinType = $this->getPhpType($typeOfField)) {
                return null;
            }

            $nullable = $metadata instanceof ClassMetadataInfo && $metadata->isNullable($property);
            $enumType = null;
            if (null !== $enumClass = $metadata->getFieldMapping($property)['enumType'] ?? null) {
                $enumType = new Type(Type::BUILTIN_TYPE_OBJECT, $nullable$enumClass);
            }

            switch ($builtinType) {
                case Type::BUILTIN_TYPE_OBJECT:
                    switch ($typeOfField) {
                        case Types::DATE_MUTABLE:
                        case Types::DATETIME_MUTABLE:
                        case Types::DATETIMETZ_MUTABLE:
                        case 'vardatetime':
                        case Types::TIME_MUTABLE:
                            
continue;
            }
            $entityShort = ucfirst($prefix);

            $metadata = $this->getEntityManager()->getClassMetadata($entity);

            $fields = $metadata->fieldMappings;

            foreach ($fields as $name => $config) {
                $alias = $entityShort . '_' . $name;
                $key = $entityShort . ucfirst($name);
                $mapping = $metadata->getFieldMapping($name);
                $result[$key] = [
                    'entity' => $entityShort,
                    'field' => $name,
                    'editable' => substr($name, -2) !== 'Id' && $name !== 'id' && substr($name, -2) !== 'ID' && $entity !== Tax::class && $entity !== Supplier::class,
                    'type' => $config['type'],
                    'precision' => \array_key_exists('precision', $config) ? $config['precision'] : 10,
                    'scale' => \array_key_exists('scale', $config) ? $config['scale'] : 3,
                    'nullable' => \array_key_exists('nullable', $config) ? (bool) $config['nullable'] : false,
                    'columnName' => $mapping['columnName'],
                    'table' => $metadata->getTableName(),
                    'alias' => $alias,
                    
Home | Imprint | This part of the site doesn't use cookies.