Temporary revert

This commit is contained in:
Nicolas Le Goff
2011-12-27 16:27:04 +01:00
parent 1617d3e561
commit ccda8a86a9

View File

@@ -9,6 +9,7 @@
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Core\Service;
use Doctrine\DBAL\Types\Type;
@@ -24,93 +25,16 @@ class Doctrine
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';
static::loadClasses();
$config = new \Doctrine\ORM\Configuration();
if ($conf["debug"]["enable"])
{
//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;
}
}
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache);
$chainDriverImpl = new \Doctrine\ORM\Mapping\Driver\DriverChain();
@@ -142,7 +66,7 @@ class Doctrine
$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();
@@ -205,20 +129,6 @@ class Doctrine
$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(
'Types'
, realpath(__DIR__ . '/../../../../Doctrine')