src/Metadata/EntitySchemaTransformer.js
/**
     * Transforms entity schema into new metadata args storage object.
     */
Transforms entity schema into new metadata args storage object.
Transforms entity schema into new metadata args storage object .
transform(schemas) {
        const metadataArgsStorage = new MetadataArgsStorage();
        const embeddableClasses = schemas
            .filter(es => es.options.embeddable)
            .map(es => es.options.target)
        ;
        for (const entitySchema of schemas) {
            const options = entitySchema.options;
            if (! options.embeddable) {
                const tableMetadata = {
                    target: options.target || options.name,
                    name: options.tableName,
                    database: options.database,
                    schema: options.schema,
                    type: options.type || 'regular',
                    orderBy: options.orderBy,
                    synchronize: options.synchronize,
                };
                metadataArgsStorage.tables.push(tableMetadata);
                this._processRepository(metadataArgsStorage, entitySchema);
            }
            this._processColumns(metadataArgsStorage, entitySchema, embeddableClasses);
            this._processRelations(metadataArgsStorage, entitySchema);
            this._processIndices(metadataArgsStorage, entitySchema);
            (options.checks || []).forEach(check => {
                const checkArgs = {
                    target: options.target || options.name,
                    name: check.name,
                    expression: check.expression,
                };
                metadataArgsStorage.checks.push(checkArgs);
            });
            (options.exclusions || []).forEach(exclusion => {
                const exclusionArgs = {
                    target: options.target || options.name,
                    name: exclusion.name,
                    expression: exclusion.expression,
                };
                metadataArgsStorage.exclusions.push(exclusionArgs);
            });
            if ('SINGLE_TABLE' === options.inheritanceType) {
                const column = options.discriminatorColumn;
                for (const [ key, target ] of __jymfony.getEntries(options.discriminatorMap || {})) {
                    const reflClass = ReflectionClass.exists(target) ? new ReflectionClass(target) : null;
                    metadataArgsStorage.inheritances.push({
                        column,
                        pattern: 'STI',
                        target: reflClass ? reflClass.getConstructor() : target,
                    });
                    metadataArgsStorage.discriminatorValues.push({
                        target: reflClass ? reflClass.getConstructor() : target,
                        value: key,
                    });
                }
            }
        }
        return metadataArgsStorage;
    }
transform ( schemas ) { const metadataArgsStorage = new MetadataArgsStorage ( ) ; const embeddableClasses = schemas . filter ( es => es . options . embeddable ) . map ( es => es . options . target ) ; for ( const entitySchema of schemas ) { const options = entitySchema . options ; if ( ! options . embeddable ) { const tableMetadata = { target : options . target || options . name , name : options . tableName , database : options . database , schema : options . schema , type : options . type || 'regular' , orderBy : options . orderBy , synchronize : options . synchronize , } ; metadataArgsStorage . tables . push ( tableMetadata ) ; this . _processRepository ( metadataArgsStorage , entitySchema ) ; } this . _processColumns ( metadataArgsStorage , entitySchema , embeddableClasses ) ; this . _processRelations ( metadataArgsStorage , entitySchema ) ; this . _processIndices ( metadataArgsStorage , entitySchema ) ; ( options . checks || [ ] ) . forEach ( check => { const checkArgs = { target : options . target || options . name , name : check . name , expression : check . expression , } ; metadataArgsStorage . checks . push ( checkArgs ) ; } ) ; ( options . exclusions || [ ] ) . forEach ( exclusion => { const exclusionArgs = { target : options . target || options . name , name : exclusion . name , expression : exclusion . expression , } ; metadataArgsStorage . exclusions . push ( exclusionArgs ) ; } ) ; if ( 'SINGLE_TABLE' === options . inheritanceType ) { const column = options . discriminatorColumn ; for ( const [ key , target ] of __jymfony . getEntries ( options . discriminatorMap || { } ) ) { const reflClass = ReflectionClass . exists ( target ) ? new ReflectionClass ( target ) : null ; metadataArgsStorage . inheritances . push ( { column , pattern : 'STI' , target : reflClass ? reflClass . getConstructor ( ) : target , } ) ; metadataArgsStorage . discriminatorValues . push ( { target : reflClass ? reflClass . getConstructor ( ) : target , value : key , } ) ; } } } return metadataArgsStorage ; }
Transforms entity schema into new metadata args storage object.
Transforms entity schema into new metadata args storage object .
// Add table metadata args from the schema // Embeddable can't have a repository. // Add check metadata args from the schema // Add exclusion metadata args from the schema