Mock factory method to create an EntityManager.

{@inheritdoc}
3322
public static function create($conn, Configuration $config = null, EventManager $eventManager = null)
    {
        if (null === $config) {
            $config = new Configuration();
            $config->setProxyDir(__DIR__ . '/../Proxies');
            $config->setProxyNamespace('Doctrine\Tests\Proxies');
            $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver([], true));
        }
        if (null === $eventManager) {
            $eventManager = new EventManager();
        }

        return new EntityManagerMock($conn, $config, $eventManager);
    }
323546
public static DocumentBuilder newDocumentBuilder(final DocumentBuilderFactory factory)
   {
      try
      {
         final DocumentBuilder builder = factory.newDocumentBuilder();
         return builder;
      }
      catch (Exception e)
      {
         throw MESSAGES.unableToCreateInstanceOf(e, DocumentBuilder.class.getName());
      }
   }
585389
protected function registerEloquentFactory()
    {
        $this->container['db.faker'] = function () {
            return FakerFactory::create();
        };

        $this->container['db.eloquent'] = function ($container) {
            return EloquentFactory::construct(
                $container['db.faker'],
                database_path('factories')
            );
        };
    }
395807
@Override
    public T create(CreationalContext<T> creationalContext) {
        T instance = getProducer().produce(creationalContext);
        getProducer().inject(instance, creationalContext);

        if (!hasPostConstructCallback || beanManager.isContextActive(RequestScoped.class)) {
            getProducer().postConstruct(instance);
        } else {
            /*
             * CDI-219
             * The request scope is active during @PostConstruct callback of any bean.
             */
            RequestContext context = getUnboundRequestContext();
            try {
                context.activate();
                beanManager.fireRequestContextInitialized(getId());
                getProducer().postConstruct(instance);
            } finally {
                beanManager.fireRequestContextBeforeDestroyed(getId());
                context.invalidate();
                context.deactivate();
                beanManager.fireRequestContextDestroyed(getId());
            }
        }
        return instance;
    }
538942
public function createMetaEntityFactory(): MetaEntityFactory {
		if (null === $this->metaEntityFactory) {
			$this->metaEntityFactory = new MysqlMetaEntityFactory($this);
		}
		
		return $this->metaEntityFactory;
	}
671551
protected function registerEloquentFactory()
    {
        $this->app->singleton(FakerGenerator::class, function ($app) {
            return FakerFactory::create($app['config']->get('app.faker_locale', 'en_US'));
        });

        $this->app->singleton(EloquentFactory::class, function ($app) {
            return EloquentFactory::construct(
                $app->make(FakerGenerator::class), $this->app->databasePath('factories')
            );
        });
    }
748825
public function create()
    {
        $entityClass = $this->getEntityName();

        $reflection = new \ReflectionClass($entityClass);

        if ($reflection->isAbstract()) {
            throw RuntimeException::createAbstract($entityClass);
        }

        return new $entityClass();
    }
718249
public static Object instantiateObject(Class<?> clazz) {
    try {
      Constructor<?> constructor = clazz.getConstructor();
      return constructor.newInstance();
    } catch (Exception exp) {
      throw new EntityManagerException(exp);
    }

  }
1219582
function factory($key, $factory)
	{
		if($factory instanceof Factory)
		{
			$this->_registry[$key] = function() use($factory) {
				return $factory->create();
			};
		}
		else if(is_callable($factory))
		{
			$this->_registry[$key] = $factory;
		}
		else
		{
			throw new RegistryException(
				"Parameter must be a Factory or Closure");
		}

		return $this;
	}
899592
@Override
    public <T> T create(EntityCreateOperation<T> creator)
            throws ServiceException {
        try {
            return service.create(creator);
        } catch (UniformInterfaceException e) {
            throw processCatch(new ServiceException(e));
        } catch (ClientHandlerException e) {
            throw processCatch(new ServiceException(e));
        }
    }
108450
static EntityManager proxy(EntityManager entityManager) {
    ProxyFactory proxyFactory = new ProxyFactory(entityManager);
    proxyFactory.addAdvice(new RepositoryEntityManagerEntityGraphInjector());
    return (EntityManager) proxyFactory.getProxy();
  }
