コード例 #1
0
ファイル: OrmTestCase.php プロジェクト: naderman/doctrine2
    /**
     * Creates an EntityManager for testing purposes.
     * 
     * NOTE: The created EntityManager will have its dependant DBAL parts completely
     * mocked out using a DriverMock, ConnectionMock, etc. These mocks can then
     * be configured in the tests to simulate the DBAL behavior that is desired
     * for a particular test,
     *
     * @return Doctrine\ORM\EntityManager
     */
    protected function _getTestEntityManager($conn = null, $conf = null, $eventManager = null, $withSharedMetadata = true)
    {
        $config = new \Doctrine\ORM\Configuration();
        if($withSharedMetadata) {
            $config->setMetadataCacheImpl(self::getSharedMetadataCacheImpl());
        } else {
            $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache);
        }

        $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver());

        $config->setQueryCacheImpl(self::getSharedQueryCacheImpl());
        $config->setProxyDir(__DIR__ . '/Proxies');
        $config->setProxyNamespace('Doctrine\Tests\Proxies');
        $eventManager = new \Doctrine\Common\EventManager();
        if ($conn === null) {
            $conn = array(
                'driverClass' => 'Doctrine\Tests\Mocks\DriverMock',
                'wrapperClass' => 'Doctrine\Tests\Mocks\ConnectionMock',
                'user' => 'john',
                'password' => 'wayne'
            );
        }
        if (is_array($conn)) {
            $conn = \Doctrine\DBAL\DriverManager::getConnection($conn, $config, $eventManager);
        }
        return \Doctrine\Tests\Mocks\EntityManagerMock::create($conn, $config, $eventManager);
    }
コード例 #2
0
 protected function getDoctrine_Orm_DefaultEntityManagerService()
 {
     require_once 'D:/xampp/htdocs/symfony_installer/rest/app/cache/prod/jms_diextra/doctrine/EntityManager_565715f0d6f2e.php';
     $a = new \Doctrine\Common\Cache\ArrayCache();
     $a->setNamespace('sf2orm_default_0e40646fce844daa965ec40672242e7d');
     $b = new \Doctrine\Common\Cache\ArrayCache();
     $b->setNamespace('sf2orm_default_0e40646fce844daa965ec40672242e7d');
     $c = new \Doctrine\Common\Cache\ArrayCache();
     $c->setNamespace('sf2orm_default_0e40646fce844daa965ec40672242e7d');
     $d = new \Doctrine\ORM\Mapping\Driver\DriverChain();
     $d->addDriver(new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($this->get('annotation_reader'), array(0 => 'D:\\xampp\\htdocs\\symfony_installer\\rest\\src\\WireDelta\\DemoBundle\\Entity')), 'WireDelta\\DemoBundle\\Entity');
     $e = new \Doctrine\ORM\Configuration();
     $e->setEntityNamespaces(array('WireDeltaDemoBundle' => 'WireDelta\\DemoBundle\\Entity'));
     $e->setMetadataCacheImpl($a);
     $e->setQueryCacheImpl($b);
     $e->setResultCacheImpl($c);
     $e->setMetadataDriverImpl($d);
     $e->setProxyDir('D:/xampp/htdocs/symfony_installer/rest/app/cache/prod/doctrine/orm/Proxies');
     $e->setProxyNamespace('Proxies');
     $e->setAutoGenerateProxyClasses(false);
     $e->setClassMetadataFactoryName('Doctrine\\ORM\\Mapping\\ClassMetadataFactory');
     $e->setDefaultRepositoryClassName('Doctrine\\ORM\\EntityRepository');
     $e->setNamingStrategy(new \Doctrine\ORM\Mapping\DefaultNamingStrategy());
     $f = call_user_func(array('Doctrine\\ORM\\EntityManager', 'create'), $this->get('doctrine.dbal.default_connection'), $e);
     $this->get('doctrine.orm.default_manager_configurator')->configure($f);
     return $this->services['doctrine.orm.default_entity_manager'] = new \EntityManager565715f0d6f2e_546a8d27f194334ee012bfe64f629947b07e4919\__CG__\Doctrine\ORM\EntityManager($f, $this);
 }
コード例 #3
0
 /**
  * Factory method which creates an EntityManager.
  *
  * @return \Doctrine\ORM\EntityManager
  */
 public function create()
 {
     $config = new \Doctrine\ORM\Configuration();
     $config->setClassMetadataFactoryName('TYPO3\\Flow\\Persistence\\Doctrine\\Mapping\\ClassMetadataFactory');
     $cache = new \TYPO3\Flow\Persistence\Doctrine\CacheAdapter();
     // must use ObjectManager in compile phase...
     $cache->setCache($this->objectManager->get('TYPO3\\Flow\\Cache\\CacheManager')->getCache('Flow_Persistence_Doctrine'));
     $config->setMetadataCacheImpl($cache);
     $config->setQueryCacheImpl($cache);
     $resultCache = new \TYPO3\Flow\Persistence\Doctrine\CacheAdapter();
     // must use ObjectManager in compile phase...
     $resultCache->setCache($this->objectManager->get('TYPO3\\Flow\\Cache\\CacheManager')->getCache('Flow_Persistence_Doctrine_Results'));
     $config->setResultCacheImpl($resultCache);
     if (class_exists($this->settings['doctrine']['sqlLogger'])) {
         $config->setSQLLogger(new $this->settings['doctrine']['sqlLogger']());
     }
     $eventManager = $this->buildEventManager();
     $flowAnnotationDriver = $this->objectManager->get('TYPO3\\Flow\\Persistence\\Doctrine\\Mapping\\Driver\\FlowAnnotationDriver');
     $config->setMetadataDriverImpl($flowAnnotationDriver);
     $proxyDirectory = \TYPO3\Flow\Utility\Files::concatenatePaths(array($this->environment->getPathToTemporaryDirectory(), 'Doctrine/Proxies'));
     \TYPO3\Flow\Utility\Files::createDirectoryRecursively($proxyDirectory);
     $config->setProxyDir($proxyDirectory);
     $config->setProxyNamespace('TYPO3\\Flow\\Persistence\\Doctrine\\Proxies');
     $config->setAutoGenerateProxyClasses(FALSE);
     $entityManager = \Doctrine\ORM\EntityManager::create($this->settings['backendOptions'], $config, $eventManager);
     $flowAnnotationDriver->setEntityManager($entityManager);
     \Doctrine\DBAL\Types\Type::addType('objectarray', 'TYPO3\\Flow\\Persistence\\Doctrine\\DataTypes\\ObjectArray');
     if (isset($this->settings['doctrine']['filters']) && is_array($this->settings['doctrine']['filters'])) {
         foreach ($this->settings['doctrine']['filters'] as $filterName => $filterClass) {
             $config->addFilter($filterName, $filterClass);
             $entityManager->getFilters()->enable($filterName);
         }
     }
     return $entityManager;
 }
