private function doGenerate($scheme, Page $page, AbstractClassContent $content = null)
    {
        $replacement = [
            '$parent'   => $page->isRoot() ? '' : $page->getParent()->getUrl(false),
            '$title'    => StringUtils::urlize($page->getTitle()),
            '$datetime' => $page->getCreated()->format('ymdHis'),
            '$date'     => $page->getCreated()->format('ymd'),
            '$time'     => $page->getCreated()->format('His'),
        ];

        $matches = [];
        if (preg_match_all('/(\$content->[a-z]+)/i', $scheme, $matches)) {
            foreach ($matches[1] as $pattern) {
                $property = explode('->', $pattern);
                $property = array_pop($property);

                try {
                    $replacement[$pattern] = StringUtils::urlize($content->$property);
                } catch (\Exception $e) {
                    $replacement[$pattern] = '';
                }
            }
        }

        $matches = [];
        if (preg_match_all('/(\$ancestor\[([0-9]+)\])/i', $scheme, $matches)) {
            foreach ($matches[2] as $level) {
                $ancestor = $this->application
                    ->getEntityManager()
                    ->getRepository('BackBee\NestedNode\Page')
                    ->getAncestor($page, $level)
                ;
                if (null !== $ancestor && $page->getLevel() > $level) {
                    $replacement['$ancestor['.$level.']'] = $ancestor->getUrl(false);
                } else {
                    $replacement['$ancestor['.$level.']'] = '';
                }
            }
        }

        $url = preg_replace('/\/+/', '/', str_replace(array_keys($replacement), array_values($replacement), $scheme));

        return $this->getUniqueness($page, $url);
    }