1265030
public function injectEntityManager(EntityManagerInterface $entityManager, ClassMetadata $classMetadata) : void
    {
        if ($entityManager !== self::$entityManager) {
            throw new RuntimeException(
                'Trying to use PersistentObject with different EntityManager instances. ' .
                'Was PersistentObject::setEntityManager() called?'
            );
        }

        $this->cm = $classMetadata;
    }
846576
private synchronized void initialize() {
        Iterator types = EntityTypesLocator.getEntityTypes().getAllEntityTypes();
        String factoryName = null;

        while (types.hasNext()) {
            Class type = (Class) types.next();
            if (type != Object.class) {
                String factoryKey =
                        "org.apereo.portal.services.EntityNameFinderService.NameFinderFactory.implementation_"
                                + type.getName();
                try {
                    factoryName = PropertiesManager.getProperty(factoryKey);
                } catch (Exception runtime) {
                    String dMsg =
                            "EntityNameFinderService.initialize(): "
                                    + "could not find property for "
                                    + type.getName()
                                    + " factory.";
                    log.debug(dMsg);
                }
                if (factoryName != null) {
                    try {
                        IEntityNameFinderFactory factory =
                                (IEntityNameFinderFactory) Class.forName(factoryName).newInstance();
                        getNameFinders().put(type, factory.newFinder());
                    } catch (Exception e) {
                        String eMsg =
                                "EntityNameFinderService.initialize(): "
                                        + "Could not instantiate finder for "
                                        + type.getName()
                                        + ": ";
                        log.error(eMsg, e);
                    }
                }
            }
        }
        setInitialized(true);
    }
877193
@Override
	public Object create(Object locator) throws CreateException {
		for (Registration registration : _registrations) {
			if (registration.getLocator().equals(locator)) {
				try {
					return registration.getFactory().create(locator);
				} catch (Exception ex) {
					if (ex instanceof CreateException)
						throw (CreateException) ex;

					throw (CreateException) new CreateException(null, "Failed to create object for " + locator)
							.withCause(ex);
				}
			}
		}
		return null;
	}
1137908
public function createOriginalEntity(EntityManagerInterface $em, $entity)
    {
        $uow      = $em->getUnitOfWork();
        $id_data  = $uow->isInIdentityMap($entity) ? $uow->getEntityIdentifier($entity) : [];
        $data     = $uow->getOriginalEntityData($entity);
        $metadata = $em->getClassMetadata(get_class($entity));
        $original = $metadata->newInstance();
        $fields   = array_merge($metadata->getFieldNames(), $metadata->getAssociationNames());

        if (empty($data) && !empty($fields)) {
            return null;
        }

        foreach ($fields as $field) {
            if (isset($data[$field])) {
                $metadata->setFieldValue($original, $field, $data[$field]);
            } elseif (isset($id_data[$field]) && $metadata->isIdentifier($field) && $metadata->isIdGeneratorIdentity()) {
                $metadata->setFieldValue($original, $field, $id_data[$field]);
            } elseif ($metadata->isAssociationInverseSide($field)) {
                $metadata->setFieldValue($original, $field, $metadata->getFieldValue($entity, $field));
            }
        }

        return $original;
    }
407408
public function createMetaEntityFactory(): MetaEntityFactory {
		if (null === $this->metaEntityFactory) {
			$this->metaEntityFactory = new SqliteMetaEntityFactory($this);
		}
		
		return $this->metaEntityFactory;
	}
463362
private function getObjectManager($entityClassname)
    {
        $objectManager = $this->getContainer()->get('doctrine')->getManagerForClass($entityClassname);
        if ($objectManager) {
            return $objectManager;
        }

        $objectManager = $this->getContainer()->get('doctrine_mongodb')->getManagerForClass($entityClassname);
        if ($objectManager) {
            return $objectManager;
        }

        throw new \RuntimeException(sprintf('Class "%s" is not a managed entity', $entityClassname));
    }