config = $config; $this->injectableFactory = $injectableFactory; $this->metadataDataProvider = $metadataDataProvider; $this->eventDispatcher = $eventDispatcher; } public function create(): EntityManager { $entityFactory = $this->injectableFactory->create(EntityFactory::class); $repositoryFactory = $this->injectableFactory->createWith(RepositoryFactory::class, [ 'entityFactory' => $entityFactory, ]); $config = $this->config; $databaseParams = DatabaseParams::create() ->withHost($config->get('database.host')) ->withPort($config->get('database.port') ? (int) $config->get('database.port') : null) ->withName($config->get('database.dbname')) ->withUsername($config->get('database.user')) ->withPassword($config->get('database.password')) ->withCharset($config->get('database.charset') ?? 'utf8') ->withDriver($config->get('database.driver')) ->withPlatform($config->get('database.platform')) ->withSslCa($config->get('database.sslCA')) ->withSslCert($config->get('database.sslCert')) ->withSslKey($config->get('database.sslKey')) ->withSslCaPath($config->get('database.sslCAPath')) ->withSslCipher($config->get('database.sslCipher')) ->withSslVerifyDisabled($config->get('database.sslVerifyDisabled') ?? false); $metadata = new Metadata($this->metadataDataProvider, $this->eventDispatcher); $valueFactoryFactory = $this->injectableFactory->createWith( ValueFactoryFactory::class, [ 'ormMetadata' => $metadata, ] ); $attributeExtractorFactory = $this->injectableFactory->createWith( AttributeExtractorFactory::class, [ 'ormMetadata' => $metadata, ] ); $entityManager = $this->injectableFactory->createWith( EntityManager::class, [ 'databaseParams' => $databaseParams, 'metadata' => $metadata, 'repositoryFactory' => $repositoryFactory, 'entityFactory' => $entityFactory, 'valueFactoryFactory' => $valueFactoryFactory, 'attributeExtractorFactory' => $attributeExtractorFactory, 'eventDispatcher' => $this->eventDispatcher, ] ); return $entityManager; } }