コード例 #4
0
 private function init()
 {
     if (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers())) {
         \PHPUnit_Framework_TestCase::markTestSkipped('This test requires SQLite support in your environment');
     }
     $config = new \Doctrine\ORM\Configuration();
     $config->setEntityNamespaces(array('UebbHateoasBundle' => 'uebb\\HateoasBundle\\Tests\\Entity'));
     $config->setAutoGenerateProxyClasses(true);
     $config->setProxyDir(\sys_get_temp_dir());
     $config->setProxyNamespace('UebbHateoasTests\\Doctrine');
     $reader = new AnnotationReader();
     $metadataDriver = new AnnotationDriver($reader, 'uebb\\HateoasBundle\\Tests\\Entity');
     $config->setMetadataDriverImpl($metadataDriver);
     $config->setQueryCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     $params = array('driver' => 'pdo_sqlite', 'memory' => true);
     $this->entityManager = EntityManager::create($params, $config);
     $this->linkParser = $this->getMock('uebb\\HateoasBundle\\Service\\LinkParserInterface');
     $this->linkResolver = $this->getMock('uebb\\HateoasBundle\\Service\\LinkResolverInterface');
     $this->dispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $this->formResolver = new FormResolver($this->factory, $reader);
     $this->queryParser = $this->getMock('uebb\\HateoasBundle\\Service\\QueryParserInterface');
     $this->serializer = $this->getMock('JMS\\Serializer\\SerializerInterface');
     $this->validator = $this->getMock('Symfony\\Component\\Validator\\Validator\\ValidatorInterface');
     $this->requestProcessor = new RequestProcessor($this->entityManager, $this->linkParser, $this->linkResolver, $this->formResolver, $this->dispatcher, $this->queryParser, $this->serializer, $this->validator);
 }
コード例 #5
0
 protected function getDoctrine_Orm_DefaultEntityManagerService()
 {
     $a = new \Doctrine\Common\Cache\ArrayCache();
     $a->setNamespace('sf2orm_default_4daee9dfb8af5f706c767d9f3ee73fb6');
     $b = new \Doctrine\Common\Cache\ArrayCache();
     $b->setNamespace('sf2orm_default_4daee9dfb8af5f706c767d9f3ee73fb6');
     $c = new \Doctrine\Common\Cache\ArrayCache();
     $c->setNamespace('sf2orm_default_4daee9dfb8af5f706c767d9f3ee73fb6');
     $d = new \Doctrine\ORM\Mapping\Driver\SimplifiedXmlDriver(array('C:\\xampp\\htdocs\\betafinale\\vendor\\friendsofsymfony\\user-bundle\\FOS\\UserBundle\\Resources\\config\\doctrine' => 'FOS\\UserBundle\\Entity'));
     $d->setGlobalBasename('mapping');
     $e = new \Doctrine\ORM\Mapping\Driver\DriverChain();
     $e->addDriver($d, 'FOS\\UserBundle\\Entity');
     $e->addDriver(new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($this->get('annotation_reader'), array(0 => 'C:\\xampp\\htdocs\\betafinale\\src\\Utilisateur\\UtilisateurBundle\\Entity')), 'Utilisateur\\UtilisateurBundle\\Entity');
     $e->addDriver(new \Doctrine\ORM\Mapping\Driver\XmlDriver(new \Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator(array('C:\\xampp\\htdocs\\betafinale\\vendor\\friendsofsymfony\\user-bundle\\FOS\\UserBundle\\Resources\\config\\doctrine\\model' => 'FOS\\UserBundle\\Model'), '.orm.xml')), 'FOS\\UserBundle\\Model');
     $f = new \Doctrine\ORM\Configuration();
     $f->setEntityNamespaces(array('FOSUserBundle' => 'FOS\\UserBundle\\Entity', 'UtilisateurBundle' => 'Utilisateur\\UtilisateurBundle\\Entity'));
     $f->setMetadataCacheImpl($a);
     $f->setQueryCacheImpl($b);
     $f->setResultCacheImpl($c);
     $f->setMetadataDriverImpl($e);
     $f->setProxyDir('C:/xampp/htdocs/betafinale/app/cache/prod/doctrine/orm/Proxies');
     $f->setProxyNamespace('Proxies');
     $f->setAutoGenerateProxyClasses(false);
     $f->setClassMetadataFactoryName('Doctrine\\ORM\\Mapping\\ClassMetadataFactory');
     $f->setDefaultRepositoryClassName('Doctrine\\ORM\\EntityRepository');
     $f->setNamingStrategy(new \Doctrine\ORM\Mapping\DefaultNamingStrategy());
     $this->services['doctrine.orm.default_entity_manager'] = $instance = call_user_func(array('Doctrine\\ORM\\EntityManager', 'create'), $this->get('doctrine.dbal.default_connection'), $f);
     $this->get('doctrine.orm.default_manager_configurator')->configure($instance);
     return $instance;
 }
コード例 #6
0
 protected function getDoctrine_Orm_DefaultEntityManagerService()
 {
     $a = new \Doctrine\Common\Cache\ArrayCache();
     $a->setNamespace('sf2orm_default_96cf3538b0da5baecb67532527b29efb');
     $b = new \Doctrine\Common\Cache\ArrayCache();
     $b->setNamespace('sf2orm_default_96cf3538b0da5baecb67532527b29efb');
     $c = new \Doctrine\Common\Cache\ArrayCache();
     $c->setNamespace('sf2orm_default_96cf3538b0da5baecb67532527b29efb');
     $d = new \Doctrine\ORM\Mapping\Driver\SimplifiedXmlDriver(array('C:\\wamp\\www\\Gestion_Recouvrement\\src\\DbSp\\DbBundle\\Resources\\config\\doctrine' => 'DbSp\\DbBundle\\Entity'));
     $d->setGlobalBasename('mapping');
     $e = new \Doctrine\ORM\Mapping\Driver\DriverChain();
     $e->addDriver($d, 'DbSp\\DbBundle\\Entity');
     $f = new \Doctrine\ORM\Configuration();
     $f->setEntityNamespaces(array('DbSpDbBundle' => 'DbSp\\DbBundle\\Entity'));
     $f->setMetadataCacheImpl($a);
     $f->setQueryCacheImpl($b);
     $f->setResultCacheImpl($c);
     $f->setMetadataDriverImpl($e);
     $f->setProxyDir('C:/wamp/www/Gestion_Recouvrement/app/cache/prod/doctrine/orm/Proxies');
     $f->setProxyNamespace('Proxies');
     $f->setAutoGenerateProxyClasses(false);
     $f->setClassMetadataFactoryName('Doctrine\\ORM\\Mapping\\ClassMetadataFactory');
     $f->setDefaultRepositoryClassName('Doctrine\\ORM\\EntityRepository');
     $f->setNamingStrategy(new \Doctrine\ORM\Mapping\DefaultNamingStrategy());
     $this->services['doctrine.orm.default_entity_manager'] = $instance = call_user_func(array('Doctrine\\ORM\\EntityManager', 'create'), $this->get('doctrine.dbal.default_connection'), $f);
     $this->get('doctrine.orm.default_manager_configurator')->configure($instance);
     return $instance;
 }
