123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- <?php
-
-
- namespace Doctrine\ORM\Tools;
-
- use Doctrine\Common\ClassLoader;
- use Doctrine\Common\Cache\Cache;
- use Doctrine\Common\Cache\ArrayCache;
- use Doctrine\ORM\Configuration;
- use Doctrine\ORM\Mapping\Driver\XmlDriver;
- use Doctrine\ORM\Mapping\Driver\YamlDriver;
-
-
- class Setup
- {
-
-
- static public function registerAutoloadGit($gitCheckoutRootPath)
- {
- if (!class_exists('Doctrine\Common\ClassLoader', false)) {
- require_once $gitCheckoutRootPath . "/lib/vendor/doctrine-common/lib/Doctrine/Common/ClassLoader.php";
- }
-
- $loader = new ClassLoader("Doctrine\Common", $gitCheckoutRootPath . "/lib/vendor/doctrine-common/lib");
- $loader->register();
-
- $loader = new ClassLoader("Doctrine\DBAL", $gitCheckoutRootPath . "/lib/vendor/doctrine-dbal/lib");
- $loader->register();
-
- $loader = new ClassLoader("Doctrine\ORM", $gitCheckoutRootPath . "/lib");
- $loader->register();
-
- $loader = new ClassLoader("Symfony\Component", $gitCheckoutRootPath . "/lib/vendor");
- $loader->register();
- }
-
-
-
- static public function registerAutoloadPEAR()
- {
- if (!class_exists('Doctrine\Common\ClassLoader', false)) {
- require_once "Doctrine/Common/ClassLoader.php";
- }
-
- $loader = new ClassLoader("Doctrine");
- $loader->register();
-
- $parts = explode(PATH_SEPARATOR, get_include_path());
-
- foreach ($parts AS $includePath) {
- if ($includePath != "." && file_exists($includePath . "/Doctrine")) {
- $loader = new ClassLoader("Symfony\Component", $includePath . "/Doctrine");
- $loader->register();
- return;
- }
- }
- }
-
-
-
- static public function registerAutoloadDirectory($directory)
- {
- if (!class_exists('Doctrine\Common\ClassLoader', false)) {
- require_once $directory . "/Doctrine/Common/ClassLoader.php";
- }
-
- $loader = new ClassLoader("Doctrine");
- $loader->register();
-
- $loader = new ClassLoader("Symfony\Component", $directory . "/Doctrine");
- $loader->register();
- }
-
-
-
- static public function createAnnotationMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, Cache $cache = null)
- {
- $config = self::createConfiguration($isDevMode, $cache, $proxyDir);
- $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver($paths));
- return $config;
- }
-
-
-
- static public function createXMLMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, Cache $cache = null)
- {
- $config = self::createConfiguration($isDevMode, $cache, $proxyDir);
- $config->setMetadataDriverImpl(new XmlDriver($paths));
- return $config;
- }
-
-
-
- static public function createYAMLMetadataConfiguration(array $paths, $isDevMode = false, $proxyDir = null, Cache $cache = null)
- {
- $config = self::createConfiguration($isDevMode, $cache, $proxyDir);
- $config->setMetadataDriverImpl(new YamlDriver($paths));
- return $config;
- }
-
-
-
- static public function createConfiguration($isDevMode = false, $proxyDir = null, Cache $cache = null)
- {
- if ($isDevMode === false && $cache === null) {
- if (extension_loaded('apc')) {
- $cache = new \Doctrine\Common\Cache\ApcCache;
- } else if (extension_loaded('xcache')) {
- $cache = new \Doctrine\Common\Cache\XcacheCache;
- } else if (extension_loaded('memcache')) {
- $memcache = new \Memcache();
- $memcache->connect('127.0.0.1');
- $cache = new \Doctrine\Common\Cache\MemcacheCache();
- $cache->setMemcache($memcache);
- } else {
- $cache = new ArrayCache;
- }
- $cache->setNamespace("dc2_");
- } else if ($cache === null) {
- $cache = new ArrayCache;
- }
-
- $config = new Configuration();
- $config->setMetadataCacheImpl($cache);
- $config->setQueryCacheImpl($cache);
- $config->setResultCacheImpl($cache);
- $config->setProxyDir( $proxyDir ?: sys_get_temp_dir() );
- $config->setProxyNamespace('DoctrineProxies');
- $config->setAutoGenerateProxyClasses($isDevMode);
-
- return $config;
- }
- }
|