public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
    {
        if (empty($this->replacements)) {
            return;
        }

        /** @var ClassMetadataInfo $metadata */
        $metadata = $eventArgs->getClassMetadata();

        // Handle table name.
        $tableName = $metadata->getTableName();
        if ($tableName) {
            $metadata->setPrimaryTable(
                [
                    'name' => $this->doReplacement($tableName),
                ]
            );
        }

        // Handle fields AKA columns.
        foreach ($metadata->getFieldNames() as $fieldName) {
            $mapping = $metadata->getFieldMapping($fieldName);
            foreach ($mapping as $key => $value) {
                if (is_string($value)) {
                    $mapping[$key] = $this->doReplacement($value);
                }
            }
            $metadata->setAttributeOverride($fieldName, $mapping);
        }

        // Handle associations AKA foreign keys.
        $associationMappings = $metadata->getAssociationMappings();
        foreach ($metadata->getAssociationNames() as $fieldName) {
            if (isset($associationMappings[$fieldName])) {
                $associationMapping = $associationMappings[$fieldName];
                if (isset($associationMapping['joinColumns'])) {
                    foreach ($associationMapping['joinColumns'] as $key => $joinColumn) {
                        $associationMapping['joinColumns'][$key]['name'] = $this->doReplacement($joinColumn['name']);
                        $associationMapping['joinColumns'][$key]['referencedColumnName'] = $this->doReplacement(
                            $joinColumn['referencedColumnName']
                        );
                    }
                    $metadata->setAssociationOverride($fieldName, $associationMapping);
                }
            }
        }

        // Handle discriminator.
        if (count($metadata->discriminatorMap)) {
            $this->processDiscriminatorMap($metadata);
        }
    }
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
    {
        if (empty($this->replacements)) {
            return;
        }

        /** @var ClassMetadataInfo $metadata */
        $metadata = $eventArgs->getClassMetadata();

        // Handle table name.
        $tableName = $metadata->getTableName();
        if ($tableName) {
            $metadata->setPrimaryTable(
                [
                    'name' => $this->doReplacement($tableName),
                ]
            );
        }

        // Handle fields AKA columns.
        foreach ($metadata->getFieldNames() as $fieldName) {
            $mapping = $metadata->getFieldMapping($fieldName);
            foreach ($mapping as $key => $value) {
                if (is_string($value)) {
                    $mapping[$key] = $this->doReplacement($value);
                }
            }
            $metadata->setAttributeOverride($fieldName, $mapping);
        }

        // Handle associations AKA foreign keys.
        $associationMappings = $metadata->getAssociationMappings();
        foreach ($metadata->getAssociationNames() as $fieldName) {
            if (isset($associationMappings[$fieldName])) {
                $associationMapping = $associationMappings[$fieldName];
                if (isset($associationMapping['joinColumns'])) {
                    foreach ($associationMapping['joinColumns'] as $key => $joinColumn) {
                        $associationMapping['joinColumns'][$key]['name'] = $this->doReplacement($joinColumn['name']);
                        $associationMapping['joinColumns'][$key]['referencedColumnName'] = $this->doReplacement(
                            $joinColumn['referencedColumnName']
                        );
                    }
                    $metadata->setAssociationOverride($fieldName, $associationMapping);
                }
            }
        }

        // Handle discriminator.
        if (count($metadata->discriminatorMap)) {
            $this->processDiscriminatorMap($metadata);
        }
    }
public function loadClassMetadata ( LoadClassMetadataEventArgs $ eventArgs ) { if ( empty ( $ this -> replacements ) ) { return ; } /** @var ClassMetadataInfo $metadata */ $ metadata = $ eventArgs -> getClassMetadata ( ) ; // Handle table name. $ tableName = $ metadata -> getTableName ( ) ; if ( $ tableName ) { $ metadata -> setPrimaryTable ( [ 'name' => $ this -> doReplacement ( $ tableName ) , ] ) ; } // Handle fields AKA columns. foreach ( $ metadata -> getFieldNames ( ) as $ fieldName ) { $ mapping = $ metadata -> getFieldMapping ( $ fieldName ) ; foreach ( $ mapping as $ key => $ value ) { if ( is_string ( $ value ) ) { $ mapping [ $ key ] = $ this -> doReplacement ( $ value ) ; } } $ metadata -> setAttributeOverride ( $ fieldName , $ mapping ) ; } // Handle associations AKA foreign keys. $ associationMappings = $ metadata -> getAssociationMappings ( ) ; foreach ( $ metadata -> getAssociationNames ( ) as $ fieldName ) { if ( isset ( $ associationMappings [ $ fieldName ] ) ) { $ associationMapping = $ associationMappings [ $ fieldName ] ; if ( isset ( $ associationMapping [ 'joinColumns' ] ) ) { foreach ( $ associationMapping [ 'joinColumns' ] as $ key => $ joinColumn ) { $ associationMapping [ 'joinColumns' ] [ $ key ] [ 'name' ] = $ this -> doReplacement ( $ joinColumn [ 'name' ] ) ; $ associationMapping [ 'joinColumns' ] [ $ key ] [ 'referencedColumnName' ] = $ this -> doReplacement ( $ joinColumn [ 'referencedColumnName' ] ) ; } $ metadata -> setAssociationOverride ( $ fieldName , $ associationMapping ) ; } } } // Handle discriminator. if ( count ( $ metadata -> discriminatorMap ) ) { $ this -> processDiscriminatorMap ( $ metadata ) ; } }
Processes doctrine mapping metadata and does replacements, as provided in replacements map.

@param LoadClassMetadataEventArgs $eventArgs
Processes doctrine mapping metadata and does replacements as provided in replacements map .