/** * Returns system DI container. * @return SystemContainer */ public function createContainer() { if ($cacheDir = $this->getCacheDirectory()) { $cache = new NCache(new NPhpFileStorage($cacheDir), 'Nette.Configurator'); $cacheKey = array($this->params, $this->files); $cached = $cache->load($cacheKey); if (!$cached) { $code = $this->buildContainer($dependencies); $cache->save($cacheKey, $code, array( NCache::FILES => $this->params['productionMode'] ? NULL : $dependencies, )); $cached = $cache->load($cacheKey); } NLimitedScope::load($cached['file'], TRUE); } elseif ($this->files) { throw new InvalidStateException("Set path to temporary directory using setTempDirectory()."); } else { NLimitedScope::evaluate($this->buildContainer()); // back compatibility with Environment } $container = new $this->params['container']['class']; $container->initialize(); NEnvironment::setContext($container); // back compatibility return $container; }