public function build() : EntityManager
{
$driver = new SimplifiedXmlDriver($this->mappings);
$config = Setup::createConfiguration(true);
$config->setMetadataDriverImpl($driver);
if (!is_null($this->logger)) {
$config->setSQLLogger($this->logger);
}
foreach ($this->customTypes as $customTypeName => $customTypeClass) {
if (!Type::hasType($customTypeName)) {
Type::addType($customTypeName, $customTypeClass);
}
}
$em = EntityManager::create($this->connection, $config);
foreach ($this->customTypes as $customTypeName => $customTypeClass) {
$em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping($customTypeName, $customTypeName);
}
return $em;
}