Class DocumentUrlService
Implements IDocumentUrlService operations for handling document URLs.
Inheritance
Namespace: Umbraco.Cms.Core.Services
Assembly: Umbraco.Core.dll
Syntax
public class DocumentUrlService : IDocumentUrlService
Constructors
View SourceDocumentUrlService(ILogger<DocumentUrlService>, IDocumentUrlRepository, IDocumentRepository, ICoreScopeProvider, IOptions<GlobalSettings>, IOptions<WebRoutingSettings>, UrlSegmentProviderCollection, IContentService, IShortStringHelper, ILanguageService, IKeyValueService, IIdKeyMap, IDocumentNavigationQueryService, IPublishStatusQueryService, IDomainCacheService, IDefaultCultureAccessor)
Initializes a new instance of the DocumentUrlService class.
Declaration
public DocumentUrlService(ILogger<DocumentUrlService> logger, IDocumentUrlRepository documentUrlRepository, IDocumentRepository documentRepository, ICoreScopeProvider coreScopeProvider, IOptions<GlobalSettings> globalSettings, IOptions<WebRoutingSettings> webRoutingSettings, UrlSegmentProviderCollection urlSegmentProviderCollection, IContentService contentService, IShortStringHelper shortStringHelper, ILanguageService languageService, IKeyValueService keyValueService, IIdKeyMap idKeyMap, IDocumentNavigationQueryService documentNavigationQueryService, IPublishStatusQueryService publishStatusQueryService, IDomainCacheService domainCacheService, IDefaultCultureAccessor defaultCultureAccessor)
Parameters
| Type | Name | Description |
|---|---|---|
| ILogger<DocumentUrlService> | logger | |
| IDocumentUrlRepository | documentUrlRepository | |
| IDocumentRepository | documentRepository | |
| ICoreScopeProvider | coreScopeProvider | |
| IOptions<GlobalSettings> | globalSettings | |
| IOptions<WebRoutingSettings> | webRoutingSettings | |
| UrlSegmentProviderCollection | urlSegmentProviderCollection | |
| IContentService | contentService | |
| IShortStringHelper | shortStringHelper | |
| ILanguageService | languageService | |
| IKeyValueService | keyValueService | |
| IIdKeyMap | idKeyMap | |
| IDocumentNavigationQueryService | documentNavigationQueryService | |
| IPublishStatusQueryService | publishStatusQueryService | |
| IDomainCacheService | domainCacheService | |
| IDefaultCultureAccessor | defaultCultureAccessor |
DocumentUrlService(ILogger<DocumentUrlService>, IDocumentUrlRepository, IDocumentRepository, ICoreScopeProvider, IOptions<GlobalSettings>, UrlSegmentProviderCollection, IContentService, IShortStringHelper, ILanguageService, IKeyValueService, IIdKeyMap, IDocumentNavigationQueryService, IPublishStatusQueryService, IDomainCacheService)
Initializes a new instance of the DocumentUrlService class.
Declaration
[Obsolete("Please use the constructor taking all parameters. Scheduled for removal in Umbraco 19.")]
public DocumentUrlService(ILogger<DocumentUrlService> logger, IDocumentUrlRepository documentUrlRepository, IDocumentRepository documentRepository, ICoreScopeProvider coreScopeProvider, IOptions<GlobalSettings> globalSettings, UrlSegmentProviderCollection urlSegmentProviderCollection, IContentService contentService, IShortStringHelper shortStringHelper, ILanguageService languageService, IKeyValueService keyValueService, IIdKeyMap idKeyMap, IDocumentNavigationQueryService documentNavigationQueryService, IPublishStatusQueryService publishStatusQueryService, IDomainCacheService domainCacheService)
Parameters
| Type | Name | Description |
|---|---|---|
| ILogger<DocumentUrlService> | logger | |
| IDocumentUrlRepository | documentUrlRepository | |
| IDocumentRepository | documentRepository | |
| ICoreScopeProvider | coreScopeProvider | |
| IOptions<GlobalSettings> | globalSettings | |
| UrlSegmentProviderCollection | urlSegmentProviderCollection | |
| IContentService | contentService | |
| IShortStringHelper | shortStringHelper | |
| ILanguageService | languageService | |
| IKeyValueService | keyValueService | |
| IIdKeyMap | idKeyMap | |
| IDocumentNavigationQueryService | documentNavigationQueryService | |
| IPublishStatusQueryService | publishStatusQueryService | |
| IDomainCacheService | domainCacheService |
Methods
View SourceCreateOrUpdateUrlSegmentsAsync(IEnumerable<IContent>)
Creates or updates the URL segments for a collection of documents.
Declaration
public Task CreateOrUpdateUrlSegmentsAsync(IEnumerable<IContent> documentsEnumerable)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<IContent> | documentsEnumerable |
Returns
| Type | Description |
|---|---|
| Task |
CreateOrUpdateUrlSegmentsAsync(Guid)
Creates or updates the URL segments for a single document.
Declaration
public Task CreateOrUpdateUrlSegmentsAsync(Guid key)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | The document key. |
Returns
| Type | Description |
|---|---|
| Task |
CreateOrUpdateUrlSegmentsWithDescendantsAsync(Guid)
Creates or updates the URL segments for a document and it's descendants.
Declaration
public Task CreateOrUpdateUrlSegmentsWithDescendantsAsync(Guid key)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | The document key. |
Returns
| Type | Description |
|---|---|
| Task |
DeleteUrlsFromCacheAsync(IEnumerable<Guid>)
Deletes all URLs from the cache for a collection of document keys.
Declaration
public Task DeleteUrlsFromCacheAsync(IEnumerable<Guid> documentKeysEnumerable)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<Guid> | documentKeysEnumerable |
Returns
| Type | Description |
|---|---|
| Task |
GetDocumentKeyByRoute(string, string?, int?, bool)
Gets a document key by route.
Declaration
public Guid? GetDocumentKeyByRoute(string route, string? culture, int? documentStartNodeId, bool isDraft)
Parameters
| Type | Name | Description |
|---|---|---|
| string | route | The route. |
| string | culture | The culture code. |
| int? | documentStartNodeId | The document start node Id. |
| bool | isDraft | Whether to get the url of the draft or published document. |
Returns
| Type | Description |
|---|---|
| Guid? | The document key, or null if not found. |
GetDocumentKeyByUri(Uri, bool)
Gets a document key by System.Uri.
Declaration
public Guid? GetDocumentKeyByUri(Uri uri, bool isDraft)
Parameters
| Type | Name | Description |
|---|---|---|
| Uri | uri | The uniform resource identifier. |
| bool | isDraft | Whether to get the url of the draft or published document. |
Returns
| Type | Description |
|---|---|
| Guid? | The document key, or null if not found. |
GetLegacyRouteFormat(Guid, string?, bool)
Gets the legacy route format for a document key and culture.
Declaration
public string GetLegacyRouteFormat(Guid documentKey, string? culture, bool isDraft)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | documentKey | |
| string | culture | The culture code. |
| bool | isDraft | Whether to get the url of the draft or published document. |
Returns
| Type | Description |
|---|---|
| string |
GetUrlSegment(Guid, string, bool)
Gets a single URL segment from a document key and culture. Preview urls are returned if isDraft is true.
Declaration
public string? GetUrlSegment(Guid documentKey, string culture, bool isDraft)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | documentKey | The key of the document. |
| string | culture | The culture code. |
| bool | isDraft | Whether to get the url of the draft or published document. |
Returns
| Type | Description |
|---|---|
| string | A URL segment for the document. |
Remarks
If more than one segment is available, the first retrieved and indicated as primary will be returned.
GetUrlSegments(Guid, string, bool)
Gets the URL segments from a document key and culture. Preview urls are returned if isDraft is true.
Declaration
public IEnumerable<string> GetUrlSegments(Guid documentKey, string culture, bool isDraft)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | documentKey | The key of the document. |
| string | culture | The culture code. |
| bool | isDraft | Whether to get the url of the draft or published document. |
Returns
| Type | Description |
|---|---|
| IEnumerable<string> | The URL segments for the document. |
HasAny()
Gets a value indicating whether any URLs have been cached.
Declaration
public bool HasAny()
Returns
| Type | Description |
|---|---|
| bool |
InitAsync(bool, CancellationToken)
Initializes the service and ensure the content in the database is correct with the current configuration.
Declaration
public Task InitAsync(bool forceEmpty, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | forceEmpty | Forces an early return when we know there are no routes (i.e. on install). |
| CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| Task |
RebuildAllUrlsAsync()
Rebuilds all document URLs.
Declaration
public Task RebuildAllUrlsAsync()
Returns
| Type | Description |
|---|---|
| Task |