Nest the config loader and activates it

@return static
164679
public function nest()
    {
        // Nest config
        $manifest = clone $this->getManifest();

        // Create new blank loader with new stack (top level nesting)
        $newLoader = new static;
        $newLoader->pushManifest($manifest);

        // Activate new loader
        return $newLoader->activate();
    }
176179
protected function setupContainer()
    {
        $container = Registry::init();
        $container->add('app', $this);
        $container->add('registry', $container);

        $container->add('config', function () {
            return new Config($this->getConfigPath(), 'prod');
        });

        $this->config = $container->make('config');

        $container->add('routes', function () {
            return new Collection();
        });

        $this->container = $container;
    }
1115077
public static function factory()
    {
        $self = new static();
        $self->downloader = new Plugins\Xml\Downloader();
        $self->writer     = new Plugins\Xml\Writer();
        
        $self->outputter  = new Plugins\NullObject();

        return $self;
    }
726827
protected function loadManager()
    {
        if (null === $this->getManager()) {
            $manager = new Manager($this->getConfig(), $this);
            $this->setManager($manager);
        } else {
            $manager = $this->getManager();
            $manager->setCommand($this);
        }
    }
1350329
public static function fromConfig()
	{
		$mailer = self::getInstance();

		$services = Config::get ('mailer.services');

		if (!$services) {
			return $mailer;
		}

		foreach ($services as $k => $v) {
			$service = MapperFactory::getServiceMapper()->getFromToken($k);
			if ($service) {
				$service->setFromConfig ($v);
				$mailer->addService ($service);
			}
		}

		return $mailer;
	}
115701
public function reloadConfig(): Promise
    {
        if ($this->pendingConfig) {
            return $this->pendingConfig;
        }

        $promise = call(function () {
            $this->config = yield $this->configLoader->loadConfig();
        });

        $this->pendingConfig = $promise;

        $promise->onResolve(function () {
            $this->pendingConfig = null;
        });

        return $promise;
    }
239743
function initialize()
    {
        if ($this->isInitialize())
            return $this;

        // ) Load Modules ------------------------------------------------------\
        $serviceManager = $this->getServiceManager();
        /** @var ModuleManager $moduleManager */
        $moduleManager  = $serviceManager->get('ModuleManager');
        $moduleManager->loadModules();

        // ) Attach Listeners To Events ----------------------------------------\
        $events = $this->getEventManager();
        foreach ($this->listeners as $listener) {
            if (!is_object($listener)) {
                if (class_exists($listener))
                    $listener = new $listener();
                else
                    $listener = $this->getServiceManager()->get($listener);
            }

            if (!$listener instanceof ListenerAggregateInterface)
                throw new \Exception(sprintf(
                    'Listener must instance of "ListenerAggregateInterface" but "%s" given.'
                    , is_object($listener) ? get_class($listener) : gettype($listener)
                ));

            // Attach Aggregate Listener
            $events->attach($listener);
        }

        // Ci) Bootstrap Application --------------------------------------------\
        $this->bootstrap();

        $this->__isInitialize = true;

        return $this;
    }
176985
private function initDefaultClasses()
	{
		$this['loader'] = $this->share(function ($app) {
			return new ClassLoader();
		});

		$this['config'] = $this->share(function ($app) {
			$config = new Config();
			$config->addHint($app['path.root'] . '/resources/config/');
			return $config;
		});

		$this->instance('app', $this);
	}
117552
public static function init()
    {
        $files = File::getFolder(CONF_PATH)['file'];
        foreach ($files as $item => $file) {
            if (is_file(CONF_PATH . $file)) {
                $conf = self::load(CONF_PATH . $file);
                if (0 === $item) {
                    self::$config = $conf;
                } else {
                    self::$config[basename($file, EXT)] = $conf;
                }
            }
        }
        return self::$config;
    }
1157940
public function bootstrap()
    {
        $this->registerLoader();
        $this->registerModules($this->getConfiguration()['application']['modules']);

        $eventsManager = new \Phalcon\Events\Manager();
        $this->setEventsManager($eventsManager);

        $this->registerServices();

        return $this;
    }
