/** * Load all modules basing on configuration * * @return $this * @throws \InvalidArgumentException */ protected function loadModules() { $modules = $this->config->get('app.module'); if (empty($modules)) { throw new \InvalidArgumentException("Configuration for modules is empty." . " Check whether key 'app.module' has at least one module specified."); } foreach ($modules as $name => $config) { $this->loadModule($name, $config); } return $this; }
/** * @param Config $config * * @return \Doctrine\Common\Cache\CacheProvider * @throws \OutOfBoundsException */ public function getCache($config) { $type = $config->get('type'); switch ($type) { case 'memcache': $memcache = new \Memcache(); $memcache->connect($config->get('config.host'), $config->get('config.port')); $cache = new \Doctrine\Common\Cache\MemcacheCache(); $cache->setMemcache($memcache); break; case 'xcache': $cache = new \Doctrine\Common\Cache\XCacheCache(); break; case 'apc': $cache = new \Doctrine\Common\Cache\ApcCache(); break; case 'array': $cache = new \Doctrine\Common\Cache\ArrayCache(); break; default: throw new \OutOfBoundsException(sprintf("Unsupported cache type: '%s'", $type)); break; } return $cache; }