drobne upravy v UI atd.
[dw-class2.git] / cli-config.php
blob8bc285f2238ad4a2e477ed8205bb63cb52ea596e
1 <?php
2 use Doctrine\Common\ClassLoader,
3 Doctrine\ORM\Configuration,
4 Doctrine\ORM\EntityManager,
5 Doctrine\Common\Cache\ApcCache,
6 Doctrine\Common\Cache\ArrayCache,
7 Doctrine\DBAL\Event\Listeners\MysqlSessionInit;
9 require_once 'lib/Doctrine/Common/ClassLoader.php';
11 // Set up class loading. You could use different autoloaders, provided by your favorite framework,
12 // if you want to.
14 $classLoader = new ClassLoader('Doctrine\ORM', realpath(__DIR__ . '/lib'));
15 $classLoader->register();
16 $classLoader = new ClassLoader('Doctrine\DBAL', realpath(__DIR__ . '/lib'));
17 $classLoader->register();
18 $classLoader = new ClassLoader('Doctrine\Common', realpath(__DIR__ . '/lib'));
19 $classLoader->register();
20 $classLoader = new ClassLoader('Symfony', realpath(__DIR__ . '/lib'));
21 $classLoader->register();
23 $classLoader = new ClassLoader('Doctrine\ORM', 'lib');
24 $classLoader->register();
25 $classLoader = new ClassLoader('Doctrine\DBAL', 'lib');
26 $classLoader->register();
27 $classLoader = new ClassLoader('Doctrine\Common', 'lib');
28 $classLoader->register();
29 $classLoader = new ClassLoader('Symfony', 'lib');
30 $classLoader->register();
32 $namespaces = array(
33 'Entities',
34 'Proxies',
35 // Custom class loaders
36 'Structure',
37 'Exception',
38 'Tools',
39 'Facade',
40 'Presenters',
41 'UI',
44 foreach($namespaces as $namespace) {
45 $classLoader = new ClassLoader($namespace, realpath(__DIR__ . '/classes'));
46 $classLoader->register();
49 // Set up caches
50 $config = new Configuration;
51 //$cache = new ApcCache;
52 $cache = new ArrayCache;
53 $config->setMetadataCacheImpl($cache);
54 $driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__. '/classes/Entities'));
55 $config->setMetadataDriverImpl($driverImpl);
56 $config->setQueryCacheImpl($cache);
58 // Proxy configuration
59 $config->setProxyDir(__DIR__ . '/classes/Proxies');
60 $config->setProxyNamespace('Proxies');
61 $config->setAutoGenerateProxyClasses(false);
63 require('db-config.php');
65 // Create EntityManager
66 $em = EntityManager::create($connectionOptions, $config);
67 $em->getEventManager()->addEventSubscriber(new MysqlSessionInit('utf8', 'utf8_unicode_ci'));
69 // Helpers for console
70 $helperSet = new \Symfony\Component\Console\Helper\HelperSet;
71 $helperSet->set(new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()), 'db');
72 $helperSet->set(new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em), 'em');