protected function prepareUrl($url)
    {
        if (null === $url) {
            $url = Environment::get('requestUri');
        } elseif (is_numeric($url)) {
            if (null === ($jumpTo = $this->framework->getAdapter(PageModel::class)->findByPk($url))) {
                throw new \InvalidArgumentException('Given page id does not exist.');
            }

            $url = $this->framework->getAdapter(Controller::class)->generateFrontendUrl($jumpTo->row());

            list(, $queryString) = explode('?', Environment::get('request'), 2);

            if ('' != $queryString) {
                $url .= '?'.$queryString;
            }
        }

        $url = ampersand($url, false);

        return $url;
    }