public function testSet() { $this->assertEquals('newValue', $this->config->set('blah', 'newValue')->get('blah')); $this->assertEquals('newValue', $this->config->set('newkey', 'newValue')->get('newkey')); $this->assertEquals('newValue', $this->config->get('newkey')); $this->assertEquals('newValue', $this->config->set('newkey.deep', 'newValue')->get('newkey.deep')); }
/** * @return CurrentLocaleStrategy * @throws UnknownCurrentLocaleStrategyException */ protected function getCurrentLocaleStrategy() { $currentLocaleStrategyClass = $this->config->get('locale.strategy_for_current', self::DEFAULT_CURRENT_LOCALE_STRATEGY); if (strpos($currentLocaleStrategyClass, '\\') === false) { $currentLocaleStrategyClass = sprintf('%s\\%sCurrentLocaleStrategy', __NAMESPACE__, $currentLocaleStrategyClass); } if (!class_exists($currentLocaleStrategyClass)) { throw new UnknownCurrentLocaleStrategyException(sprintf('Unknown strategy to look for current locale: %s', $currentLocaleStrategyClass)); } return new $currentLocaleStrategyClass(); }
/** * @param Request $request * @return string[] */ protected function breakdownRoute(Request $request) { $actionName = ''; $parts = explode('/', rtrim($request->getPathInfo(), '/')); array_shift($parts); if ($prefix = $this->config->get(self::CONFIG_KEY_PREFIX)) { if (count($parts) && $parts[0] == $prefix) { array_shift($parts); } } $subnamespaces = $this->config->get(self::CONFIG_KEY_ACTION_SUBNAMESPACES, []); if (is_array($subnamespaces) && count($subnamespaces) && count($parts) && in_array($parts[0], $subnamespaces)) { $actionName = $parts[0] . '\\'; array_shift($parts); } $actionName .= count($parts) ? array_shift($parts) : self::DEFAULT_ACTION; $params = []; while (count($parts)) { $params[array_shift($parts)] = count($parts) ? array_shift($parts) : null; } return [$actionName, $params]; }
/** * @return EntityManager * @throws ProxiesNotWritableException * @throws \Doctrine\ORM\ORMException */ public function getEntityManager() { $proxiesDir = $this->serverContext->getPath(ServerContext::DIR_TMP) . '/doctrineProxies'; !is_dir($proxiesDir) && @mkdir($proxiesDir, 0755); if (!is_dir($proxiesDir) || !is_writable($proxiesDir)) { throw new ProxiesNotWritableException(sprintf('Doctrine proxies dir does not exists or not writeable: %s', $proxiesDir)); } $connConfig = DoctrineSetup::createAnnotationMetadataConfiguration([$this->serverContext->getPath(ServerContext::DIR_SRC)], true); $connConfig->setProxyDir($proxiesDir); $connConfig->setProxyNamespace('Proxies'); $conn = ['driver' => $this->config->get('doctrine.driver'), 'host' => $this->config->get('mysql.host'), 'dbname' => $this->config->get('mysql.dbname'), 'user' => $this->config->get('mysql.username'), 'password' => $this->config->get('mysql.password')]; $em = EntityManager::create($conn, $connConfig); if ($logger = $this->config->get('doctrine.logger')) { $loggerClass = sprintf('\\Doctrine\\DBAL\\Logging\\%s', $logger); $em->getConfiguration()->setSQLLogger(new $loggerClass()); } $em->getConfiguration()->setNamingStrategy(new UnderscoreNamingStrategy()); return $em; }