protected function getUrlFromRoute($name, Route $route)
    {
        $option = $route->getOption('sitemap');
        
        if ($option === null) {
            return null;
        }
        if (is_string($option)) {
            $decoded = json_decode($option, true);
            if (!json_last_error() && is_array($decoded)) {
                $option = $decoded;
            }
        }
        if (!is_array($option) && !is_bool($option)) {
            $bool = filter_var($option, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
            if (null === $bool) {
                throw new \InvalidArgumentException("The sitemap option for route $name must be boolean or array");
            }
            $option = $bool;
        }
        if (!$option) {
            return null;
        }
        $url = $this->router->generate($name);
        
        $urlObject = new Url(
                $url,
                (isset($option['lastMod']) ? $option['lastMod'] : null),
                (isset($option['priority']) ? $option['priority'] : null),
                (isset($option['changeFreq']) ? $option['changeFreq'] : null)
        );
        
        return $urlObject;
    }