configUrl = $configUrl; $this->requireJsUrl = $requireJsUrl; $this->bootstrapUrl = $bootstrapUrl; } /** * Get the loader for the bundle mode * @param string $bundle the URL of the bundle * @param string $controller the controller module id * @param array $params additionnal parameters to give to the loader * * @return the generated script tag */ public function getBundleLoader($bundle, $controller, $params = null) { $attributes = [ 'data-config' => $this->configUrl, 'src' => $bundle, 'data-controller' => $controller ]; if (!is_null($params)) { $attributes['data-params'] = json_encode($params); } return $this->buildScriptTag($attributes); } /** * Get the loader for the dynamic mode * @param string $controller the controller module id * @param array $params additionnal parameters to give to the loader * * @return the generated script tag */ public function getDynamicLoader($controller, $params = null) { $attributes = [ 'data-config' => $this->configUrl, 'src' => $this->requireJsUrl, 'data-main' => $this->bootstrapUrl, 'data-controller' => $controller ]; if (!is_null($params)) { $attributes['data-params'] = json_encode($params); } return $this->buildScriptTag($attributes); } /** * Build the script tag * @param array $attributes key/val to create tag's attributes * * @return the generated script tag */ private function buildScriptTag($attributes) { $amdScript = ''; } }