/** * Test building the AMD script loader * * @dataProvider amdLoaderProvider */ public function testAmdLoader($configUrl, $requireJsUrl, $bootstrapUrl, $bundle, $controller, $params, $result) { $loader = new AmdLoader($configUrl, $requireJsUrl, $bootstrapUrl); if ($bundle) { $this->assertEquals($loader->getBundleLoader($bundle, $controller, $params), $result); } else { $this->assertEquals($loader->getDynamicLoader($controller, $params), $result); } }
/** * Create the AMD loader for the current context. * It will load login's modules for anonymous session. * Loads the bundle mode in production and the dynamic mode in debug. * * @param string $bundle the bundle URL * @param string $controller the controller module id * @param array $params additional parameters * @return string the script tag */ public static function getAmdLoader($bundle = null, $controller = null, $params = null) { $bundleMode = \tao_helpers_Mode::is('production'); $configUrl = get_data('client_config_url'); $requireJsUrl = Template::js('lib/require.js', 'tao'); $bootstrapUrl = Template::js('loader/bootstrap', 'tao'); $loader = new AmdLoader($configUrl, $requireJsUrl, $bootstrapUrl); if (\common_session_SessionManager::isAnonymous()) { $controller = 'controller/login'; $bundle = Template::js('loader/login.min.js', 'tao'); } if ($bundleMode) { return $loader->getBundleLoader($bundle, $controller, $params); } return $loader->getDynamicLoader($controller, $params); }