<commit_before><?php
namespace Neochic\SlimTools\Factory;

use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
use Doctrine\Common\Annotations\AnnotationRegistry;
use Composer\Autoload\ClassLoader;

class EntityManagerFactory
{
    public static function createEntityManager(array $database, array $doctrine, ClassLoader $classLoader) {
        $isDevMode = true;
	    $config = Setup::createAnnotationMetadataConfiguration($doctrine['model.paths'], $isDevMode, null, null, false);
        $config->setAutoGenerateProxyClasses(constant("Doctrine\\Common\\Proxy\\AbstractProxyFactory::". $doctrine['proxyMode']));

        AnnotationRegistry::registerLoader(array($classLoader, 'loadClass'));

        foreach($doctrine['annotation.paths'] as $namespace => $path) {
            AnnotationRegistry::registerAutoloadNamespace($namespace, $path);
        }

        $em = EntityManager::create($database, $config);
        $em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');

	    return $em;
    }
}<commit_msg>* dql functions can be added to em via config<commit_after><?php
namespace Neochic\SlimTools\Factory;

use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
use Doctrine\Common\Annotations\AnnotationRegistry;
use Composer\Autoload\ClassLoader;

class EntityManagerFactory
{
    public static function createEntityManager(array $database, array $doctrine, ClassLoader $classLoader) {
        $isDevMode = true;
	$config = Setup::createAnnotationMetadataConfiguration($doctrine['model.paths'], $isDevMode, null, null, false);
        $config->setAutoGenerateProxyClasses(constant("Doctrine\\Common\\Proxy\\AbstractProxyFactory::". $doctrine['proxyMode']));

        AnnotationRegistry::registerLoader(array($classLoader, 'loadClass'));

        if (isset($doctrine['annotation.paths'])) {
            foreach ( $doctrine['annotation.paths'] as $namespace => $path ) {
	        AnnotationRegistry::registerAutoloadNamespace( $namespace, $path );
            }
        }

        if (isset($doctrine['dql.paths'])) {
            foreach($doctrine['dql.paths'] as $name => $path) {
                $config->addCustomStringFunction($name, $path);
            }
        }

        $em = EntityManager::create($database, $config);
        $em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');

	    return $em;
    }
}
{'fraction_non_alphanumeric': 0.1375310687655344, 'fraction_numerical': 0.0, 'mean_word_length': 4.296052631578948, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2121117', 'n_tokens_mistral': 658, 'n_tokens_neox': 640, 'n_words': 115}