コード例 #7
0
 protected function getDoctrine_Orm_DefaultEntityManagerService()
 {
     $a = new \Doctrine\Common\Cache\ArrayCache();
     $a->setNamespace('sf2orm_default_8d769ce4aa22abd637c7b7052818602e040efc33d69a70ac4544342291b37ba8');
     $b = new \Doctrine\Common\Cache\ArrayCache();
     $b->setNamespace('sf2orm_default_8d769ce4aa22abd637c7b7052818602e040efc33d69a70ac4544342291b37ba8');
     $c = new \Doctrine\Common\Cache\ArrayCache();
     $c->setNamespace('sf2orm_default_8d769ce4aa22abd637c7b7052818602e040efc33d69a70ac4544342291b37ba8');
     $d = new \Doctrine\ORM\Mapping\Driver\DriverChain();
     $d->addDriver(new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($this->get('annotation_reader'), array(0 => '/home/iker/symfony2/marca/src/uni/bundle/marcaBundle/Entity')), 'uni\\bundle\\marcaBundle\\Entity');
     $e = new \Doctrine\ORM\Configuration();
     $e->setEntityNamespaces(array('uniMarcaBundle' => 'uni\\bundle\\marcaBundle\\Entity'));
     $e->setMetadataCacheImpl($a);
     $e->setQueryCacheImpl($b);
     $e->setResultCacheImpl($c);
     $e->setMetadataDriverImpl($d);
     $e->setProxyDir('/home/iker/symfony2/marca/app/cache/prod/doctrine/orm/Proxies');
     $e->setProxyNamespace('Proxies');
     $e->setAutoGenerateProxyClasses(false);
     $e->setClassMetadataFactoryName('Doctrine\\ORM\\Mapping\\ClassMetadataFactory');
     $e->setDefaultRepositoryClassName('Doctrine\\ORM\\EntityRepository');
     $e->setNamingStrategy(new \Doctrine\ORM\Mapping\DefaultNamingStrategy());
     $this->services['doctrine.orm.default_entity_manager'] = $instance = \Doctrine\ORM\EntityManager::create($this->get('doctrine.dbal.default_connection'), $e);
     $this->get('doctrine.orm.default_manager_configurator')->configure($instance);
     return $instance;
 }
コード例 #8
0
 protected function getDoctrine_Orm_DefaultEntityManagerService()
 {
     require_once '/var/www/Symfony/app/cache/prod/jms_diextra/doctrine/EntityManager.php';
     $a = new \Doctrine\Common\Cache\ArrayCache();
     $a->setNamespace('sf2orm_default_a92f94852d95a1e374806d6b93dd509c');
     $b = new \Doctrine\Common\Cache\ArrayCache();
     $b->setNamespace('sf2orm_default_a92f94852d95a1e374806d6b93dd509c');
     $c = new \Doctrine\Common\Cache\ArrayCache();
     $c->setNamespace('sf2orm_default_a92f94852d95a1e374806d6b93dd509c');
     $d = new \Doctrine\ORM\Mapping\Driver\DriverChain();
     $d->addDriver(new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($this->get('annotation_reader'), array(0 => '/var/www/Symfony/src/Form/FormBundle/Entity')), 'Form\\FormBundle\\Entity');
     $e = new \Doctrine\ORM\Configuration();
     $e->setEntityNamespaces(array('FormFormBundle' => 'Form\\FormBundle\\Entity'));
     $e->setMetadataCacheImpl($a);
     $e->setQueryCacheImpl($b);
     $e->setResultCacheImpl($c);
     $e->setMetadataDriverImpl($d);
     $e->setProxyDir('/var/www/Symfony/app/cache/prod/doctrine/orm/Proxies');
     $e->setProxyNamespace('Proxies');
     $e->setAutoGenerateProxyClasses(false);
     $e->setClassMetadataFactoryName('Doctrine\\ORM\\Mapping\\ClassMetadataFactory');
     $e->setDefaultRepositoryClassName('Doctrine\\ORM\\EntityRepository');
     $e->setNamingStrategy(new \Doctrine\ORM\Mapping\DefaultNamingStrategy());
     $f = call_user_func(array('Doctrine\\ORM\\EntityManager', 'create'), $this->get('doctrine.dbal.default_connection'), $e);
     $this->get('doctrine.orm.default_manager_configurator')->configure($f);
     return $this->services['doctrine.orm.default_entity_manager'] = new \EM50865219e3628_546a8d27f194334ee012bfe64f629947b07e4919\__CG__\Doctrine\ORM\EntityManager($f, $this);
 }
コード例 #9
0
 public function setUp()
 {
     $reader = new \Doctrine\Common\Annotations\AnnotationReader();
     $driver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader);
     $config = new \Doctrine\ORM\Configuration();
     $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     $config->setQueryCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     $config->setProxyDir(sys_get_temp_dir());
     $config->setProxyNamespace('SimpleThings\\EntityAudit\\Tests\\Proxies');
     $config->setMetadataDriverImpl($driver);
     $conn = array('driver' => $GLOBALS['DOCTRINE_DRIVER'], 'memory' => $GLOBALS['DOCTRINE_MEMORY'], 'dbname' => $GLOBALS['DOCTRINE_DATABASE'], 'user' => $GLOBALS['DOCTRINE_USER'], 'password' => $GLOBALS['DOCTRINE_PASSWORD'], 'host' => $GLOBALS['DOCTRINE_HOST']);
     $auditConfig = new AuditConfiguration();
     $auditConfig->setCurrentUsername("beberlei");
     $auditConfig->setAuditedEntityClasses($this->auditedEntities);
     $auditConfig->setGlobalIgnoreColumns(array('ignoreme'));
     $this->auditManager = new AuditManager($auditConfig);
     $this->auditManager->registerEvents($evm = new EventManager());
     if (php_sapi_name() == 'cli' && isset($_SERVER['argv']) && (in_array('-v', $_SERVER['argv']) || in_array('--verbose', $_SERVER['argv']))) {
         $config->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger());
     }
     $this->em = \Doctrine\ORM\EntityManager::create($conn, $config, $evm);
     $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->em);
     $em = $this->em;
     try {
         $schemaTool->createSchema(array_map(function ($value) use($em) {
             return $em->getClassMetadata($value);
         }, $this->schemaEntities));
     } catch (\Exception $e) {
         if ($GLOBALS['DOCTRINE_DRIVER'] != 'pdo_mysql' || !($e instanceof \PDOException && strpos($e->getMessage(), 'Base table or view already exists') !== false)) {
             throw $e;
         }
     }
 }
コード例 #10
0
ファイル: Repository.php プロジェクト: kj187/LEA
 /**
  * Initialize doctrine
  *
  * @return void
  */
 protected function initializeDoctrine()
 {
     $doctrineConfiguration = new \Doctrine\ORM\Configuration();
     // Proxy configuration
     $doctrineConfiguration->setProxyDir(ROOT . 'Data/Proxies/Doctrine/');
     $doctrineConfiguration->setProxyNamespace('LEA\\Proxies');
     $doctrineConfiguration->setAutoGenerateProxyClasses(APPLICATION_CONTEXT == 'development');
     // Mapping Configuration
     //$driverImpl = new Doctrine\ORM\Mapping\Driver\XmlDriver(__DIR__."/config/mappings/xml");
     //$driverImpl = new Doctrine\ORM\Mapping\Driver\XmlDriver(__DIR__."/config/mappings/yml");
     $driverImpl = $doctrineConfiguration->newDefaultAnnotationDriver(ROOT . 'Application/Domain/Model/');
     $doctrineConfiguration->setMetadataDriverImpl($driverImpl);
     // Caching Configuration
     //if (APPLICATION_CONTEXT == 'development') {
     $cache = new \Doctrine\Common\Cache\ArrayCache();
     //} else {
     //    $cache = new \Doctrine\Common\Cache\ApcCache();
     //}
     $doctrineConfiguration->setMetadataCacheImpl($cache);
     $doctrineConfiguration->setQueryCacheImpl($cache);
     // database configuration parameters
     $conn = array('driver' => $this->configuration['database']['driver'], 'user' => $this->configuration['database']['username'], 'password' => $this->configuration['database']['password'], 'dbname' => $this->configuration['database']['dbname'], 'host' => $this->configuration['database']['host']);
     // obtaining the entity manager
     $evm = new \Doctrine\Common\EventManager();
     $this->entityManager = \Doctrine\ORM\EntityManager::create($conn, $doctrineConfiguration, $evm);
 }
