public static function getAmdLoader($bundle = null, $controller = null, $params = null, $allowAnonymous = false){

        $bundleMode   = \tao_helpers_Mode::is('production');
        $configUrl    = get_data('client_config_url');
        $requireJsUrl = Template::js('lib/require.js', 'tao');
        $bootstrapUrl = Template::js('loader/bootstrap.js', 'tao');

        $loader = new AmdLoader($configUrl, $requireJsUrl, $bootstrapUrl);

        if(\common_session_SessionManager::isAnonymous() && !$allowAnonymous) {
            $controller = 'controller/login';
            $bundle = Template::js('loader/login.min.js', 'tao');
        }

        if($bundleMode){
            return "<script src='" . Template::js('loader/vendor.min.js', 'tao') . "'></script>\n" .
                    $loader->getBundleLoader($bundle, $controller, $params);
        }

        return $loader->getDynamicLoader($controller, $params);
    }