From dca0881d943b22d0d42bed5cd451611e6e9a0343 Mon Sep 17 00:00:00 2001 From: Gusakov Nikita Date: Sat, 18 May 2013 01:42:55 +0400 Subject: [PATCH] forget add changes --- tools/sandbox/bootstrap.php | 35 +++++++++++++++++++++++++++ tools/sandbox/doctrine.php | 22 ++++------------- tools/sandbox/index.php | 48 ++++--------------------------------- 3 files changed, 44 insertions(+), 61 deletions(-) diff --git a/tools/sandbox/bootstrap.php b/tools/sandbox/bootstrap.php index e69de29bb..0e7120544 100644 --- a/tools/sandbox/bootstrap.php +++ b/tools/sandbox/bootstrap.php @@ -0,0 +1,35 @@ +add('Entities', __DIR__); +$loader->add('Proxies', __DIR__); + +$config = new \Doctrine\ORM\Configuration(); + +// Set up Metadata Drivers +$driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__ . "/Entities")); +$config->setMetadataDriverImpl($driverImpl); + +// Set up caches +$cache = new ApcCache; +$config->setMetadataCacheImpl($cache); +$config->setQueryCacheImpl($cache); +$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache); + +// Proxy configuration +$config->setProxyDir(__DIR__ . '/Proxies'); +$config->setProxyNamespace('Proxies'); + +// Database connection information +$connectionOptions = array( + 'driver' => 'pdo_sqlite', + 'path' => 'database.sqlite' +); + +return EntityManager::create($connectionOptions, $config); \ No newline at end of file diff --git a/tools/sandbox/doctrine.php b/tools/sandbox/doctrine.php index 9060e6f7b..66ed4f3c1 100644 --- a/tools/sandbox/doctrine.php +++ b/tools/sandbox/doctrine.php @@ -1,27 +1,15 @@ register(); -$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\DBAL', realpath(__DIR__ . '/../../lib/vendor/doctrine-dbal/lib')); -$classLoader->register(); -$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\Common', realpath(__DIR__ . '/../../lib/vendor/doctrine-common/lib')); -$classLoader->register(); -$classLoader = new \Doctrine\Common\ClassLoader('Symfony', realpath(__DIR__ . '/../../lib/vendor')); -$classLoader->register(); -$classLoader = new \Doctrine\Common\ClassLoader('Entities', __DIR__); -$classLoader->register(); -$classLoader = new \Doctrine\Common\ClassLoader('Proxies', __DIR__); -$classLoader->register(); - -require __DIR__ . '/cli-config.php'; +$em = require_once __DIR__.'/bootstrap.php'; $cli = new \Symfony\Component\Console\Application('Doctrine Command Line Interface', Doctrine\Common\Version::VERSION); $cli->setCatchExceptions(true); // Variable $helpers is defined inside cli-config.php -$cli->setHelperSet($helpers); +$cli->setHelperSet(new Symfony\Component\Console\Helper\HelperSet(array( + 'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()), + 'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em) +))); $cli->addCommands(array( // DBAL Commands diff --git a/tools/sandbox/index.php b/tools/sandbox/index.php index ad1cb9d6b..f866aeada 100644 --- a/tools/sandbox/index.php +++ b/tools/sandbox/index.php @@ -1,7 +1,7 @@ register(); -$classLoader = new ClassLoader('Doctrine\DBAL', realpath(__DIR__ . '/../../lib/vendor/doctrine-dbal/lib')); -$classLoader->register(); -$classLoader = new ClassLoader('Doctrine\Common', realpath(__DIR__ . '/../../lib/vendor/doctrine-common/lib')); -$classLoader->register(); -$classLoader = new ClassLoader('Symfony', realpath(__DIR__ . '/../../lib/vendor')); -$classLoader->register(); -$classLoader = new ClassLoader('Entities', __DIR__); -$classLoader->register(); -$classLoader = new ClassLoader('Proxies', __DIR__); -$classLoader->register(); - -// Set up caches -$config = new Configuration; -$cache = new ApcCache; -$config->setMetadataCacheImpl($cache); -$driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__."/Entities")); -$config->setMetadataDriverImpl($driverImpl); -$config->setQueryCacheImpl($cache); - -// Proxy configuration -$config->setProxyDir(__DIR__ . '/Proxies'); -$config->setProxyNamespace('Proxies'); -$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache); - -// Database connection information -$connectionOptions = array( - 'driver' => 'pdo_sqlite', - 'path' => 'database.sqlite' -); - -// Create EntityManager -$em = EntityManager::create($connectionOptions, $config); +$em = require_once __DIR__ . '/bootstrap.php'; ## PUT YOUR TEST CODE BELOW