Repository/Registry/RegistryFactory.php
private function injectDependencies(RegistryInterface $registry, $entityName = null, EntityManager $entityManager = null)
    {
        if (!($entityManager instanceof EntityManager)) {
            /** @var EntityManager $entityManager */
            $entityManager = $this->container->get('doctrine.orm.entity_manager');
        }

        if ($registry instanceof EntityManagerAwareInterface) {
            $registry->setEntityManager($entityManager);
        }

        if ($registry instanceof EntityRegistry) {
            if ($entityName === null) {
                throw new \Exception('Can\'t load an entity registry without entity name');
            }
            $registry->setEntityRepository($entityManager->getRepository($entityName));
        }

        if ($registry instanceof MongoDBAwareInterface) {
            if ($entityName === null) {
                throw new \Exception('Can\'t load a mongodb registry without entity name');
            }

            $collection = ConnectionFactory::getInstance()->getConnection()->getMongoDatabase()->selectCollection($entityName);
            $registry->setMongoDBCollection($collection);
        }

        if ($registry instanceof ClassAwareInterface) {

            $shortcutParser = new ShortcutNotationParser($entityName);
            $bundle = $this->container->get('kernel')->getBundle($shortcutParser->getBundleName());

            $stackConfiguration = new EntityStackConfiguration($bundle, $shortcutParser->getEntityName());

            if ($registry instanceof MongoDBAwareInterface) {
                $registry->setEntityClass($stackConfiguration->getDocumentClass());
            } else {
                $registry->setEntityClass($stackConfiguration->getEntityClass());
            }
        }
    }
private function injectDependencies(RegistryInterface $registry, $entityName = null, EntityManager $entityManager = null)
    {
        if (!($entityManager instanceof EntityManager)) {
            /** @var EntityManager $entityManager */
            $entityManager = $this->container->get('doctrine.orm.entity_manager');
        }

        if ($registry instanceof EntityManagerAwareInterface) {
            $registry->setEntityManager($entityManager);
        }

        if ($registry instanceof EntityRegistry) {
            if ($entityName === null) {
                throw new \Exception('Can\'t load an entity registry without entity name');
            }
            $registry->setEntityRepository($entityManager->getRepository($entityName));
        }

        if ($registry instanceof MongoDBAwareInterface) {
            if ($entityName === null) {
                throw new \Exception('Can\'t load a mongodb registry without entity name');
            }

            $collection = ConnectionFactory::getInstance()->getConnection()->getMongoDatabase()->selectCollection($entityName);
            $registry->setMongoDBCollection($collection);
        }

        if ($registry instanceof ClassAwareInterface) {

            $shortcutParser = new ShortcutNotationParser($entityName);
            $bundle = $this->container->get('kernel')->getBundle($shortcutParser->getBundleName());

            $stackConfiguration = new EntityStackConfiguration($bundle, $shortcutParser->getEntityName());

            if ($registry instanceof MongoDBAwareInterface) {
                $registry->setEntityClass($stackConfiguration->getDocumentClass());
            } else {
                $registry->setEntityClass($stackConfiguration->getEntityClass());
            }
        }
    }
private function injectDependencies ( RegistryInterface $ registry , $ entityName = null , EntityManager $ entityManager = null ) { if ( ! ( $ entityManager instanceof EntityManager ) ) { /** @var EntityManager $entityManager */ $ entityManager = $ this -> container -> get ( 'doctrine.orm.entity_manager' ) ; } if ( $ registry instanceof EntityManagerAwareInterface ) { $ registry -> setEntityManager ( $ entityManager ) ; } if ( $ registry instanceof EntityRegistry ) { if ( $ entityName === null ) { throw new \ Exception ( 'Can\'t load an entity registry without entity name' ) ; } $ registry -> setEntityRepository ( $ entityManager -> getRepository ( $ entityName ) ) ; } if ( $ registry instanceof MongoDBAwareInterface ) { if ( $ entityName === null ) { throw new \ Exception ( 'Can\'t load a mongodb registry without entity name' ) ; } $ collection = ConnectionFactory :: getInstance ( ) -> getConnection ( ) -> getMongoDatabase ( ) -> selectCollection ( $ entityName ) ; $ registry -> setMongoDBCollection ( $ collection ) ; } if ( $ registry instanceof ClassAwareInterface ) { $ shortcutParser = new ShortcutNotationParser ( $ entityName ) ; $ bundle = $ this -> container -> get ( 'kernel' ) -> getBundle ( $ shortcutParser -> getBundleName ( ) ) ; $ stackConfiguration = new EntityStackConfiguration ( $ bundle , $ shortcutParser -> getEntityName ( ) ) ; if ( $ registry instanceof MongoDBAwareInterface ) { $ registry -> setEntityClass ( $ stackConfiguration -> getDocumentClass ( ) ) ; } else { $ registry -> setEntityClass ( $ stackConfiguration -> getEntityClass ( ) ) ; } } }
Inject dependencies using implemented interfaces to registry

@param \Thuata\ComponentBundle\Registry\RegistryInterface $registry
@param string|null                                        $entityName
@param EntityManager                                      $entityManager

@throws \Exception
Inject dependencies using implemented interfaces to registry