protected function createRoute(
        $domain,
        CustomUrlBehavior $document,
        Localization $locale,
        $persistedLocale,
        $routesPath
    ) {
        $path = sprintf('%s/%s', $routesPath, $domain);
        $routeDocument = $this->findOrCreateRoute($path, $persistedLocale, $document, $domain);
        $routeDocument->setTargetDocument($document);
        $routeDocument->setLocale($locale->getLocale());
        $routeDocument->setHistory(false);

        $this->documentManager->persist(
            $routeDocument,
            $persistedLocale,
            [
                'path' => $path,
                'auto_create' => true,
            ]
        );
        $this->documentManager->publish($routeDocument, $persistedLocale);

        return $routeDocument;
    }