/** * Get cache. * * @return Cache */ public function getCache() { if (null === $this->cache) { $directory = $this->config->getCacheDirectory(); if (null === $directory) { $this->cache = new ArrayCache(); return $this->cache; } $this->cache = new FilesystemCache($directory); } return $this->cache; }
/** * Test that the expected custom values are returned. */ public function testCustomConfigValues() { $config = new Config(); $config->setDatabaseFilePath('/path/to/database.file'); $config->setCacheDirectory('/cache/directory'); $config->setLogFilePath('/path/to/log.file'); $config->setProcessTimeout(Config::DEFAULT_PROCESS_TIMEOUT + 10); $this->assertSame('/path/to/database.file', $config->getDatabaseFilePath()); $this->assertSame('/cache/directory', $config->getCacheDirectory()); $this->assertSame('/path/to/log.file', $config->getLogFilePath()); $this->assertSame(Config::DEFAULT_PROCESS_TIMEOUT + 10, $config->getProcessTimeout()); }
/** * Get entity manager config. * * @return EntityManagerConfig */ public function getEntityManagerConfig() { if (null === $this->entityManagerConfig) { $cacheDirectory = $this->config->getCacheDirectory(); if (null === $cacheDirectory) { $cacheDirectory = sys_get_temp_dir(); } $config = new EntityManagerConfig(); $config->setAutoGenerateProxyClasses(true); $config->setProxyDir(rtrim($cacheDirectory, '/') . '/proxy'); $config->setProxyNamespace(Commander::ENTITY_NAMESPACE); $config->setMetadataDriverImpl($this->mappingDriver); $config->setMetadataCacheImpl($this->cache); $config->setQueryCacheImpl($this->cache); $config->setResultCacheImpl($this->cache); $config->setHydrationCacheImpl($this->cache); $this->entityManagerConfig = $config; } return $this->entityManagerConfig; }