public function config()
    {
        $this->setContentHeader('application/javascript');

        //get extension paths to set up aliases dynamically
        $extensionsAliases = ClientLibRegistry::getRegistry()->getLibAliasMap();
        $this->setData('extensionsAliases', $extensionsAliases);

        $libConfigs = ClientLibConfigRegistry::getRegistry()->getMap();
        // Dynamically adds the date format.
        $formatter = DateHelper::getDateFormatter();
        $libConfigs['util/locale']['dateTimeFormat'] = $formatter->getJavascriptFormat(DateHelper::FORMAT_LONG);
        $this->setData('libConfigs', $libConfigs);

        $extendedConfig = $this->getServiceLocator()->get(ClientConfigService::SERVICE_ID)->getExtendedConfig();
        foreach ($extendedConfig as $key => $value) {
            $this->setData($key, json_encode($value));
        }

        //use the resolver in order to validate the route
        $resolver = $this->getResolver();

        //loads the URLs context
        /** @var AssetService $assetService */
        $assetService = $this->getServiceLocator()->get(AssetService::SERVICE_ID);
        $tao_base_www = $assetService->getJsBaseWww('tao');
        $this->setData('buster', $assetService->getCacheBuster());

        $base_www = $assetService->getJsBaseWww($resolver->getExtensionId());
        $base_url = $this->getExtension($resolver->getExtensionId())->getConstant('BASE_URL');

        $langCode = tao_helpers_I18n::getLangCode();
        if(strpos($langCode, '-') > 0){
            $lang = strtolower(substr($langCode, 0, strpos($langCode, '-')));
        } else {
            $lang = strtolower($langCode);
        }

        $this->setData('locale', $langCode);
        $this->setData('client_timeout', $this->getClientTimeout());
        $this->setData('crossorigin', $this->isCrossorigin());
        $this->setData('tao_base_www', $tao_base_www);

        $this->setData('context', json_encode([
            'root_url'       => ROOT_URL,
            'base_url'       => $base_url,
            'taobase_www'    => $tao_base_www,
            'base_www'       => $base_www,
            'base_lang'      => $lang,
            'locale'         => $langCode,
            'timeout'        => $this->getClientTimeout(),
            'extension'      => $resolver->getExtensionId(),
            'module'         => $resolver->getControllerShortName(),
            'action'         => $resolver->getMethodName(),
            'shownExtension' => $this->getShownExtension(),
            'shownStructure' => $this->getShownStructure(),
            'bundle'         => tao_helpers_Mode::is(tao_helpers_Mode::PRODUCTION)
        ]));

        $this->setView('client_config.tpl');
    }