CompilerPass/MappingCompilerPass.php
private function addObjectManager(
        ContainerBuilder $container,
        MappingBag $mappingBag
    ): string {
        $reducedMappingBag = $mappingBag->getReducedMappingBag();
        $definition = new Definition('Doctrine\Common\Persistence\ObjectManager');
        $definition->setFactory([
            new Reference('base.object_manager_provider'),
            'getObjectManagerByEntityNamespace',
        ]);
        $class = $this->resolveParameterName($container, $reducedMappingBag->getEntityClass());
        $definition->setArguments([$class]);
        $aliasName = ltrim(($mappingBag->getContainerPrefix().'.'.$mappingBag->getContainerObjectManagerName().'.'.$mappingBag->getEntityName()), '.');
        $container->setDefinition(
            $aliasName,
            $definition
        );

        return $aliasName;
    }
private function addObjectManager(
        ContainerBuilder $container,
        MappingBag $mappingBag
    ): string {
        $reducedMappingBag = $mappingBag->getReducedMappingBag();
        $definition = new Definition('Doctrine\Common\Persistence\ObjectManager');
        $definition->setFactory([
            new Reference('base.object_manager_provider'),
            'getObjectManagerByEntityNamespace',
        ]);
        $class = $this->resolveParameterName($container, $reducedMappingBag->getEntityClass());
        $definition->setArguments([$class]);
        $aliasName = ltrim(($mappingBag->getContainerPrefix().'.'.$mappingBag->getContainerObjectManagerName().'.'.$mappingBag->getEntityName()), '.');
        $container->setDefinition(
            $aliasName,
            $definition
        );

        return $aliasName;
    }
private function addObjectManager ( ContainerBuilder $ container , MappingBag $ mappingBag ) : string { $ reducedMappingBag = $ mappingBag -> getReducedMappingBag ( ) ; $ definition = new Definition ( 'Doctrine\Common\Persistence\ObjectManager' ) ; $ definition -> setFactory ( [ new Reference ( 'base.object_manager_provider' ) , 'getObjectManagerByEntityNamespace' , ] ) ; $ class = $ this -> resolveParameterName ( $ container , $ reducedMappingBag -> getEntityClass ( ) ) ; $ definition -> setArguments ( [ $ class ] ) ; $ aliasName = ltrim ( ( $ mappingBag -> getContainerPrefix ( ) . '.' . $ mappingBag -> getContainerObjectManagerName ( ) . '.' . $ mappingBag -> getEntityName ( ) ) , '.' ) ; $ container -> setDefinition ( $ aliasName , $ definition ) ; return $ aliasName ; }
Add object manager alias and return the assigned name.

@param ContainerBuilder $container
@param MappingBag       $mappingBag

@return string
Add object manager alias and return the assigned name .