public static function bootstrapAutoloading() { if (!self::$bootstrapped) { self::$bootstrapped = true; require_once __DIR__ . '/../vendor/doctrine-orm/lib/Doctrine/ORM/Tools/Setup.php'; \Doctrine\ORM\Tools\Setup::registerAutoloadGit(__DIR__ . '/../vendor/doctrine-orm/'); \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(__DIR__ . "/../vendor/doctrine-orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php"); } }
/** * Get the Doctrine EntityManager * * @return \Doctrine\ORM\EntityManager */ public function getEntityManager() { if ($this->entityManager !== null) { return $this->entityManager; } Tx_Doctrine2_ExtbaseBootstrap::bootstrapAutoloading(); // Dev Mode decides if proxies are auto-generated every request // and what kind of cache is used for the metadata. $isDevMode = self::getDevMode(); $config = new \Doctrine\ORM\Configuration(); if ($isDevMode) { $config->setAutoGenerateProxyClasses(true); } $config->setProxyDir(PATH_site . 'typo3temp/doctrine2'); $config->setProxyNamespace('TxDoctrine2Proxies'); $cache = $this->createCache($isDevMode); $config->setMetadataCacheImpl($cache); $config->setQueryCacheImpl($cache); $paths = $this->getEntityDirectories(); $driverImpl = $config->newDefaultAnnotationDriver($paths); $config->setMetadataDriverImpl($driverImpl); $config->addFilter('enableFields', 'Tx_Doctrine2_Persistence_EnableFieldsFilter'); if (!\Doctrine\DBAL\Types\Type::hasType('timestamp')) { \Doctrine\DBAL\Types\Type::addType('timestamp', 'Tx_Doctrine2_Types_TimestampType'); } $dbParams = $this->getDatabaseParams(); $evm = $this->createEventManager(); $this->entityManager = \Doctrine\ORM\EntityManager::create($dbParams, $config, $evm); $this->entityManager->getFilters('enableFields')->enable('enableFields'); if ($this->objectManager instanceof Tx_Doctrine2_ObjectManager) { $this->objectManager->setEntityManager($this->entityManager); } return $this->entityManager; }