コード例 #11
0
 public function init()
 {
     $bootstrapOptions = $this->getBootstrap()->getOptions();
     $options = $this->getOptions();
     $memcache = null;
     $doctrineConfig = new \Doctrine\ORM\Configuration();
     if (!empty($options['options']['metadataCache'])) {
         $metaCache = new $options['options']['metadataCache']();
         if ($metaCache instanceof \Doctrine\Common\Cache\MemcacheCache) {
             $memcache = new Memcache();
             $memcache->connect('localhost', 11211);
             $metaCache->setMemcache($memcache);
         }
         $doctrineConfig->setMetadataCacheImpl($metaCache);
     }
     if (!empty($options['options']['queryCache'])) {
         $queryCache = new $options['options']['queryCache']();
         if ($queryCache instanceof \Doctrine\Common\Cache\MemcacheCache) {
             if (is_null($memcache)) {
                 $memcache = new Memcache();
                 $memcache->connect('localhost', 11211);
             }
             $queryCache->setMemcache($memcache);
         }
         $doctrineConfig->setQueryCacheImpl($queryCache);
     }
     $driverImpl = $doctrineConfig->newDefaultAnnotationDriver(array($options['paths']['entities']));
     $doctrineConfig->setMetadataDriverImpl($driverImpl);
     //$doctrineConfig->setEntityNamespaces(
     //    $options['entitiesNamespaces']);
     $doctrineConfig->setProxyDir($options['paths']['proxies']);
     $doctrineConfig->setProxyNamespace($options['options']['proxiesNamespace']);
     $this->getBootstrap()->em = \Doctrine\ORM\EntityManager::create($options['connections']['doctrine'], $doctrineConfig);
     return $this->getBootstrap()->em;
 }
コード例 #12
0
 protected function getDoctrine_Orm_DefaultEntityManagerService()
 {
     $a = new \Doctrine\Common\Cache\ArrayCache();
     $a->setNamespace('sf2orm_default_34fb07f8c5c30a0161dab82f751c8632e441929962e443e4f0acfa325886b164');
     $b = new \Doctrine\Common\Cache\ArrayCache();
     $b->setNamespace('sf2orm_default_34fb07f8c5c30a0161dab82f751c8632e441929962e443e4f0acfa325886b164');
     $c = new \Doctrine\Common\Cache\ArrayCache();
     $c->setNamespace('sf2orm_default_34fb07f8c5c30a0161dab82f751c8632e441929962e443e4f0acfa325886b164');
     $d = new \Doctrine\ORM\Mapping\Driver\DriverChain();
     $d->addDriver(new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($this->get('annotation_reader'), array(0 => '/home/itziar/web/synfony2/recetas/src/uni/bundle/recetasBundle/Entity')), 'uni\\bundle\\recetasBundle\\Entity');
     $e = new \Doctrine\ORM\Configuration();
     $e->setEntityNamespaces(array('uniRecetasBundle' => 'uni\\bundle\\recetasBundle\\Entity'));
     $e->setMetadataCacheImpl($a);
     $e->setQueryCacheImpl($b);
     $e->setResultCacheImpl($c);
     $e->setMetadataDriverImpl($d);
     $e->setProxyDir('/home/itziar/web/synfony2/recetas/app/cache/prod/doctrine/orm/Proxies');
     $e->setProxyNamespace('Proxies');
     $e->setAutoGenerateProxyClasses(false);
     $e->setClassMetadataFactoryName('Doctrine\\ORM\\Mapping\\ClassMetadataFactory');
     $e->setDefaultRepositoryClassName('Doctrine\\ORM\\EntityRepository');
     $e->setNamingStrategy(new \Doctrine\ORM\Mapping\DefaultNamingStrategy());
     $this->services['doctrine.orm.default_entity_manager'] = $instance = \Doctrine\ORM\EntityManager::create($this->get('doctrine.dbal.default_connection'), $e);
     $this->get('doctrine.orm.default_manager_configurator')->configure($instance);
     return $instance;
 }
コード例 #13
0
 protected function getDoctrine_Orm_DefaultEntityManagerService()
 {
     $a = new \Doctrine\Common\Cache\ArrayCache();
     $a->setNamespace('sf2orm_default_212f582878cf7474c20ecc1bd0f75efb89c7ef7c7a33110da091960837c6c845');
     $b = new \Doctrine\Common\Cache\ArrayCache();
     $b->setNamespace('sf2orm_default_212f582878cf7474c20ecc1bd0f75efb89c7ef7c7a33110da091960837c6c845');
     $c = new \Doctrine\Common\Cache\ArrayCache();
     $c->setNamespace('sf2orm_default_212f582878cf7474c20ecc1bd0f75efb89c7ef7c7a33110da091960837c6c845');
     $d = new \Doctrine\ORM\Mapping\Driver\DriverChain();
     $d->addDriver(new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($this->get('annotation_reader'), array(0 => '/home/andoni/symfony2/Marca/src/Uni/Bundle/MarcaBundle/Entity')), 'Uni\\Bundle\\MarcaBundle\\Entity');
     $e = new \Doctrine\ORM\Configuration();
     $e->setEntityNamespaces(array('uniMarcaBundle' => 'Uni\\Bundle\\MarcaBundle\\Entity'));
     $e->setMetadataCacheImpl($a);
     $e->setQueryCacheImpl($b);
     $e->setResultCacheImpl($c);
     $e->setMetadataDriverImpl($d);
     $e->setProxyDir('/home/andoni/symfony2/Marca/app/cache/prod/doctrine/orm/Proxies');
     $e->setProxyNamespace('Proxies');
     $e->setAutoGenerateProxyClasses(false);
     $e->setClassMetadataFactoryName('Doctrine\\ORM\\Mapping\\ClassMetadataFactory');
     $e->setDefaultRepositoryClassName('Doctrine\\ORM\\EntityRepository');
     $e->setNamingStrategy(new \Doctrine\ORM\Mapping\DefaultNamingStrategy());
     $this->services['doctrine.orm.default_entity_manager'] = $instance = \Doctrine\ORM\EntityManager::create($this->get('doctrine.dbal.default_connection'), $e);
     $this->get('doctrine.orm.default_manager_configurator')->configure($instance);
     return $instance;
 }
