Add a route map to the router. If the pattern already exists it will be overwritten.
{
$pattern = explode('/', trim(parse_url((string) $pattern, PHP_URL_PATH), ' /'));
$vars = array();
$regex = array();
foreach ($pattern as $segment)
{
if ($segment == '*')
{
$regex[] = '.*';
}
elseif ($segment[0] == '*')
{
$vars[] = substr($segment, 1);
$regex[] = '(.*)';
}
elseif ($segment[0] == '\\' && $segment[1] == '*')
{
$regex[] = '\*' . preg_quote(substr($segment, 2));
}
elseif ($segment == ':')
{
$regex[] = '[^/]*';
}
elseif ($segment[0] == ':')
{
$vars[] = substr($segment, 1);
$regex[] = '([^/]*)';
}
elseif ($segment[0] == '\\' && $segment[1] == ':')
{
$regex[] = preg_quote(substr($segment, 1));
}
else
{
$regex[] = preg_quote($segment);
}
}
$this->maps[] = array(
'regex' => chr(1) . '^' . implode('/', $regex) . '$' . chr(1),
'vars' => $vars,
'controller' => (string) $controller
);
return $this;
}