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
16289
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);
    }
391637
protected function getController($controller)
	{
		$stub = $this->files->get(__DIR__.'/stubs/controller.stub');

		// We will explode out the controller name on the naemspace delimiter so we
		// are able to replace a namespace in this stub file. If no namespace is
		// provided we'll just clear out the namespace place-holder locations.
		$segments = explode('\\', $controller);

		$stub = $this->replaceNamespace($segments, $stub);

		return str_replace('{{class}}', last($segments), $stub);
	}
1289462
protected function setModuleAssets(Controller $controller)
    {
        $controller->addAssetLibrary('jquery_mobile');
        $controller->setJs(__DIR__ . '/js/common.js');
        $controller->setCss(__DIR__ . '/css/common.css');
    }
635183
public function getLink($controller, $params = array(), $fullPath = false)
    {
        if ($controller instanceof Controller) {
            $controller = get_class($controller);
        }
        $controller = (string)$controller;
        if(substr($controller, 0, 1) === "\\") {
            $controller = substr($controller, 1);
        }
        try {

            $url = Bootstrap::getSingleton()->getManager()->getRouter()->generate($controller, $params);
            if ($fullPath) {
                $protocol = 'http';
                if (strpos($_SERVER['SCRIPT_URI'], 'https') !== false) {
                    $protocol = 'https';
                }
                return $protocol . '://' . $_SERVER['HTTP_HOST'] . $url;
            }
            return $url;
        } catch (\Exception $ex) {

        }
        return "";
    }
1242960
private function getPartsFromControllerName($controller)
    {
        if (3 != count($parts = explode(':', $controller))) {
            throw new \InvalidArgumentException(sprintf('The "%s" controller is not a valid a:b:c controller string.', $controller));
        }

        list($moduleName, $controller, $action) = $parts;
        $controller = str_replace('/', '\\', $controller);
        $module     = $this->moduleManager->getModule($moduleName);

        if (!is_object($module)) {
            throw new \RuntimeException(sprintf(
                'Unable to locate module: %s, when parsing controller: %s',
                $moduleName, $controller
            ));
        }

        $moduleName = $module->getName();

        return [$module, $moduleName, $controller, $action];
    }
1213806
static function load($controller, $action = '', $params = array())
	{

		$class_name = ucfirst($controller);
		$method = $action;
		$tc = "Controller\\" . $class_name;
		if (!class_exists($tc)) return self::er("Class $tc does not exist.");
		$this_object = new $tc($params);


		if (!method_exists($this_object, $method)) {
			return self::er("Method $method in $tc does not exist.");
		}


		if (!is_callable(array($this_object, $method))) return self::er("Method $method in $tc is not callable.");
		if (is_callable(array($this_object, "__before"))) {
			call_user_func(array($this_object, "__before"));
		}


		call_user_func(array($this_object, $method));

		if (is_callable(array($this_object, "__after"))) {
			call_user_func(array($this_object, "__after"));
		}
		return $this_object;
	}
553048
public function controller($controller = null)
    {
        if (!is_null($controller)) {
            $this->controller = $controller;
            return $this;
        } else {
            return $this->controller ?: '';
        }
    }
290283
public function register_router_controller($router, $params, $controller)
    {
        if (!is_array($params)) {
            $params = array($params);
        }
        $route = $params[0];
        $method = isset($params[1]) ? $params[1] : 'GET|POST';
        $name = isset($params[2]) ? $params[2] : $controller;
        if (in_array($name, $this->controllers_routes)) {
            $name = null;
        } else {
            $this->controllers_routes[] = $name;
        }
        $this->controllers_url_routes[] = $controller . ' ' . $route . ' [' . $method . ']';
        if(!isset(self::$routes[$name])) {
            $router->map($method, $route, array($this, $controller), $name);
            self::$routes[$name] = true;
        } else {
            $router->map($method, $route, array($this, $controller));

        }
    }
489615
public function get(string $module, string $controller): Link
    {
        return $this->addMap(RequestMethod::GET, $module, $controller);
    }
1280331
protected function getRequiredClientBundleCodeGenerators($bundle)
    {
        return [
            $this->createClientDependencyProviderCodeGenerator($bundle),
            $this->createClientFactoryCodeGenerator($bundle),
            $this->createClientCodeGenerator($bundle),
            $this->createClientInterfaceCodeGenerator($bundle),
            $this->createStubCodeGenerator($bundle),
            $this->createStubInterfaceCodeGenerator($bundle),
            $this->createGatewayControllerCodeGenerator($bundle),
        ];
    }
1307532
public function findUriTemplatesByController($controller)
    {
        $result = array();

        foreach ($this->map as $uriTemplate => $options) {
            if (isset($options['controller']) && $options['controller'] == $controller) {
                array_push($result, $uriTemplate);
            }
        }

        return $result;
    }
218730
public static function mvcDispatcher($module, $controller, $action, $params)
    {
        $dispatcher = new self;
        $dispatcher->setModule($module);
        $dispatcher->setController($controller);
        $dispatcher->setAction($action);
        $dispatcher->setParams($params);

        // get current application config
        $applicationConfig = Bootstrap::getInstance()->getEnvironment()->getApplicationConfig();

        // build the class name
        $className = '\\' . $applicationConfig->Namespace . '\Modules\\' . $dispatcher->getModule() . '\Controllers\\' . $dispatcher->getController();
        $dispatcher->setClassName($className);

        return $dispatcher;
    }
322960
protected function urlCustom($module, $controller, $params): string
    {
        $url = $this->reverse[$module][$controller]['route'];

        $getParams = [];
        foreach ($params as $key => $value) {
            // sub-array as GET params
            if (\is_array($value)) {
                $getParams[$key] = $value;
                continue;
            }
            $url = str_replace('{$' . $key . '}', $value, $url, $replaced);
            // if not replaced, setup param as GET
            if (!$replaced) {
                $getParams[$key] = $value;
            }
        }
        // clean optional params
        $url = preg_replace('/\{\$[a-z0-9-_]+\}/i', '', $url);
        // clean regular expression (.*)
        $url = preg_replace('/\(\.\*\)/', '', $url);
        // replace "//" with "/"
        $url = str_replace('//', '/', $url);

        if (!empty($getParams)) {
            $url .= '?' . http_build_query($getParams);
        }
        return $this->getBaseUrl() . ltrim($url, '/');
    }
979651
public function getUrl(
        $module = self::DEFAULT_MODULE,
        $controller = self::DEFAULT_CONTROLLER,
        array $params = []
    ): string {
        $module = $module ?? Request::getModule();
        $controller = $controller ?? Request::getController();

        if (isset($this->reverse[$module], $this->reverse[$module][$controller])) {
            return $this->urlCustom($module, $controller, $params);
        }

        return $this->urlRoute($module, $controller, $params);
    }
265902
public static function buildURL($controller, array $params = [], string $host = '') : string {
		if (empty($host)) {
			$host = \Request::host();
		}
		$controller = ltrim($controller, '/');
		return $host . $controller . '?' . http_build_query2($params);
	}
405281
public function load(array $bundles)
    {
        $this->finalBundles = $bundles;

        while (!empty($this->bundleStack)) {
            $bundle = array_shift($this->bundleStack);
            $this->addBundle($bundle);
        }

        return $this->finalBundles;
    }
892373
public function setMvcUrl($controller = null, $action = null, array $params = [])
    {
        $this->mvcUrl = [
            'controller' => trim($controller),
            'action'     => trim($action),
            'params'     => $params
        ];
        return $this;
    }