コード例 #14
0
 protected function getDoctrine_Orm_DefaultEntityManagerService()
 {
     $a = new \Doctrine\Common\Cache\ArrayCache();
     $a->setNamespace('sf2orm_default_d8b0087a585fd8d1a917703a03663dadd0fbb62170bcdd10b61d3f5a3b162bd9');
     $b = new \Doctrine\Common\Cache\ArrayCache();
     $b->setNamespace('sf2orm_default_d8b0087a585fd8d1a917703a03663dadd0fbb62170bcdd10b61d3f5a3b162bd9');
     $c = new \Doctrine\Common\Cache\ArrayCache();
     $c->setNamespace('sf2orm_default_d8b0087a585fd8d1a917703a03663dadd0fbb62170bcdd10b61d3f5a3b162bd9');
     $d = new \Doctrine\ORM\Mapping\Driver\DriverChain();
     $d->addDriver(new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($this->get('annotation_reader'), array(0 => '/home/ivan/symfony2/juegos/src/uniJuegos/Bundle/Entity')), 'uniJuegos\\Bundle\\Entity');
     $e = new \Doctrine\ORM\Configuration();
     $e->setEntityNamespaces(array('uniJuegosBundle' => 'uniJuegos\\Bundle\\Entity'));
     $e->setMetadataCacheImpl($a);
     $e->setQueryCacheImpl($b);
     $e->setResultCacheImpl($c);
     $e->setMetadataDriverImpl($d);
     $e->setProxyDir('/home/ivan/symfony2/juegos/app/cache/prod/doctrine/orm/Proxies');
     $e->setProxyNamespace('Proxies');
     $e->setAutoGenerateProxyClasses(false);
     $e->setClassMetadataFactoryName('Doctrine\\ORM\\Mapping\\ClassMetadataFactory');
     $e->setDefaultRepositoryClassName('Doctrine\\ORM\\EntityRepository');
     $e->setNamingStrategy(new \Doctrine\ORM\Mapping\DefaultNamingStrategy());
     $this->services['doctrine.orm.default_entity_manager'] = $instance = \Doctrine\ORM\EntityManager::create($this->get('doctrine.dbal.default_connection'), $e);
     $this->get('doctrine.orm.default_manager_configurator')->configure($instance);
     return $instance;
 }
コード例 #15
0
 public function setUp()
 {
     $config = new \Doctrine\ORM\Configuration();
     $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     $config->setQueryCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     $config->setProxyDir(__DIR__ . '/_files');
     $config->setProxyNamespace('DoctrineExtensions\\LargeCollections\\Proxies');
     $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver());
     $conn = array('driver' => 'pdo_sqlite', 'memory' => true);
     #$config->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger());
     $this->em = \Doctrine\ORM\EntityManager::create($conn, $config);
     $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->em);
     $schemaTool->createSchema(array($this->em->getClassMetadata('DoctrineExtensions\\LargeCollections\\Article'), $this->em->getClassMetadata('DoctrineExtensions\\LargeCollections\\Tag'), $this->em->getClassMetadata('DoctrineExtensions\\LargeCollections\\Comment')));
     $article = new Article();
     $tag1 = new Tag();
     $tag2 = new Tag();
     $comment1 = new Comment();
     $comment2 = new Comment();
     $article->addComment($comment1);
     $article->addComment($comment2);
     $article->addTag($tag1);
     $article->addTag($tag2);
     $this->em->persist($article);
     $this->em->persist($tag1);
     $this->em->persist($tag2);
     $this->em->persist($comment1);
     $this->em->persist($comment2);
     $this->em->flush();
     $this->articleId = $article->id();
     $this->em->clear();
 }
コード例 #16
0
 /**
  * {@inheritdoc}
  */
 public function register(\Silex\Application $app)
 {
     $app['annotation.reader.internal'] = $app->share(function () use($app) {
         return new \Doctrine\Common\Annotations\AnnotationReader();
     });
     $app['annotation.reader'] = $app->share(function () use($app) {
         return new \Doctrine\Common\Annotations\CachedReader($app['annotation.reader.internal'], $app['app.cache']);
     });
     $app['orm.config.annotation.driver'] = $app->share(function () use($app) {
         return new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($app['annotation.reader'], array(__DIR__ . '/Organizations'));
     });
     $app['orm.config'] = $app->share(function () use($app) {
         $config = new \Doctrine\ORM\Configuration();
         $config->setMetadataCacheImpl($app['app.cache']);
         $config->setResultCacheImpl($app['app.cache']);
         $config->setQueryCacheImpl($app['app.cache']);
         $config->setProxyDir($app['db.orm.proxies_dir']);
         $config->setProxyNamespace($app['db.orm.proxies_namespace']);
         $config->setAutoGenerateProxyClasses($app['db.orm.auto_generate_proxies']);
         $config->setMetadataDriverImpl($app['orm.config.annotation.driver']);
         return $config;
     });
     $app['orm.em'] = $app->share(function () use($app) {
         return \Doctrine\ORM\EntityManager::create($app['db'], $app['orm.config'], $app['db.event_manager']);
     });
 }
コード例 #17
0
 protected function getDoctrine_Orm_DefaultEntityManagerService()
 {
     $a = new \Doctrine\Common\Cache\ArrayCache();
     $a->setNamespace('sf2orm_default_a10d301149e084ecdc488926bd33b00804ee0e5e92d7232190c350bbe261b941');
     $b = new \Doctrine\Common\Cache\ArrayCache();
     $b->setNamespace('sf2orm_default_a10d301149e084ecdc488926bd33b00804ee0e5e92d7232190c350bbe261b941');
     $c = new \Doctrine\Common\Cache\ArrayCache();
     $c->setNamespace('sf2orm_default_a10d301149e084ecdc488926bd33b00804ee0e5e92d7232190c350bbe261b941');
     $d = new \Doctrine\ORM\Mapping\Driver\SimplifiedXmlDriver(array('/var/www/html/LetsVolunteer/src/Ridwan/EntityBundle/Resources/config/doctrine' => 'Ridwan\\EntityBundle\\Entity', '/var/www/html/LetsVolunteer/vendor/friendsofsymfony/user-bundle/FOS/UserBundle/Resources/config/doctrine' => 'FOS\\UserBundle\\Entity'));
     $d->setGlobalBasename('mapping');
     $e = new \Doctrine\ORM\Mapping\Driver\DriverChain();
     $e->addDriver($d, 'Ridwan\\EntityBundle\\Entity');
     $e->addDriver($d, 'FOS\\UserBundle\\Entity');
     $f = new \Doctrine\ORM\Configuration();
     $f->setEntityNamespaces(array('RidwanEntityBundle' => 'Ridwan\\EntityBundle\\Entity', 'FOSUserBundle' => 'FOS\\UserBundle\\Entity'));
     $f->setMetadataCacheImpl($a);
     $f->setQueryCacheImpl($b);
     $f->setResultCacheImpl($c);
     $f->setMetadataDriverImpl($e);
     $f->setProxyDir('/var/www/html/LetsVolunteer/app/cache/prod/doctrine/orm/Proxies');
     $f->setProxyNamespace('Proxies');
     $f->setAutoGenerateProxyClasses(false);
     $f->setClassMetadataFactoryName('Doctrine\\ORM\\Mapping\\ClassMetadataFactory');
     $f->setDefaultRepositoryClassName('Doctrine\\ORM\\EntityRepository');
     $f->setNamingStrategy(new \Doctrine\ORM\Mapping\DefaultNamingStrategy());
     $this->services['doctrine.orm.default_entity_manager'] = $instance = \Doctrine\ORM\EntityManager::create($this->get('doctrine.dbal.default_connection'), $f);
     $this->get('doctrine.orm.default_manager_configurator')->configure($instance);
     return $instance;
 }
