Search Results for

    Show / Hide Table of Contents
    View Source

    Class DocumentUrlAliasService

    Implements IDocumentUrlAliasService operations for handling document URL aliases.

    Inheritance
    object
    Namespace: Umbraco.Cms.Core.Services
    Assembly: Umbraco.Core.dll
    Syntax
    public class DocumentUrlAliasService : IDocumentUrlAliasService

    Constructors

    View Source

    DocumentUrlAliasService(ILogger<DocumentUrlAliasService>, IDocumentUrlAliasRepository, ICoreScopeProvider, ILanguageService, IKeyValueService, IContentService, IDocumentNavigationQueryService)

    Initializes a new instance of the DocumentUrlAliasService class.

    Declaration
    public DocumentUrlAliasService(ILogger<DocumentUrlAliasService> logger, IDocumentUrlAliasRepository documentUrlAliasRepository, ICoreScopeProvider coreScopeProvider, ILanguageService languageService, IKeyValueService keyValueService, IContentService contentService, IDocumentNavigationQueryService documentNavigationQueryService)
    Parameters
    Type Name Description
    ILogger<DocumentUrlAliasService> logger
    IDocumentUrlAliasRepository documentUrlAliasRepository
    ICoreScopeProvider coreScopeProvider
    ILanguageService languageService
    IKeyValueService keyValueService
    IContentService contentService
    IDocumentNavigationQueryService documentNavigationQueryService

    Fields

    View Source

    RebuildKey

    Represents the key used to identify the URL alias generation rebuild operation.

    Declaration
    public const string RebuildKey = "UmbracoUrlAliasGeneration"
    Field Value
    Type Description
    string

    Methods

    View Source

    CreateOrUpdateAliasesAsync(Guid)

    Creates or updates the aliases for a single document.

    Declaration
    public Task CreateOrUpdateAliasesAsync(Guid documentKey)
    Parameters
    Type Name Description
    Guid documentKey

    The document key.

    Returns
    Type Description
    Task
    View Source

    CreateOrUpdateAliasesWithDescendantsAsync(Guid)

    Creates or updates the aliases for a document and its descendants.

    Declaration
    public Task CreateOrUpdateAliasesWithDescendantsAsync(Guid documentKey)
    Parameters
    Type Name Description
    Guid documentKey

    The document key.

    Returns
    Type Description
    Task
    View Source

    DeleteAliasesFromCacheAsync(IEnumerable<Guid>)

    Deletes all aliases from the cache for a collection of document keys.

    Declaration
    public Task DeleteAliasesFromCacheAsync(IEnumerable<Guid> documentKeys)
    Parameters
    Type Name Description
    IEnumerable<Guid> documentKeys

    The collection of document keys.

    Returns
    Type Description
    Task
    View Source

    GetAliasesAsync(Guid, string?)

    Gets all URL aliases for a given document.

    Declaration
    public Task<IEnumerable<string>> GetAliasesAsync(Guid documentKey, string? culture)
    Parameters
    Type Name Description
    Guid documentKey

    The document key.

    string culture

    The culture code (null for default language).

    Returns
    Type Description
    Task<IEnumerable<string>>

    All aliases for the document in the specified culture, or empty if none found.

    View Source

    GetDocumentKeysByAliasAsync(string, string?)

    Gets all document keys that match a given URL alias.

    Declaration
    public Task<IEnumerable<Guid>> GetDocumentKeysByAliasAsync(string alias, string? culture)
    Parameters
    Type Name Description
    string alias

    The URL alias (normalized: lowercase, no leading slash).

    string culture

    The culture code (null for invariant).

    Returns
    Type Description
    Task<IEnumerable<Guid>>

    All document keys that have the specified alias, or empty if none found.

    View Source

    HasAny()

    Checks whether any aliases are cached.

    Declaration
    public bool HasAny()
    Returns
    Type Description
    bool

    true if there are any aliases in the cache; otherwise, false.

    View Source

    InitAsync(bool, CancellationToken)

    Initializes the service and ensures the alias cache is populated from the database.

    Declaration
    public Task InitAsync(bool forceEmpty, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    bool forceEmpty

    Forces an early return when we know there are no aliases (i.e. on install).

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task
    View Source

    RebuildAllAliasesAsync()

    Rebuilds all URL aliases from the database.

    Declaration
    public Task RebuildAllAliasesAsync()
    Returns
    Type Description
    Task
    Remarks

    This method clears the existing alias cache and database records, then rebuilds from the umbracoUrlAlias property values on all documents.

    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX