Inspired from https://github.com/nikic/FastRoute
@param array $params
@return string
@throws \InvalidArgumentException
488041
public function computePath($params) {
    $route = $this->getPath();

    if (!preg_match_all(
      '~' . self::VARIABLE_REGEX . '~x', $route, $matches,
      PREG_OFFSET_CAPTURE | PREG_SET_ORDER
    )) {
      return $route;
    }

    $offset = 0;
    $url = '';

    /** @var string[] $matches */
    foreach ($matches as $set) {
      if ($set[0][1] > $offset) {
        $url .= substr($route, $offset, $set[0][1] - $offset);
      }
      if(isset($params[$set[1][0]])) {
        $url .= $params[$set[1][0]];
      } else {
        throw new \InvalidArgumentException(sprintf('No value supplied for "%s"', $set[1][0]));
      }
      $offset = $set[0][1] + strlen($set[0][0]);
    }
    if ($offset !== strlen($route)) {
      $url .= substr($route, $offset);
    }

    return $url;
  }
870339
protected function formatKVLists(array $params)
    {
        $formatted = [];

        foreach ($params as $name => $value) {
            $formatted[] = [
                'key' => $name,
                'value' => strval($value),
            ];
        }

        return $formatted;
    }
688244
public function optionalParameters($params = null)
  {
    if (null === $params)
    {
      return $this->responseConfig['optionalParameters'];
    }

    if (false === is_array($params))
    {
      throw new InvalidArgumentException(sprintf(
        "%s is no valid parameter: Use an array with Key => Value Pairs", $params
      ));
    }

    $this->responseConfig['optionalParameters'] = $params;

    return $this;
  }
931542
private function buildQueryUrl($params)
    {
        $url = parse_url($_SERVER['REQUEST_URI']);
        if (! array_key_exists('query', $url)) {
            $url['query'] = '';
        }
        parse_str($url['query'], $url['query']);
        if (! is_array($url['query'])) {
            $url['query'] = array();
        }
        // Remove 'start parameter if it exists
        if (array_key_exists('start', $url['query'])) {
            unset($url['query']['start']);
        }
        // Add extra parameters from argument
        $url['query'] = array_merge($url['query'], $params);
        $url['query'] = http_build_query($url['query']);
        $url = $url['path'] . ($url['query'] ? '?'.$url['query'] : '');
        
        return $url;
    }
818200
final public static function route(array $params)
    {

        if (!FEnv::isset("framework.smarty.called")) {
            FEnv::set("framework.smarty.called", 1);
        }
        $im = new \iumioFramework\Core\Masters\MasterCore();

        if (!isset($params['name'])) {
            throw new \Exception("The parameter [name] is missing to generate a valid route", E_ERROR);
        }
        $route = ($im->generateRoute(((isset($params['name']))? $params['name'] : ""), ((isset($params['params']) &&
            !empty($params['params']))? $params['params']  : null), ((isset($params['appname']) &&
            !empty($params['appname']))? $params['appname']  : null), ((isset($params['component']) &&
            $params['component'] == "yes")? true  : false)));
        return ($route);
    }
1001822
public function getUrl($params) {
		$path = $this->path;

		foreach ($params as $k => $v) {
			$path = str_replace(":$k", $v, $path);
		}

		return $path;
	}
929922
public function addRouteParameters(array $params)
    {
        $this->parameters = array_merge($this->parameters,$params);
        $this->rawParameters = array_merge($this->rawParameters, $params);

        $this->routeParameters = $params;
    }
1102528
protected static function pluginUrl($params)
    {
        $result = '';
        if (!empty($params['route'])) {
            $route = $params['route'];
            unset($params['route']);
            $result = Url::toRoute($route, $params);
        } elseif (!empty($params['url'])) {
            $url = $params['url'];
            unset($params['url']);
            $result = Url::toRoute($url, $params);
        } else {
            $msg = __METHOD__ . ": text plugin '{{%url}}' must have 'route' or 'url' parameter."
                 . " Real params is " . var_export($params, true);
            Yii::error($msg);
        }
        return $result;
    }
412037
public function transform($params, $rules)
    {
        if (!is_array($params)) {
            throw new InvalidArgumentException('Please use array params when call transform.');
        }
        if (!is_array($rules)) {
            throw new InvalidArgumentException('Please use array rules when call transform.');
        }
        foreach ($params as $key => $param) {
            if (isset($rules[$key])) {
                $formatted = call_user_func([$rules[$key], 'format'], $param);
                $params[$key] = $formatted;
            }
        }
        return $params;
    }