コード例 #18
0
ファイル: bootstrap.php プロジェクト: V3N0m21/Uppu4
function createDoctrineConfig($cache, $cachedAnnotationReader)
{
    AnnotationRegistry::registerFile(dirname(__DIR__) . "/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php");
    //$cache = new Doctrine\Common\Cache\ArrayCache;
    //    if (extension_loaded('apc')) {
    //        $cache = new \Doctrine\Common\Cache\ApcCache();
    //    } else {
    //        $cache = new \Doctrine\Common\Cache\PhpFileCache();
    //    }
    $isDevMode = true;
    //    $annotationReader = new AnnotationReader;
    //    $cachedAnnotationReader = new Doctrine\Common\Annotations\CachedReader(
    //        $annotationReader, // use reader
    //        $cache // and a cache driver
    //    );
    $annotationDriver = new Doctrine\ORM\Mapping\Driver\AnnotationDriver($cachedAnnotationReader, array(__DIR__ . '/Resource'));
    $driverChain = new Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain();
    Gedmo\DoctrineExtensions::registerAbstractMappingIntoDriverChainORM($driverChain, $cachedAnnotationReader);
    $driverChain->addDriver($annotationDriver, 'Uppu4\\Entity');
    $config = Setup::createAnnotationMetadataConfiguration(array(__DIR__ . "/Resource"), $isDevMode);
    //!!!!!!
    $config = new Doctrine\ORM\Configuration();
    $config->setProxyDir(sys_get_temp_dir());
    $config->setProxyNamespace('Proxy');
    $config->setAutoGenerateProxyClasses(true);
    // this can be based on production config.
    // register metadata driver
    $config->setMetadataDriverImpl($driverChain);
    // use our already initialized cache driver
    $config->setMetadataCacheImpl($cache);
    $config->setQueryCacheImpl($cache);
    $deleted = $cache->deleteAll();
    return $config;
}
コード例 #19
0
ファイル: Bootstrap.php プロジェクト: manish436/zform
 /**
  * Initialize Doctrine
  * @return Doctrine_Manager
  */
 public function _initDoctrine()
 {
     // include and register Doctrine's class loader
     require_once 'Doctrine/Common/ClassLoader.php';
     $classLoader = new \Doctrine\Common\ClassLoader('Doctrine', APPLICATION_PATH . '/../library/');
     $classLoader->register();
     // create the Doctrine configuration
     $config = new \Doctrine\ORM\Configuration();
     // setting the cache ( to ArrayCache. Take a look at
     // the Doctrine manual for different options ! )
     $cache = new \Doctrine\Common\Cache\ArrayCache();
     $config->setMetadataCacheImpl($cache);
     $config->setQueryCacheImpl($cache);
     // choosing the driver for our database schema
     // we'll use annotations
     $driver = $config->newDefaultAnnotationDriver(APPLICATION_PATH . '/models');
     $config->setMetadataDriverImpl($driver);
     // set the proxy dir and set some options
     $config->setProxyDir(APPLICATION_PATH . '/models/Proxies');
     $config->setAutoGenerateProxyClasses(true);
     $config->setProxyNamespace('App\\Proxies');
     // now create the entity manager and use the connection
     // settings we defined in our application.ini
     $connectionSettings = $this->getOption('doctrine');
     $conn = array('driver' => $connectionSettings['conn']['driv'], 'user' => $connectionSettings['conn']['user'], 'password' => $connectionSettings['conn']['pass'], 'dbname' => $connectionSettings['conn']['dbname'], 'host' => $connectionSettings['conn']['host']);
     $entityManager = \Doctrine\ORM\EntityManager::create($conn, $config);
     // push the entity manager into our registry for later use
     $registry = Zend_Registry::getInstance();
     $registry->entitymanager = $entityManager;
     return $entityManager;
 }
コード例 #20
0
ファイル: EntityManagerFactory.php プロジェクト: nxpthx/FLOW3
 /**
  * Factory method which creates an EntityManager.
  *
  * @return \Doctrine\ORM\EntityManager
  */
 public function create()
 {
     $config = new \Doctrine\ORM\Configuration();
     $config->setClassMetadataFactoryName('TYPO3\\FLOW3\\Persistence\\Doctrine\\Mapping\\ClassMetadataFactory');
     if (class_exists($this->settings['doctrine']['cacheImplementation'])) {
         // safeguard against apc being disabled in CLI...
         if ($this->settings['doctrine']['cacheImplementation'] !== 'Doctrine\\Common\\Cache\\ApcCache' || function_exists('apc_fetch')) {
             $cache = new $this->settings['doctrine']['cacheImplementation']();
             $config->setMetadataCacheImpl($cache);
             $config->setQueryCacheImpl($cache);
         }
     }
     if (class_exists($this->settings['doctrine']['sqlLogger'])) {
         $config->setSQLLogger(new $this->settings['doctrine']['sqlLogger']());
     }
     // must use ObjectManager in compile phase...
     $flow3AnnotationDriver = $this->objectManager->get('TYPO3\\FLOW3\\Persistence\\Doctrine\\Mapping\\Driver\\Flow3AnnotationDriver');
     $config->setMetadataDriverImpl($flow3AnnotationDriver);
     $proxyDirectory = \TYPO3\FLOW3\Utility\Files::concatenatePaths(array($this->environment->getPathToTemporaryDirectory(), 'Doctrine/Proxies'));
     \TYPO3\FLOW3\Utility\Files::createDirectoryRecursively($proxyDirectory);
     $config->setProxyDir($proxyDirectory);
     $config->setProxyNamespace('TYPO3\\FLOW3\\Persistence\\Doctrine\\Proxies');
     $config->setAutoGenerateProxyClasses(FALSE);
     $entityManager = \Doctrine\ORM\EntityManager::create($this->settings['backendOptions'], $config);
     $flow3AnnotationDriver->setEntityManager($entityManager);
     return $entityManager;
 }
