src/mg/Ding/Mvc/Http/HttpUrlMapper.php
public function map(Action $actionObject)
    {
        $url = $actionObject->getId();
        // Add a slash to the beginning is none is found after removing the
        // base url.
        if ($url[0] != '/') {
            $url = '/' . $url;
        }
        // Do not take into account the arguments part of the url.
        $url = explode('?', $url);
        $url = $url[0];

        // Add a trailing slash to the result.
        $len = strlen($url) - 1;
        if ($url[$len] != '/') {
            $url .= '/';
        }

        $this->_logger->debug('Trying to match: ' . $url);
        // Lookup a controller that can handle this url.
        $try = array_merge($this->_map, self::$_annotatedControllers);
        $candidates = array();
        foreach ($try as $map) {
            $controllerUrl = $map[0];
            $controller = $map[1];
            $interceptors = array();
            if (isset($map[2])) {
                $interceptors = $map[2];
            }
            if ($controllerUrl[0] != '/') {
                $controllerUrl = '/' . $controllerUrl;
            }
            $len = strlen($controllerUrl);
            if ($controllerUrl[$len - 1] != '/') {
                $controllerUrl = $controllerUrl . '/';
            }
            $controllerUrlStart = strpos($url, $controllerUrl);
            if (!($controllerUrlStart === 0)) {
                continue;
            }
            $start = $controllerUrlStart + strlen($controllerUrl);
            $action = substr($url, $start);
            if ($action === false) {
                $action = 'Main';
            }
            $action = explode('/', $action);
            $action = $action[0];
            if (!is_object($controller)) {
                $controller = $this->container->getBean($controller);
                $this->_logger->debug(
                	"Found as annotated controller: "
                	. "$controllerUrl in " . get_class($controller)
                );
            }
            if (!isset($candidates[$len])) {
                $candidates[$len] = array();
            }
            $candidates[$len][] = new DispatchInfo(
                $actionObject, $controller, $action . 'Action', $interceptors
            );
        }
        if (empty($candidates)) {
            return false;
        }
        krsort($candidates);
        $controllers = array_shift($candidates);
        return array_shift($controllers);
    }
public function map(Action $actionObject)
    {
        $url = $actionObject->getId();
        // Add a slash to the beginning is none is found after removing the
        // base url.
        if ($url[0] != '/') {
            $url = '/' . $url;
        }
        // Do not take into account the arguments part of the url.
        $url = explode('?', $url);
        $url = $url[0];

        // Add a trailing slash to the result.
        $len = strlen($url) - 1;
        if ($url[$len] != '/') {
            $url .= '/';
        }

        $this->_logger->debug('Trying to match: ' . $url);
        // Lookup a controller that can handle this url.
        $try = array_merge($this->_map, self::$_annotatedControllers);
        $candidates = array();
        foreach ($try as $map) {
            $controllerUrl = $map[0];
            $controller = $map[1];
            $interceptors = array();
            if (isset($map[2])) {
                $interceptors = $map[2];
            }
            if ($controllerUrl[0] != '/') {
                $controllerUrl = '/' . $controllerUrl;
            }
            $len = strlen($controllerUrl);
            if ($controllerUrl[$len - 1] != '/') {
                $controllerUrl = $controllerUrl . '/';
            }
            $controllerUrlStart = strpos($url, $controllerUrl);
            if (!($controllerUrlStart === 0)) {
                continue;
            }
            $start = $controllerUrlStart + strlen($controllerUrl);
            $action = substr($url, $start);
            if ($action === false) {
                $action = 'Main';
            }
            $action = explode('/', $action);
            $action = $action[0];
            if (!is_object($controller)) {
                $controller = $this->container->getBean($controller);
                $this->_logger->debug(
                	"Found as annotated controller: "
                	. "$controllerUrl in " . get_class($controller)
                );
            }
            if (!isset($candidates[$len])) {
                $candidates[$len] = array();
            }
            $candidates[$len][] = new DispatchInfo(
                $actionObject, $controller, $action . 'Action', $interceptors
            );
        }
        if (empty($candidates)) {
            return false;
        }
        krsort($candidates);
        $controllers = array_shift($candidates);
        return array_shift($controllers);
    }
This will map a full url, like /A/B/C to an HttpAction and will try to
find a controller that can handle it. This will isolate the baseUrl.

@param Action $action Original action (coming from the frontcontroller,
the full url).

@return DispatchInfo