723174
public function execute(array $params = [])
    {
        $context = \Context::getInstance();
        $excludedRoutes = $this->getExcludedRoutes();
        $currentRoute = [
            'extension' => $context->getExtensionName(),
            'module' => $context->getModuleName(),
            'action' => $context->getActionName(),
        ];

        if (!in_array($currentRoute, $excludedRoutes)) {
            $currentUrl = \common_http_Request::currentRequest()->getUrl();
            $url = $this->url . (parse_url($this->url, PHP_URL_QUERY) ? '&' : '?') . 'return_url=' . urlencode($currentUrl);

            $flowController = new FlowController();
            $flowController->redirect($url);
        }
    }
153032
public function routeParams($params = '')
    {
        if (!empty($params)) {
            // Set the property
            if (is_a($params, 'stdClass')) {
                $this->routeParams = $params;
            } else {
                return false;
            }
        } else {
            // Get the property
            return $this->routeParams;
        }
    }
423957
public function path(array $params = array())
    {
        $this->build();
        
        $path = [];
        if ($this->_modules)
            $path = $this->_modules;
        $path[] = $this->_controller;
        $path[] = isset($params['action']) ? $params['action'] : $this->_action;
        
        $format = isset($params['format']) ? '.' . $params['format'] : '';
        
        return implode('/', $path) . $format;
    }
70799
public function createUrl($params=array())
    {
        return Yii::app()->createUrl($this->route, CMap::mergeArray($params, $this->evaluateParams($this->params)));
    }
354278
protected function configure(array $params)
    {
        $required = array('hostname', 'base_dn');
        $missing = array();
        foreach ($required as $key) {
            if (! array_key_exists($key, $params)) {
                $missing[] = $key;
            }
        }
        if (count($missing) > 0) {
            throw new \InvalidArgumentException(
                'Required parameters missing: ' . implode(', ', $missing)
            );
        }

        $idx = strpos($params['hostname'], '://');
        $enforceSSL = false;
        if (false !== $idx) {
            $prefix = strtolower(substr($params['hostname'], 0, $idx));
            if ($prefix === 'ldaps') {
                $enforceSSL = true;
            }
            $params['hostname'] = substr($params['hostname'], $idx+3);
        }

        $params['withSSL'] = false;
        $params['withTLS'] = false;
        if (array_key_exists('security', $params)) {
            switch($params['security']) {
            case 'SSL':
                $params['withSSL'] = true;
                break;
            case 'TLS':
                $params['withTLS'] = true;
                break;
            default:
                throw new \InvalidArgumentException(
                    sprintf(
                        'Security mode %s not supported - only SSL or TLS are supported',
                        $params['security']
                    )
                );
            }
        } elseif ($enforceSSL) {
            $params['withSSL'] = true;
        }

        if (! array_key_exists('port', $params)) {
            if ($params['withSSL']) {
                $params['port'] = 636;
            } else {
                $params['port'] = 389;
            }
        }

        if (! array_key_exists('options', $params)) {
            $params['options'] = array();
        }

        $params['bind_anonymous'] = false;
        if ((! array_key_exists('bind_dn', $params)) || (strlen(trim($params['bind_dn'])) == 0)) {
            $params['bind_anonymous'] = true;
            $params['bind_dn']        = '';
            $params['bind_password']  = '';
        }
        if (! array_key_exists('bind_password', $params)) {
            $params['bind_password']  = '';
        }

        $this->configuration = $params;
    }
305396
protected function prepareParams(array $params)
	{
		$prepared = [];
		
		foreach($params as $k => $v)
		{
			if(is_array($v))
			{
				foreach(array_values($v) as $i => $val)
				{
					$prepared[sprintf('%s%u', $k, $i)] = $val;
				}
			}
			else
			{
				$prepared[(string)$k] = $v;
			}
		}
		
		return $prepared;
	}
160066
protected function serializeParams(array $params)
    {
        $serialized = array();
        foreach ($params as $param) {
            $serialized[] = $this->serializer->serialize($param);
        }

        return $serialized;
    }
198399
public function execute($params = array())
    {
        $app = $this->router->getAppInstance();
        return $app->trigger("system.routing.route.execute", function($event) {
            $app = $event->props('app');
            $route = $event->props('route');
            $params = $event->props('params');
            if (count($params) == 0) {
                $params = $route->getParams();
            }
            //enhancement, detect the type of the callback
            $callback = $route->getCallback();
            if (is_string($callback)) {
                $callback_comps = explode("#", $callback);
                $callback_object_class = $callback_comps[0]; //starting from root namespace
                $callback_object_class = str_replace(".", "\\", $callback_object_class); 
                $callback_object = new $callback_object_class($app);
                $callback_object_method = $callback_comps[1];
                $callback = array($callback_object, $callback_object_method);
            }
            return call_user_func_array($callback, $params);
        }, array('app' => $app, 'route' => $this, 'params' => $params));
    }