86055
public function getConfigManager()
    {
        if (null === $this->configManager) {
            $cachePath = $this->getCacheDir() . '/application-config-cache.' . $this->getName() . '.php';
            $this->configManager = new ConfigManager($cachePath, !$this->debug, $this->rootDir . '/config');
        }

        return $this->configManager;
    }
144702
protected function loadPluginManagerConfigs()
    {
        foreach ($this->getXml()->xpath('plugins/pluginmanager[@type != ""]') as $pmConfig) {
            $key = (string)$pmConfig['type'];
            $config = $this->createServiceManagerConfig($pmConfig);

            if ($config) {
                $this->manifest['application_config'][$key] = $config;
            }
        }

        return $this;
    }
168273
protected function _getConfig()
    {
        if ($this->config === null) {
            $configFinder = new ConfigFinder();
            $this->config = $configFinder->loadAll();
        }

        return $this->config;
    }
1370205
public function init()
    {
        if ($this->initialized) {
            return $this;
        }

        $this->grav = Grav::instance();
        $this->config = $this->grav['config'];

        // Enable/disable debugger based on configuration.
        $this->enabled = (bool)$this->config->get('system.debugger.enabled');

        if ($this->enabled()) {
            $this->initialized = true;

            $plugins_config = (array)$this->config->get('plugins');

            ksort($plugins_config);

            $debugbar = $this->debugbar;
            $debugbar->addCollector(new MemoryCollector());
            $debugbar->addCollector(new ExceptionsCollector());
            $debugbar->addCollector(new ConfigCollector((array)$this->config->get('system'), 'Config'));
            $debugbar->addCollector(new ConfigCollector($plugins_config, 'Plugins'));
            $this->addMessage('Grav v' . GRAV_VERSION);
        }

        return $this;
    }
818653
public function setup()
    {
        $this->di->set('config', $this->config);

        $this->initEnvironment($this->config);
        $this->initErrorHandler($this->config);
        $this->initLoader($this->config);
        $this->initModules($this->config);
        $this->initRoutes($this->config);
        $this->initServices($this->config);
        $this->initDispatcher();

        $this->application->setDI($this->di);
        DI::setDefault($this->di);

        return $this;
    }
738945
private function initBundles()
    {
        $bundleLoader = $this->getContainer()->get('bundle.loader');
        if (!$bundleLoader->isRestored() && null !== $this->getConfig()->getBundlesConfig()) {
            $bundleLoader->load($this->getConfig()->getBundlesConfig());
        }

        return $this;
    }
790844
public function applyConfig()
    {
        parent::applyConfig();
        $pool = $this;
        if (!isset($this->preloading)) {
            $this->preloading = new ComplexJob();
        }
        $job = $this->preloading;
        $job->addJob('resolvfile', function ($jobname, $job) use ($pool) {
            FileSystem::readfile($pool->config->resolvfile->value, function ($file, $data) use ($pool, $job, $jobname) {
                if ($file) {
                    foreach (explode("\n", $data) as $line) {
                        $line = trim($line);
                        if ($line !== '' && $line[0] !== '#' && preg_match('~nameserver ([^\r\n;]+)~i', $line, $m)) {
                            $pool->nameServers[] = $m[1];
                        }
                    }
                }
                $job->setResult($jobname);
            });
        });
        $job->addJob('hostsfile', function ($jobname, $job) use ($pool) {
            FileSystem::readfile($pool->config->hostsfile->value, function ($file, $data) use ($pool, $job, $jobname) {
                if ($file) {
                    preg_match_all('~^([^#]\S+)\s+([^\r\n]+)\s*~m', $data, $m, PREG_SET_ORDER);
                    $pool->hosts = [];
                    foreach ($m as $h) {
                        $hosts = preg_split('~\s+~', $h[2]);
                        $ip = $h[1];
                        /* skip commentened ips */
                        if (preg_match('~^[\s]*?#~m', $ip)) {
                            continue;
                        }
                        foreach ($hosts as $host) {
                            $host = rtrim($host, '.') . '.';
                            $pool->hosts[$host][] = $ip;
                        }
                    }
                }
                $job->setResult($jobname);
            });
        });
        $job();
    }