コード例 #21
0
 protected function getDoctrine_Orm_DefaultEntityManagerService()
 {
     $a = new \Doctrine\Common\Cache\ArrayCache();
     $a->setNamespace('sf2orm_default_009ddab573918805ac10dd8e02df21ad9f522de9b39f898aae553f354da1859d');
     $b = new \Doctrine\Common\Cache\ArrayCache();
     $b->setNamespace('sf2orm_default_009ddab573918805ac10dd8e02df21ad9f522de9b39f898aae553f354da1859d');
     $c = new \Doctrine\Common\Cache\ArrayCache();
     $c->setNamespace('sf2orm_default_009ddab573918805ac10dd8e02df21ad9f522de9b39f898aae553f354da1859d');
     $d = new \Doctrine\ORM\Mapping\Driver\DriverChain();
     $d->addDriver(new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($this->get('annotation_reader'), array(0 => '/home/haritz/symfony2/marca/src/uni/bundle/marcaBundle/Entity')), 'uni\\bundle\\marcaBundle\\Entity');
     $e = new \Doctrine\ORM\Configuration();
     $e->setEntityNamespaces(array('uniMarcaBundle' => 'uni\\bundle\\marcaBundle\\Entity'));
     $e->setMetadataCacheImpl($a);
     $e->setQueryCacheImpl($b);
     $e->setResultCacheImpl($c);
     $e->setMetadataDriverImpl($d);
     $e->setProxyDir('/home/haritz/symfony2/marca/app/cache/prod/doctrine/orm/Proxies');
     $e->setProxyNamespace('Proxies');
     $e->setAutoGenerateProxyClasses(false);
     $e->setClassMetadataFactoryName('Doctrine\\ORM\\Mapping\\ClassMetadataFactory');
     $e->setDefaultRepositoryClassName('Doctrine\\ORM\\EntityRepository');
     $e->setNamingStrategy(new \Doctrine\ORM\Mapping\DefaultNamingStrategy());
     $this->services['doctrine.orm.default_entity_manager'] = $instance = \Doctrine\ORM\EntityManager::create($this->get('doctrine.dbal.default_connection'), $e);
     $this->get('doctrine.orm.default_manager_configurator')->configure($instance);
     return $instance;
 }
コード例 #22
0
 public static function _init_manager($connection)
 {
     $settings = static::connection_settings($connection);
     $config = new \Doctrine\ORM\Configuration();
     $cache = static::_init_cache($settings);
     if ($cache) {
         $config->setMetadataCacheImpl($cache);
         $config->setQueryCacheImpl($cache);
         $config->setResultCacheImpl($cache);
     }
     $config->setProxyDir($settings['proxy_dir']);
     $config->setProxyNamespace($settings['proxy_namespace']);
     $config->setAutoGenerateProxyClasses(\Arr::get($settings, 'auto_generate_proxy_classes', false));
     $config->setMetadataDriverImpl(static::_init_metadata($config, $settings));
     $EventManager = new \Doctrine\Common\EventManager();
     static::$_managers[$connection] = \Doctrine\ORM\EntityManager::create($settings['connection'], $config, $EventManager);
     if (!empty($settings['profiling'])) {
         static::$_managers[$connection]->getConnection()->getConfiguration()->setSQLLogger(new Doctrine\Logger($connection));
     }
     // Connection init callback
     if (!empty($settings['init_callback'])) {
         // If array merge combined this numeric array, grab last two array elements as the real callback
         if (is_array($settings['init_callback']) && count($settings['init_callback']) > 2) {
             $settings['init_callback'] = array_slice($settings['init_callback'], -2);
         }
         call_user_func($settings['init_callback'], static::$_managers[$connection], $connection);
     }
 }
コード例 #23
0
 protected function getDoctrine_Orm_DefaultEntityManagerService()
 {
     $a = new \Doctrine\Common\Cache\ArrayCache();
     $a->setNamespace('sf2orm_default_9d968dc3678c378fa217a1250471e79fb7e4263cf64827a5f1c8cd74fdb740d9');
     $b = new \Doctrine\Common\Cache\ArrayCache();
     $b->setNamespace('sf2orm_default_9d968dc3678c378fa217a1250471e79fb7e4263cf64827a5f1c8cd74fdb740d9');
     $c = new \Doctrine\Common\Cache\ArrayCache();
     $c->setNamespace('sf2orm_default_9d968dc3678c378fa217a1250471e79fb7e4263cf64827a5f1c8cd74fdb740d9');
     $d = new \Doctrine\ORM\Mapping\Driver\DriverChain();
     $d->addDriver(new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($this->get('annotation_reader'), array(0 => '/home/itziar/web/synfony2/itziar-superheroes/src/uni/bundle/superhBundle/Entity')), 'uni\\bundle\\superhBundle\\Entity');
     $e = new \Doctrine\ORM\Configuration();
     $e->setEntityNamespaces(array('uniSuperhBundle' => 'uni\\bundle\\superhBundle\\Entity'));
     $e->setMetadataCacheImpl($a);
     $e->setQueryCacheImpl($b);
     $e->setResultCacheImpl($c);
     $e->setMetadataDriverImpl($d);
     $e->setProxyDir('/home/itziar/web/synfony2/itziar-superheroes/app/cache/prod/doctrine/orm/Proxies');
     $e->setProxyNamespace('Proxies');
     $e->setAutoGenerateProxyClasses(false);
     $e->setClassMetadataFactoryName('Doctrine\\ORM\\Mapping\\ClassMetadataFactory');
     $e->setDefaultRepositoryClassName('Doctrine\\ORM\\EntityRepository');
     $e->setNamingStrategy(new \Doctrine\ORM\Mapping\DefaultNamingStrategy());
     $this->services['doctrine.orm.default_entity_manager'] = $instance = \Doctrine\ORM\EntityManager::create($this->get('doctrine.dbal.default_connection'), $e);
     $this->get('doctrine.orm.default_manager_configurator')->configure($instance);
     return $instance;
 }
コード例 #24
0
 protected function getDoctrine_Orm_DefaultEntityManagerService()
 {
     require_once '/opt/lampp/htdocs/symfony2/symfony/app/cache/prod/jms_diextra/doctrine/EntityManager_509982243f179.php';
     $a = new \Doctrine\Common\Cache\ArrayCache();
     $a->setNamespace('sf2orm_default_3f1b97459909d5be8f95fdd1560f907a');
     $b = new \Doctrine\Common\Cache\ArrayCache();
     $b->setNamespace('sf2orm_default_3f1b97459909d5be8f95fdd1560f907a');
     $c = new \Doctrine\Common\Cache\ArrayCache();
     $c->setNamespace('sf2orm_default_3f1b97459909d5be8f95fdd1560f907a');
     $d = new \Doctrine\ORM\Configuration();
     $d->setEntityNamespaces(array());
     $d->setMetadataCacheImpl($a);
     $d->setQueryCacheImpl($b);
     $d->setResultCacheImpl($c);
     $d->setMetadataDriverImpl(new \Doctrine\ORM\Mapping\Driver\DriverChain());
     $d->setProxyDir('/opt/lampp/htdocs/symfony2/symfony/app/cache/prod/doctrine/orm/Proxies');
     $d->setProxyNamespace('Proxies');
     $d->setAutoGenerateProxyClasses(false);
     $d->setClassMetadataFactoryName('Doctrine\\ORM\\Mapping\\ClassMetadataFactory');
     $d->setDefaultRepositoryClassName('Doctrine\\ORM\\EntityRepository');
     $d->setNamingStrategy(new \Doctrine\ORM\Mapping\DefaultNamingStrategy());
     $e = call_user_func(array('Doctrine\\ORM\\EntityManager', 'create'), $this->get('doctrine.dbal.default_connection'), $d);
     $this->get('doctrine.orm.default_manager_configurator')->configure($e);
     return $this->services['doctrine.orm.default_entity_manager'] = new \EntityManager509982243f179_546a8d27f194334ee012bfe64f629947b07e4919\__CG__\Doctrine\ORM\EntityManager($e, $this);
 }
