mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-13 04:53:26 +00:00
Temporary revert
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
namespace Alchemy\Phrasea\Core\Service;
|
namespace Alchemy\Phrasea\Core\Service;
|
||||||
|
|
||||||
use Doctrine\DBAL\Types\Type;
|
use Doctrine\DBAL\Types\Type;
|
||||||
@@ -24,93 +25,16 @@ class Doctrine
|
|||||||
|
|
||||||
protected $entityManager;
|
protected $entityManager;
|
||||||
|
|
||||||
public function __construct(Array $conf)
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
|
||||||
require_once __DIR__ . '/../../../../vendor/doctrine2-orm/lib/vendor/doctrine-common/lib/Doctrine/Common/ClassLoader.php';
|
require_once __DIR__ . '/../../../../vendor/doctrine2-orm/lib/vendor/doctrine-common/lib/Doctrine/Common/ClassLoader.php';
|
||||||
|
|
||||||
static::loadClasses();
|
static::loadClasses();
|
||||||
|
|
||||||
$config = new \Doctrine\ORM\Configuration();
|
$config = new \Doctrine\ORM\Configuration();
|
||||||
|
|
||||||
if ($conf["debug"]["enable"])
|
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache);
|
||||||
{
|
|
||||||
//Force Array
|
|
||||||
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
|
|
||||||
$config->setQueryCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ($conf["cache"]["query_cache"]["enable"])
|
|
||||||
{
|
|
||||||
//define query cache
|
|
||||||
switch ($conf["cache"]["query_cache"]["type"])
|
|
||||||
{
|
|
||||||
case 'memcached':
|
|
||||||
$config->setQueryCacheImpl(new \Doctrine\Common\Cache\MemcacheCache());
|
|
||||||
break;
|
|
||||||
case 'apc':
|
|
||||||
$config->setQueryCacheImpl(new \Doctrine\Common\Cache\ApcCache());
|
|
||||||
break;
|
|
||||||
case 'array':
|
|
||||||
default:
|
|
||||||
$config->setQueryCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($conf["cache"]["metadatas_cache"]["enable"])
|
|
||||||
{
|
|
||||||
//define metadatas cache
|
|
||||||
switch ($conf["cache"]["metadatas_cache"]["type"])
|
|
||||||
{
|
|
||||||
case 'memcached':
|
|
||||||
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\MemcacheCache());
|
|
||||||
break;
|
|
||||||
case 'apc':
|
|
||||||
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ApcCache());
|
|
||||||
break;
|
|
||||||
case 'array':
|
|
||||||
default:
|
|
||||||
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//define autoregeneration of proxies
|
|
||||||
if (!$conf["debug"]["enable"])
|
|
||||||
{
|
|
||||||
$config->setAutoGenerateProxyClasses(false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$config->setAutoGenerateProxyClasses(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//define logger
|
|
||||||
if ($conf["debug"]["enable"] && $conf["logger"]["enable"])
|
|
||||||
{
|
|
||||||
switch ($conf["logger"]["type"])
|
|
||||||
{
|
|
||||||
case 'monolog':
|
|
||||||
$logger = new \Monolog\Logger('query-logger');
|
|
||||||
$logger->pushHandler(new \Monolog\Handler\RotatingFileHandler(
|
|
||||||
__DIR__ . '/../../../../../logs/doctrine-query.log')
|
|
||||||
, $conf["logger"]["max_day"]
|
|
||||||
);
|
|
||||||
$config->setSQLLogger(new \Doctrine\Logger\MonologSQLLogger(
|
|
||||||
$logger,
|
|
||||||
$conf["logger"]["output"])
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case 'echo':
|
|
||||||
$config->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$config->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$chainDriverImpl = new \Doctrine\ORM\Mapping\Driver\DriverChain();
|
$chainDriverImpl = new \Doctrine\ORM\Mapping\Driver\DriverChain();
|
||||||
|
|
||||||
@@ -142,7 +66,7 @@ class Doctrine
|
|||||||
|
|
||||||
$evm->addEventSubscriber(new \Gedmo\Timestampable\TimestampableListener());
|
$evm->addEventSubscriber(new \Gedmo\Timestampable\TimestampableListener());
|
||||||
|
|
||||||
$this->entityManager = \Doctrine\ORM\EntityManager::create($conf["credentials"], $config, $evm);
|
$this->entityManager = \Doctrine\ORM\EntityManager::create($connectionOptions, $config, $evm);
|
||||||
|
|
||||||
$this->addTypes();
|
$this->addTypes();
|
||||||
|
|
||||||
@@ -205,20 +129,6 @@ class Doctrine
|
|||||||
|
|
||||||
$classLoader->register();
|
$classLoader->register();
|
||||||
|
|
||||||
$classLoader = new \Doctrine\Common\ClassLoader(
|
|
||||||
'Doctrine\Logger'
|
|
||||||
, realpath(__DIR__ . '/../../../../')
|
|
||||||
);
|
|
||||||
|
|
||||||
$classLoader->register();
|
|
||||||
|
|
||||||
$classLoader = new \Doctrine\Common\ClassLoader(
|
|
||||||
'Monolog'
|
|
||||||
, realpath(__DIR__ . '/../../../../vendor/Silex/vendor/monolog/src')
|
|
||||||
);
|
|
||||||
|
|
||||||
$classLoader->register();
|
|
||||||
|
|
||||||
$classLoader = new \Doctrine\Common\ClassLoader(
|
$classLoader = new \Doctrine\Common\ClassLoader(
|
||||||
'Types'
|
'Types'
|
||||||
, realpath(__DIR__ . '/../../../../Doctrine')
|
, realpath(__DIR__ . '/../../../../Doctrine')
|
||||||
|
Reference in New Issue
Block a user