|
|
|
@ -18,7 +18,7 @@ use RuntimeException; |
|
|
|
*/ |
|
|
|
class EntityManagerFactory |
|
|
|
{ |
|
|
|
public static function create(array $params, bool $dev_mode = false) : EntityManager |
|
|
|
public static function create(array $params, bool $dev_mode = false, array $middlewares = []) : EntityManager |
|
|
|
{ |
|
|
|
self::checkRequiredParams($params, ['paths', 'database', 'proxy_dir']); |
|
|
|
|
|
|
|
@ -37,6 +37,8 @@ class EntityManagerFactory |
|
|
|
$config = ORMSetup::createAttributeMetadataConfiguration($paths, $dev_mode, $params['proxy_dir'], $cache_adapter); |
|
|
|
$config->setAutoGenerateProxyClasses($dev_mode ? AbstractProxyFactory::AUTOGENERATE_ALWAYS : AbstractProxyFactory::AUTOGENERATE_NEVER); |
|
|
|
|
|
|
|
if ($middlewares) $config->setMiddlewares($middlewares); |
|
|
|
|
|
|
|
$connection = DriverManager::getConnection($params['database'], $config); |
|
|
|
$em = new EntityManager($connection, $config); |
|
|
|
return $em; |
|
|
|
|