コード例 #25
0
ファイル: Doctrine.php プロジェクト: Lavoaster/PVLive
 protected static function getEntityManager($options)
 {
     $config = new \Doctrine\ORM\Configuration();
     // Handling for class names specified as platform types.
     if ($options['conn']['platform']) {
         $class_obj = new \ReflectionClass($options['conn']['platform']);
         $options['conn']['platform'] = $class_obj->newInstance();
     }
     // Special handling for the utf8mb4 type.
     if ($options['conn']['driver'] == 'pdo_mysql' && $options['conn']['charset'] == 'utf8mb4') {
         $options['conn']['platform'] = new \DF\Doctrine\Platform\MysqlUnicode();
     }
     $metadata_driver = $config->newDefaultAnnotationDriver($options['modelPath']);
     $config->setMetadataDriverImpl($metadata_driver);
     $cache = new \DF\Doctrine\Cache();
     // $cache->setNamespace('doctrine_');
     $config->setMetadataCacheImpl($cache);
     $config->setQueryCacheImpl($cache);
     $config->setResultCacheImpl($cache);
     $config->setProxyDir($options['proxyPath']);
     $config->setProxyNamespace($options['proxyNamespace']);
     if (isset($options['conn']['debug']) && $options['conn']['debug']) {
         $config->setSQLLogger(new \DF\Doctrine\Logger\EchoSQL());
     }
     $config->addFilter('softdelete', '\\DF\\Doctrine\\Filter\\SoftDelete');
     $config->addCustomNumericFunction('RAND', '\\DF\\Doctrine\\Functions\\Rand');
     $evm = new \Doctrine\Common\EventManager();
     $em = \Doctrine\ORM\EntityManager::create($options['conn'], $config, $evm);
     $em->getFilters()->enable("softdelete");
     // Try the connection before rendering the page.
     $em->getConnection()->connect();
     return $em;
 }
コード例 #26
0
 private function configure()
 {
     $connectionParams = $this->getDbConfigs();
     $config = new \Doctrine\ORM\Configuration();
     $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver($this->entityFolder));
     $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     $config->setProxyDir($this->entityFolder . DIRECTORY_SEPARATOR . 'proxies');
     $config->setProxyNamespace('Proxies');
     $this->em = \Doctrine\ORM\EntityManager::create($connectionParams, $config);
 }
コード例 #27
0
 public function setUp()
 {
     $config = new \Doctrine\ORM\Configuration();
     $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     $config->setQueryCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     $config->setProxyDir(__DIR__ . '/_files');
     $config->setProxyNamespace('DoctrineExtensions\\Paginate\\Proxies');
     $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver());
     $conn = array('driver' => 'pdo_sqlite', 'memory' => true);
     $this->entityManager = \Doctrine\ORM\EntityManager::create($conn, $config);
 }
コード例 #28
0
 public function initialize($parameters = array())
 {
     parent::initialize($parameters);
     $schema = $this->getParameter('schema');
     $connectionName = $this->getParameter('name');
     $connectionOptions = $this->getParameter('options');
     $plugins = (array) $this->getParameter('plugins');
     $config = new \Doctrine\ORM\Configuration();
     $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     $configuration = sfProjectConfiguration::getActive();
     $paths = array();
     if ($schema) {
         $paths[] = $schema;
     }
     $paths[] = realpath(__DIR__ . '/../config/doctrine');
     $paths[] = realpath(sfConfig::get('sf_config_dir') . '/doctrine');
     $enabledPlugins = $configuration->getPlugins();
     foreach ($configuration->getAllPluginPaths() as $plugin => $path) {
         if (!in_array($plugin, $enabledPlugins) || !in_array($plugin, $plugins)) {
             continue;
         }
         $paths[] = $path . '/config/doctrine';
     }
     $paths = array_unique($paths);
     $config->setMetadataDriverImpl(new YamlDriver($paths));
     $config->setProxyDir(sfConfig::get('sf_lib_dir') . '/Proxies');
     $config->setProxyNamespace('Proxies');
     $configuration = sfProjectConfiguration::getActive();
     if (sfConfig::get('sf_debug')) {
         $config->setSqlLogger(new sfDoctrineSqlLogger($configuration->getEventDispatcher()));
     }
     $method = sprintf('configureDoctrineConnection%s', $connectionName);
     $methodExists = method_exists($configuration, $method);
     if (method_exists($configuration, 'configureDoctrineConnection') && !$methodExists) {
         $configuration->configureDoctrineConnection($config);
     } else {
         if ($methodExists) {
             $configuration->{$method}($config);
         }
     }
     $this->em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);
     if (method_exists($configuration, 'configureEntityManager')) {
         $configuration->configureEntityManager($this->em);
     }
     ActiveEntity::setEntityManager($this->em);
     // ODM MongoDB
     $config = new Doctrine\ODM\MongoDB\Configuration();
     $config->setProxyDir(sfConfig::get('sf_lib_dir') . '/Proxies');
     $config->setProxyNamespace('Proxies');
     $reader = new Doctrine\Common\Annotations\AnnotationReader();
     $reader->setDefaultAnnotationNamespace('Doctrine\\ODM\\MongoDB\\Mapping\\');
     $config->setMetadataDriverImpl(new Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver($reader, sfConfig::get('sf_lib_dir') . DIRECTORY_SEPARATOR . 'Documents'));
     $this->dm = Doctrine\ODM\MongoDB\DocumentManager::create(new \Doctrine\ODM\MongoDB\Mongo(), $config);
 }
コード例 #29
0
ファイル: OrmTestCase.php プロジェクト: jackbravo/doctrine
 /**
  * Creates an EntityManager for testing purposes.
  * 
  * NOTE: The created EntityManager will have its dependant DBAL parts completely
  * mocked out using a DriverMock, ConnectionMock, etc. These mocks can then
  * be configured in the tests to simulate the DBAL behavior that is desired
  * for a particular test,
  *
  * @return Doctrine\ORM\EntityManager
  */
 protected function _getTestEntityManager($conn = null, $conf = null, $eventManager = null)
 {
     $config = new \Doctrine\ORM\Configuration();
     $config->setMetadataCacheImpl(self::getSharedMetadataCacheImpl());
     $config->setQueryCacheImpl(self::getSharedQueryCacheImpl());
     $eventManager = new \Doctrine\Common\EventManager();
     if ($conn === null) {
         $conn = array('driverClass' => 'Doctrine\\Tests\\Mocks\\DriverMock', 'wrapperClass' => 'Doctrine\\Tests\\Mocks\\ConnectionMock', 'user' => 'john', 'password' => 'wayne');
     }
     return \Doctrine\ORM\EntityManager::create($conn, $config, $eventManager);
 }
コード例 #30
0
ファイル: TestCase.php プロジェクト: netixpro/symfony
 /**
  * @return EntityManager
  */
 protected function createTestEntityManager()
 {
     $config = new \Doctrine\ORM\Configuration();
     $config->setAutoGenerateProxyClasses(true);
     $config->setProxyDir(\sys_get_temp_dir());
     $config->setProxyNamespace('SymfonyTests\\Doctrine');
     $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver());
     $config->setQueryCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
     $params = array('driver' => 'pdo_sqlite', 'memory' => true);
     return EntityManager::create($params, $config);
 }