Added filters to doctrine entity manager factory
This commit is contained in:
@@ -18,7 +18,7 @@ use RuntimeException;
|
|||||||
*/
|
*/
|
||||||
class EntityManagerFactory
|
class EntityManagerFactory
|
||||||
{
|
{
|
||||||
public static function create(array $params, bool $dev_mode = false, array $middlewares = []) : EntityManager
|
public static function create(array $params, bool $dev_mode = false, array $middlewares = [], array $filters = []) : EntityManager
|
||||||
{
|
{
|
||||||
self::checkRequiredParams($params, ['paths', 'database', 'proxy_dir']);
|
self::checkRequiredParams($params, ['paths', 'database', 'proxy_dir']);
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ class EntityManagerFactory
|
|||||||
// specifying server version explicitly doesn't trigger this connection, which is not
|
// specifying server version explicitly doesn't trigger this connection, which is not
|
||||||
// needed for proxy generation
|
// needed for proxy generation
|
||||||
if (defined('STDIN') && @$_SERVER['argv'][1] == 'orm:generate-proxies') {
|
if (defined('STDIN') && @$_SERVER['argv'][1] == 'orm:generate-proxies') {
|
||||||
$params['database']['serverVersion'] = 14;
|
$params['database']['serverVersion'] = '14';
|
||||||
}
|
}
|
||||||
|
|
||||||
$paths = $params['paths'];
|
$paths = $params['paths'];
|
||||||
@@ -39,6 +39,10 @@ class EntityManagerFactory
|
|||||||
|
|
||||||
if ($middlewares) $config->setMiddlewares($middlewares);
|
if ($middlewares) $config->setMiddlewares($middlewares);
|
||||||
|
|
||||||
|
foreach ($filters as $name => $class) {
|
||||||
|
$config->addFilter($name, $class);
|
||||||
|
}
|
||||||
|
|
||||||
$connection = DriverManager::getConnection($params['database'], $config);
|
$connection = DriverManager::getConnection($params['database'], $config);
|
||||||
$em = new EntityManager($connection, $config);
|
$em = new EntityManager($connection, $config);
|
||||||
return $em;
|
return $em;
|
||||||
|
|||||||
Reference in New Issue
Block a user