Search Results for

    Show / Hide Table of Contents
    View Source

    Class PublishableContentServiceBase<TContent>

    Base class for publishable content services.

    Inheritance
    object
    RepositoryService
    Namespace: Umbraco.Cms.Core.Services
    Assembly: Umbraco.Core.dll
    Syntax
    public abstract class PublishableContentServiceBase<TContent> : RepositoryService, IPublishableContentService<TContent>, IContentServiceBase<TContent>, IContentServiceBase, IService where TContent : class, IPublishableContentBase
    Type Parameters
    Name Description
    TContent

    The type of content managed by the concrete implementation.

    Remarks

    A few methods here are currently only used by the ContentService, not by the ElementService. We will keep them here all the same for two reasons:

    1. As the Elements feature evolves, they might be needed eventually.
    2. The more this base class aligns with the previous versions of the ContentService, the easier forward merging will be.

    The service interfaces do not expose these methods unless they're needed, so they're only visible on the concrete implementations.

    Constructors

    View Source

    PublishableContentServiceBase(ICoreScopeProvider, ILoggerFactory, IEventMessagesFactory, IAuditService, IContentTypeRepository, IPublishableContentRepository<TContent>, ILanguageRepository, Lazy<IPropertyValidationService>, ICultureImpactFactory, IUserIdKeyResolver, PropertyEditorCollection, IIdKeyMap)

    Declaration
    protected PublishableContentServiceBase(ICoreScopeProvider provider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IAuditService auditService, IContentTypeRepository contentTypeRepository, IPublishableContentRepository<TContent> contentRepository, ILanguageRepository languageRepository, Lazy<IPropertyValidationService> propertyValidationService, ICultureImpactFactory cultureImpactFactory, IUserIdKeyResolver userIdKeyResolver, PropertyEditorCollection propertyEditorCollection, IIdKeyMap idKeyMap)
    Parameters
    Type Name Description
    ICoreScopeProvider provider
    ILoggerFactory loggerFactory
    IEventMessagesFactory eventMessagesFactory
    IAuditService auditService
    IContentTypeRepository contentTypeRepository
    IPublishableContentRepository<TContent> contentRepository
    ILanguageRepository languageRepository
    Lazy<IPropertyValidationService> propertyValidationService
    ICultureImpactFactory cultureImpactFactory
    IUserIdKeyResolver userIdKeyResolver
    PropertyEditorCollection propertyEditorCollection
    IIdKeyMap idKeyMap

    Properties

    View Source

    ContentObjectType

    Declaration
    protected abstract UmbracoObjectTypes ContentObjectType { get; }
    Property Value
    Type Description
    UmbracoObjectTypes
    View Source

    Logger

    Declaration
    protected abstract ILogger<PublishableContentServiceBase<TContent>> Logger { get; }
    Property Value
    Type Description
    ILogger<PublishableContentServiceBase<TContent>>
    View Source

    ReadLockIds

    Declaration
    protected abstract int[] ReadLockIds { get; }
    Property Value
    Type Description
    int[]
    View Source

    SupportsBranchPublishing

    Declaration
    protected abstract bool SupportsBranchPublishing { get; }
    Property Value
    Type Description
    bool
    View Source

    WriteLockIds

    Declaration
    protected abstract int[] WriteLockIds { get; }
    Property Value
    Type Description
    int[]

    Methods

    View Source

    Audit(AuditType, int, int, string?, string?)

    Declaration
    protected void Audit(AuditType type, int userId, int objectId, string? message = null, string? parameters = null)
    Parameters
    Type Name Description
    AuditType type
    int userId
    int objectId
    string message
    string parameters
    View Source

    AuditAsync(AuditType, int, int, string?, string?)

    Declaration
    protected Task AuditAsync(AuditType type, int userId, int objectId, string? message = null, string? parameters = null)
    Parameters
    Type Name Description
    AuditType type
    int userId
    int objectId
    string message
    string parameters
    Returns
    Type Description
    Task
    View Source

    BuildCultureMap(TContent, IEnumerable<string>?)

    Builds the per-item culture map carried on the notifications, keyed by item Key.

    Declaration
    protected static Dictionary<Guid, IReadOnlyCollection<string>>? BuildCultureMap(TContent content, IEnumerable<string>? cultures)
    Parameters
    Type Name Description
    TContent content

    The item the cultures belong to.

    IEnumerable<string> cultures

    The affected cultures. A null value means the category of change does not apply to this notification, so the map is null; a non-null-but-empty value means the change was tracked but affected no cultures for this item, so a present-but-empty map is returned rather than conflating that with "not tracked".

    Returns
    Type Description
    Dictionary<Guid, IReadOnlyCollection<string>>

    The per-item culture map, or null when cultures is null.

    Remarks

    Persisting the entity resets its change tracking, so the cultures are captured here when the notification is raised, because a handler cannot recompute them from the entity afterwards. ToArray() takes a copy so the notification holds a stable snapshot: some callers pass a live view over the entity's own collection (e.g. PublishedCultures) that would otherwise change as the entity is mutated.

    View Source

    CheckDataIntegrity(ContentDataIntegrityReportOptions)

    Checks the data integrity of the content tree and optionally fixes issues.

    Declaration
    public abstract ContentDataIntegrityReport CheckDataIntegrity(ContentDataIntegrityReportOptions options)
    Parameters
    Type Name Description
    ContentDataIntegrityReportOptions options

    The options for the data integrity check.

    Returns
    Type Description
    ContentDataIntegrityReport

    A ContentDataIntegrityReport containing the results of the integrity check.

    View Source

    CheckDataIntegrity(ContentDataIntegrityReportOptions, Action<ICoreScope>)

    Declaration
    protected ContentDataIntegrityReport CheckDataIntegrity(ContentDataIntegrityReportOptions options, Action<ICoreScope> notifyIssuesFixed)
    Parameters
    Type Name Description
    ContentDataIntegrityReportOptions options
    Action<ICoreScope> notifyIssuesFixed
    Returns
    Type Description
    ContentDataIntegrityReport
    View Source

    CommitContentChanges(ICoreScope, TContent, EventMessages, IReadOnlyCollection<ILanguage>, IDictionary<string, object?>?, int)

    Declaration
    protected virtual PublishResult CommitContentChanges(ICoreScope scope, TContent content, EventMessages eventMessages, IReadOnlyCollection<ILanguage> allLangs, IDictionary<string, object?>? notificationState, int userId)
    Parameters
    Type Name Description
    ICoreScope scope
    TContent content
    EventMessages eventMessages
    IReadOnlyCollection<ILanguage> allLangs
    IDictionary<string, object> notificationState
    int userId
    Returns
    Type Description
    PublishResult
    View Source

    CommitContentChangesInternal(ICoreScope, TContent, EventMessages, IReadOnlyCollection<ILanguage>, IDictionary<string, object?>?, int, bool, bool)

    Handles a lot of business logic cases for how the content should be persisted

    Declaration
    protected PublishResult CommitContentChangesInternal(ICoreScope scope, TContent content, EventMessages eventMessages, IReadOnlyCollection<ILanguage> allLangs, IDictionary<string, object?>? notificationState, int userId, bool branchOne = false, bool branchRoot = false)
    Parameters
    Type Name Description
    ICoreScope scope
    TContent content
    EventMessages eventMessages
    IReadOnlyCollection<ILanguage> allLangs
    IDictionary<string, object> notificationState
    int userId
    bool branchOne
    bool branchRoot
    Returns
    Type Description
    PublishResult
    Remarks

    Business logic cases such: as unpublishing a mandatory culture, or unpublishing the last culture, checking for pending scheduled publishing, etc... is dealt with in this method. There is quite a lot of cases to take into account along with logic that needs to deal with scheduled saving/publishing, branch saving/publishing, etc...

    View Source

    Count(string?)

    Gets the count of all TContent items.

    Declaration
    public int Count(string? contentTypeAlias = null)
    Parameters
    Type Name Description
    string contentTypeAlias

    The optional content type alias to filter by.

    Returns
    Type Description
    int

    The count of content items.

    View Source

    CountChildren(int, string?)

    Gets the count of child TContent items under a specified parent.

    Declaration
    public int CountChildren(int parentId, string? contentTypeAlias = null)
    Parameters
    Type Name Description
    int parentId

    The ID of the parent content.

    string contentTypeAlias

    The optional content type alias to filter by.

    Returns
    Type Description
    int

    The count of child content items.

    View Source

    CountDescendants(int, string?)

    Gets the count of descendant TContent items under a specified parent.

    Declaration
    public int CountDescendants(int parentId, string? contentTypeAlias = null)
    Parameters
    Type Name Description
    int parentId

    The ID of the parent content.

    string contentTypeAlias

    The optional content type alias to filter by.

    Returns
    Type Description
    int

    The count of descendant content items.

    View Source

    CountPublished(string?)

    Gets the count of published IContent items.

    Declaration
    public int CountPublished(string? contentTypeAlias = null)
    Parameters
    Type Name Description
    string contentTypeAlias

    The optional content type alias to filter by.

    Returns
    Type Description
    int

    The count of published content items.

    View Source

    Delete(TContent, int)

    Deletes content.

    Declaration
    public OperationResult Delete(TContent content, int userId = -1)
    Parameters
    Type Name Description
    TContent content

    The content to delete.

    int userId

    The identifier of the user performing the action.

    Returns
    Type Description
    OperationResult

    The operation result.

    Remarks

    This method will also delete associated media files, child content and possibly associated domains.

    This method entirely clears the content from the database.

    View Source

    DeleteLocked(ICoreScope, TContent, EventMessages)

    Declaration
    protected abstract void DeleteLocked(ICoreScope scope, TContent content, EventMessages evtMsgs)
    Parameters
    Type Name Description
    ICoreScope scope
    TContent content
    EventMessages evtMsgs
    View Source

    DeleteOfTypes(IEnumerable<int>, int)

    Deletes all content of given types.

    Declaration
    public abstract void DeleteOfTypes(IEnumerable<int> contentTypeIds, int userId = -1)
    Parameters
    Type Name Description
    IEnumerable<int> contentTypeIds

    The content type identifiers.

    int userId

    The identifier of the user performing the action.

    Remarks

    All non-deleted descendants of the deleted content is moved to the recycle bin.

    This operation is potentially dangerous and expensive.

    View Source

    DeleteVersion(int, int, bool, int)

    Permanently deletes specific version(s) from an TContent object. This method will never delete the latest version of a content item.

    Declaration
    public void DeleteVersion(int id, int versionId, bool deletePriorVersions, int userId = -1)
    Parameters
    Type Name Description
    int id

    Id of the TContent object to delete a version from

    int versionId

    Id of the version to delete

    bool deletePriorVersions

    Boolean indicating whether to delete versions prior to the versionId

    int userId

    Optional Id of the User deleting versions of a Content object

    View Source

    DeleteVersions(int, DateTime, int)

    Permanently deletes versions from an TContent object prior to a specific date. This method will never delete the latest version of a content item.

    Declaration
    public void DeleteVersions(int id, DateTime versionDate, int userId = -1)
    Parameters
    Type Name Description
    int id

    Id of the TContent object to delete versions from

    DateTime versionDate

    Latest version date

    int userId

    Optional Id of the User deleting versions of a Content object

    View Source

    DeletingNotification(TContent, EventMessages)

    Declaration
    protected abstract DeletingNotification<TContent> DeletingNotification(TContent content, EventMessages eventMessages)
    Parameters
    Type Name Description
    TContent content
    EventMessages eventMessages
    Returns
    Type Description
    DeletingNotification<TContent>
    View Source

    GetById(Guid)

    Gets a content item by its unique identifier.

    Declaration
    public TContent? GetById(Guid key)
    Parameters
    Type Name Description
    Guid key

    The unique identifier of the content item.

    Returns
    Type Description
    TContent

    The content item, or null if not found.

    View Source

    GetById(int)

    Gets an TContent object by Id

    Declaration
    public TContent? GetById(int id)
    Parameters
    Type Name Description
    int id

    Id of the Content to retrieve

    Returns
    Type Description
    TContent

    TContent

    View Source

    GetByIds(IEnumerable<Guid>)

    Gets content.

    Declaration
    public IEnumerable<TContent> GetByIds(IEnumerable<Guid> ids)
    Parameters
    Type Name Description
    IEnumerable<Guid> ids

    The unique identifiers of the content.

    Returns
    Type Description
    IEnumerable<TContent>

    The content.

    View Source

    GetByIds(IEnumerable<int>)

    Gets an TContent object by Id

    Declaration
    public IEnumerable<TContent> GetByIds(IEnumerable<int> ids)
    Parameters
    Type Name Description
    IEnumerable<int> ids

    Ids of the Content to retrieve

    Returns
    Type Description
    IEnumerable<TContent>

    TContent

    View Source

    GetContentForExpiration(DateTime)

    Gets content having an expiration date before (lower than, or equal to) a specified date.

    Declaration
    public IEnumerable<TContent> GetContentForExpiration(DateTime date)
    Parameters
    Type Name Description
    DateTime date
    Returns
    Type Description
    IEnumerable<TContent>

    An Enumerable list of TContent objects

    Remarks

    The content returned from this method may be culture variant, in which case you can use GetStatus(IPublishableContentBase, ContentScheduleCollection, string?) to get the status for a specific culture.

    View Source

    GetContentForRelease(DateTime)

    Gets content having a release date before (lower than, or equal to) a specified date.

    Declaration
    public IEnumerable<TContent> GetContentForRelease(DateTime date)
    Parameters
    Type Name Description
    DateTime date
    Returns
    Type Description
    IEnumerable<TContent>

    An Enumerable list of TContent objects.

    Remarks

    The content returned from this method may be culture variant, in which case you can use GetStatus(IPublishableContentBase, ContentScheduleCollection, string?) to get the status for a specific culture.

    View Source

    GetContentScheduleByContentId(Guid)

    Gets publish/unpublish schedule for a content node.

    Declaration
    public ContentScheduleCollection GetContentScheduleByContentId(Guid contentId)
    Parameters
    Type Name Description
    Guid contentId

    The unique identifier of the content to load schedule for.

    Returns
    Type Description
    ContentScheduleCollection

    The ContentScheduleCollection.

    View Source

    GetContentScheduleByContentId(int)

    Gets publish/unpublish schedule for a content node.

    Declaration
    public ContentScheduleCollection GetContentScheduleByContentId(int contentId)
    Parameters
    Type Name Description
    int contentId

    The identifier of the content to load schedule for.

    Returns
    Type Description
    ContentScheduleCollection

    The ContentScheduleCollection.

    View Source

    GetContentSchedulesByKeys(Guid[])

    Gets a dictionary of content keys and their matching content schedules.

    Declaration
    public IDictionary<Guid, IEnumerable<ContentSchedule>> GetContentSchedulesByKeys(Guid[] keys)
    Parameters
    Type Name Description
    Guid[] keys

    The content keys.

    Returns
    Type Description
    IDictionary<Guid, IEnumerable<ContentSchedule>>

    A dictionary with a content key and an IEnumerable of matching ContentSchedules.

    View Source

    GetContentType(string)

    Declaration
    protected IContentType GetContentType(string contentTypeAlias)
    Parameters
    Type Name Description
    string contentTypeAlias
    Returns
    Type Description
    IContentType
    View Source

    GetLanguageDetailsForAuditEntry(IEnumerable<string>)

    Declaration
    protected string GetLanguageDetailsForAuditEntry(IEnumerable<string> affectedCultures)
    Parameters
    Type Name Description
    IEnumerable<string> affectedCultures
    Returns
    Type Description
    string
    View Source

    GetLanguageDetailsForAuditEntry(IEnumerable<ILanguage>, IEnumerable<string>)

    Declaration
    protected static string GetLanguageDetailsForAuditEntry(IEnumerable<ILanguage> languages, IEnumerable<string> affectedCultures)
    Parameters
    Type Name Description
    IEnumerable<ILanguage> languages
    IEnumerable<string> affectedCultures
    Returns
    Type Description
    string
    View Source

    GetPagedOfType(int, long, int, out long, IQuery<TContent>?, Ordering?)

    Declaration
    public IEnumerable<TContent> GetPagedOfType(int contentTypeId, long pageIndex, int pageSize, out long totalRecords, IQuery<TContent>? filter = null, Ordering? ordering = null)
    Parameters
    Type Name Description
    int contentTypeId
    long pageIndex
    int pageSize
    long totalRecords
    IQuery<TContent> filter
    Ordering ordering
    Returns
    Type Description
    IEnumerable<TContent>
    View Source

    GetPagedOfTypes(int[], long, int, out long, IQuery<TContent>?, Ordering?)

    Declaration
    public IEnumerable<TContent> GetPagedOfTypes(int[] contentTypeIds, long pageIndex, int pageSize, out long totalRecords, IQuery<TContent>? filter, Ordering? ordering = null)
    Parameters
    Type Name Description
    int[] contentTypeIds
    long pageIndex
    int pageSize
    long totalRecords
    IQuery<TContent> filter
    Ordering ordering
    Returns
    Type Description
    IEnumerable<TContent>
    View Source

    GetParent(TContent?)

    Gets the parent of the current content as an TContent item.

    Declaration
    public TContent? GetParent(TContent? content)
    Parameters
    Type Name Description
    TContent content

    TContent to retrieve the parent from

    Returns
    Type Description
    TContent

    Parent TContent object

    View Source

    GetVersion(int)

    Gets a version of content.

    Declaration
    public TContent? GetVersion(int versionId)
    Parameters
    Type Name Description
    int versionId

    The version identifier.

    Returns
    Type Description
    TContent

    The content version, or null if not found.

    View Source

    GetVersionIds(int, int)

    Gets top versions of content.

    Declaration
    public IEnumerable<int> GetVersionIds(int id, int maxRows)
    Parameters
    Type Name Description
    int id

    The identifier of the content.

    int maxRows
    Returns
    Type Description
    IEnumerable<int>

    The version identifiers.

    Remarks

    Versions are ordered with current first, then most recent first.

    View Source

    GetVersions(int)

    Gets all versions of content.

    Declaration
    public IEnumerable<TContent> GetVersions(int id)
    Parameters
    Type Name Description
    int id

    The identifier of the content.

    Returns
    Type Description
    IEnumerable<TContent>

    The content versions.

    Remarks

    Versions are ordered with current first, then most recent first.

    View Source

    GetVersionsSlim(int, int, int)

    Gets all versions of content.

    Declaration
    public IEnumerable<TContent> GetVersionsSlim(int id, int skip, int take)
    Parameters
    Type Name Description
    int id

    The identifier of the content.

    int skip

    The number of versions to skip.

    int take

    The number of versions to take.

    Returns
    Type Description
    IEnumerable<TContent>

    The content versions.

    Remarks

    Versions are ordered with current first, then most recent first.

    View Source

    HasChildren(int)

    Checks whether an TContent item has any children

    Declaration
    public bool HasChildren(int id)
    Parameters
    Type Name Description
    int id

    Id of the TContent

    Returns
    Type Description
    bool

    True if the content has any children otherwise False

    View Source

    HasUnsavedChanges(TContent)

    Declaration
    protected static bool HasUnsavedChanges(TContent content)
    Parameters
    Type Name Description
    TContent content
    Returns
    Type Description
    bool
    View Source

    IsDefaultCulture(IReadOnlyCollection<ILanguage>?, string)

    Declaration
    protected static bool IsDefaultCulture(IReadOnlyCollection<ILanguage>? langs, string culture)
    Parameters
    Type Name Description
    IReadOnlyCollection<ILanguage> langs
    string culture
    Returns
    Type Description
    bool
    View Source

    IsPathPublished(TContent?)

    Checks if the TContent and all its ancestors are published.

    Declaration
    public bool IsPathPublished(TContent? content)
    Parameters
    Type Name Description
    TContent content

    The content to check.

    Returns
    Type Description
    bool

    true if the content and all its ancestors are published; otherwise, false.

    View Source

    PerformScheduledPublish(DateTime)

    Publishes and unpublishes scheduled content.

    Declaration
    public IEnumerable<PublishResult> PerformScheduledPublish(DateTime date)
    Parameters
    Type Name Description
    DateTime date

    The date to use for determining scheduled actions.

    Returns
    Type Description
    IEnumerable<PublishResult>

    The publish results.

    View Source

    PersistContentSchedule(IPublishableContentBase, ContentScheduleCollection)

    Persists publish/unpublish schedule for a content node.

    Declaration
    public void PersistContentSchedule(IPublishableContentBase content, ContentScheduleCollection contentSchedule)
    Parameters
    Type Name Description
    IPublishableContentBase content

    The content to persist the schedule for.

    ContentScheduleCollection contentSchedule

    The content schedule collection.

    View Source

    Publish(TContent, string[], int)

    Publishes content

    Declaration
    public PublishResult Publish(TContent content, string[] cultures, int userId = -1)
    Parameters
    Type Name Description
    TContent content

    The content to publish.

    string[] cultures

    The cultures to publish.

    int userId

    The identifier of the user performing the action.

    Returns
    Type Description
    PublishResult
    Remarks

    When a culture is being published, it includes all varying values along with all invariant values.

    Wildcards (*) can be used as culture identifier to publish all cultures.

    An empty array (or a wildcard) can be passed for culture invariant content.

    View Source

    PublishedNotification(IEnumerable<TContent>, EventMessages)

    Declaration
    protected abstract IStatefulNotification PublishedNotification(IEnumerable<TContent> content, EventMessages eventMessages)
    Parameters
    Type Name Description
    IEnumerable<TContent> content
    EventMessages eventMessages
    Returns
    Type Description
    IStatefulNotification
    View Source

    PublishedNotification(TContent, EventMessages)

    Declaration
    protected abstract IStatefulNotification PublishedNotification(TContent content, EventMessages eventMessages)
    Parameters
    Type Name Description
    TContent content
    EventMessages eventMessages
    Returns
    Type Description
    IStatefulNotification
    View Source

    PublishedNotification(TContent, EventMessages, IReadOnlyDictionary<Guid, IReadOnlyCollection<string>>?, IReadOnlyDictionary<Guid, IReadOnlyCollection<string>>?)

    Creates the "published" notification for a single item, carrying the cultures that were published and unpublished by the operation.

    Declaration
    protected virtual IStatefulNotification PublishedNotification(TContent content, EventMessages eventMessages, IReadOnlyDictionary<Guid, IReadOnlyCollection<string>>? publishedCultures, IReadOnlyDictionary<Guid, IReadOnlyCollection<string>>? unpublishedCultures)
    Parameters
    Type Name Description
    TContent content

    The item that was published.

    EventMessages eventMessages

    The event messages collection.

    IReadOnlyDictionary<Guid, IReadOnlyCollection<string>> publishedCultures

    The cultures that were published, keyed by item key, or null if not tracked.

    IReadOnlyDictionary<Guid, IReadOnlyCollection<string>> unpublishedCultures

    The cultures that were unpublished as part of the publish, keyed by item key, or null if not applicable.

    Returns
    Type Description
    IStatefulNotification

    The notification to publish.

    Remarks

    Defaults to the culture-agnostic PublishedNotification(TContent, EventMessages) overload so external subclasses keep working; ContentService and ElementService override this to carry the maps on the concrete notification. Unpublishing an individual culture is performed as a publish, so the unpublished cultures are reported here rather than on the "unpublished" notification.

    View Source

    PublishingNotification(TContent, EventMessages)

    Declaration
    protected abstract CancelableEnumerableObjectNotification<TContent> PublishingNotification(TContent content, EventMessages eventMessages)
    Parameters
    Type Name Description
    TContent content
    EventMessages eventMessages
    Returns
    Type Description
    CancelableEnumerableObjectNotification<TContent>
    View Source

    Rollback(int, int, string, int)

    Rolls back the content to a specific version.

    Declaration
    public OperationResult Rollback(int id, int versionId, string culture = "*", int userId = -1)
    Parameters
    Type Name Description
    int id

    The id of the content node.

    int versionId

    The version id to roll back to.

    string culture

    An optional culture to roll back.

    int userId

    The identifier of the user who is performing the roll back.

    Returns
    Type Description
    OperationResult
    Remarks

    When no culture is specified, all cultures are rolled back.

    View Source

    RolledBackNotification(TContent, EventMessages)

    Declaration
    protected abstract RolledBackNotification<TContent> RolledBackNotification(TContent target, EventMessages messages)
    Parameters
    Type Name Description
    TContent target
    EventMessages messages
    Returns
    Type Description
    RolledBackNotification<TContent>
    View Source

    RollingBackNotification(TContent, EventMessages)

    Declaration
    protected abstract RollingBackNotification<TContent> RollingBackNotification(TContent target, EventMessages messages)
    Parameters
    Type Name Description
    TContent target
    EventMessages messages
    Returns
    Type Description
    RollingBackNotification<TContent>
    View Source

    Save(IEnumerable<TContent>, int)

    Declaration
    public OperationResult Save(IEnumerable<TContent> contents, int userId = -1)
    Parameters
    Type Name Description
    IEnumerable<TContent> contents
    int userId
    Returns
    Type Description
    OperationResult
    View Source

    Save(TContent, int?, ContentScheduleCollection?)

    Saves content.

    Declaration
    public OperationResult Save(TContent content, int? userId = null, ContentScheduleCollection? contentSchedule = null)
    Parameters
    Type Name Description
    TContent content

    The content to save.

    int? userId

    The identifier of the user performing the action.

    ContentScheduleCollection contentSchedule

    The content schedule collection.

    Returns
    Type Description
    OperationResult

    The operation result.

    View Source

    SaveAndPublish(TContent, string[], int)

    Saves and publishes content in a single scope.

    Declaration
    public PublishResult SaveAndPublish(TContent content, string[] culturesToPublish, int userId = -1)
    Parameters
    Type Name Description
    TContent content

    The content to publish.

    string[] culturesToPublish

    The cultures to publish, or an empty array for invariant content.

    int userId

    The identifier of the user performing the action.

    Returns
    Type Description
    PublishResult

    The result of the publish operation, or a failure result if saving failed.

    Remarks

    For invariant content types, culturesToPublish must be empty; the content is saved and the invariant culture is published.

    For variant content types, only the cultures listed in culturesToPublish are published. Wildcards ("*"), nulls, whitespace and duplicate entries are not accepted. Passing an empty array saves the content without publishing any culture.

    When a culture is being published, it includes all varying values along with all invariant values.

    The save and publish run in the same scope. If publishing fails for a business reason (for example, invalid content or an expired schedule) the save still takes effect; both are skipped only when a saving notification handler cancels the operation.

    View Source

    SavedNotification(IEnumerable<TContent>, EventMessages)

    Declaration
    protected abstract SavedNotification<TContent> SavedNotification(IEnumerable<TContent> content, EventMessages eventMessages)
    Parameters
    Type Name Description
    IEnumerable<TContent> content
    EventMessages eventMessages
    Returns
    Type Description
    SavedNotification<TContent>
    View Source

    SavedNotification(IEnumerable<TContent>, EventMessages, IReadOnlyDictionary<Guid, IReadOnlyCollection<string>>?)

    Creates the "saved" notification for multiple items, carrying the cultures that were saved per item.

    Declaration
    protected virtual SavedNotification<TContent> SavedNotification(IEnumerable<TContent> content, EventMessages eventMessages, IReadOnlyDictionary<Guid, IReadOnlyCollection<string>>? savedCultures)
    Parameters
    Type Name Description
    IEnumerable<TContent> content

    The items that were saved.

    EventMessages eventMessages

    The event messages collection.

    IReadOnlyDictionary<Guid, IReadOnlyCollection<string>> savedCultures

    The cultures that were saved, keyed by item key.

    Returns
    Type Description
    SavedNotification<TContent>

    The notification to publish.

    Remarks

    Defaults to the culture-agnostic SavedNotification(IEnumerable<TContent>, EventMessages) overload so external subclasses keep working; ContentService and ElementService override this to carry the map on the concrete notification.

    View Source

    SavedNotification(TContent, EventMessages)

    Declaration
    protected abstract SavedNotification<TContent> SavedNotification(TContent content, EventMessages eventMessages)
    Parameters
    Type Name Description
    TContent content
    EventMessages eventMessages
    Returns
    Type Description
    SavedNotification<TContent>
    View Source

    SavedNotification(TContent, EventMessages, IReadOnlyDictionary<Guid, IReadOnlyCollection<string>>?)

    Creates the "saved" notification for a single item, carrying the cultures that were saved.

    Declaration
    protected virtual SavedNotification<TContent> SavedNotification(TContent content, EventMessages eventMessages, IReadOnlyDictionary<Guid, IReadOnlyCollection<string>>? savedCultures)
    Parameters
    Type Name Description
    TContent content

    The item that was saved.

    EventMessages eventMessages

    The event messages collection.

    IReadOnlyDictionary<Guid, IReadOnlyCollection<string>> savedCultures

    The cultures that were saved, keyed by item key, or null if not tracked.

    Returns
    Type Description
    SavedNotification<TContent>

    The notification to publish.

    Remarks

    Defaults to the culture-agnostic SavedNotification(TContent, EventMessages) overload so external subclasses keep working; ContentService and ElementService override this to carry the map on the concrete notification. See BuildCultureMap(TContent, IEnumerable<string>?) for why the cultures are captured at raise-time.

    View Source

    SavingNotification(IEnumerable<TContent>, EventMessages)

    Declaration
    protected abstract SavingNotification<TContent> SavingNotification(IEnumerable<TContent> content, EventMessages eventMessages)
    Parameters
    Type Name Description
    IEnumerable<TContent> content
    EventMessages eventMessages
    Returns
    Type Description
    SavingNotification<TContent>
    View Source

    SavingNotification(TContent, EventMessages)

    Declaration
    protected abstract SavingNotification<TContent> SavingNotification(TContent content, EventMessages eventMessages)
    Parameters
    Type Name Description
    TContent content
    EventMessages eventMessages
    Returns
    Type Description
    SavingNotification<TContent>
    View Source

    TreeChangeNotification(IEnumerable<TContent>, TreeChangeTypes, EventMessages)

    Declaration
    protected abstract TreeChangeNotification<TContent> TreeChangeNotification(IEnumerable<TContent> content, TreeChangeTypes changeTypes, EventMessages eventMessages)
    Parameters
    Type Name Description
    IEnumerable<TContent> content
    TreeChangeTypes changeTypes
    EventMessages eventMessages
    Returns
    Type Description
    TreeChangeNotification<TContent>
    View Source

    TreeChangeNotification(TContent, TreeChangeTypes, IEnumerable<string>?, IEnumerable<string>?, EventMessages)

    Declaration
    protected abstract TreeChangeNotification<TContent> TreeChangeNotification(TContent content, TreeChangeTypes changeTypes, IEnumerable<string>? publishedCultures, IEnumerable<string>? unpublishedCultures, EventMessages eventMessages)
    Parameters
    Type Name Description
    TContent content
    TreeChangeTypes changeTypes
    IEnumerable<string> publishedCultures
    IEnumerable<string> unpublishedCultures
    EventMessages eventMessages
    Returns
    Type Description
    TreeChangeNotification<TContent>
    View Source

    TreeChangeNotification(TContent, TreeChangeTypes, EventMessages)

    Declaration
    protected abstract TreeChangeNotification<TContent> TreeChangeNotification(TContent content, TreeChangeTypes changeTypes, EventMessages eventMessages)
    Parameters
    Type Name Description
    TContent content
    TreeChangeTypes changeTypes
    EventMessages eventMessages
    Returns
    Type Description
    TreeChangeNotification<TContent>
    View Source

    Unpublish(TContent, string?, int)

    Unpublishes content.

    Declaration
    public PublishResult Unpublish(TContent content, string? culture = "*", int userId = -1)
    Parameters
    Type Name Description
    TContent content
    string culture
    int userId
    Returns
    Type Description
    PublishResult
    Remarks

    By default, unpublishes the content as a whole, but it is possible to specify a culture to be unpublished. Depending on whether that culture is mandatory, and other cultures remain published, the content as a whole may or may not remain published.

    If the content type is variant, then culture can be either '*' or an actual culture, but neither null nor empty. If the content type is invariant, then culture can be either '*' or null or empty.

    View Source

    UnpublishedNotification(TContent, EventMessages)

    Declaration
    protected abstract IStatefulNotification UnpublishedNotification(TContent content, EventMessages eventMessages)
    Parameters
    Type Name Description
    TContent content
    EventMessages eventMessages
    Returns
    Type Description
    IStatefulNotification
    View Source

    UnpublishedNotification(TContent, EventMessages, IReadOnlyDictionary<Guid, IReadOnlyCollection<string>>?)

    Creates the "unpublished" notification for a single item, carrying the cultures that were unpublished.

    Declaration
    protected virtual IStatefulNotification UnpublishedNotification(TContent content, EventMessages eventMessages, IReadOnlyDictionary<Guid, IReadOnlyCollection<string>>? unpublishedCultures)
    Parameters
    Type Name Description
    TContent content

    The item that was unpublished.

    EventMessages eventMessages

    The event messages collection.

    IReadOnlyDictionary<Guid, IReadOnlyCollection<string>> unpublishedCultures

    The cultures that were unpublished, keyed by item key, or null if not tracked.

    Returns
    Type Description
    IStatefulNotification

    The notification to publish.

    Remarks

    Defaults to the culture-agnostic UnpublishedNotification(TContent, EventMessages) overload so external subclasses keep working; ContentService and ElementService override this to carry the map on the concrete notification. This is only raised when the item is unpublished as a whole.

    View Source

    UnpublishingNotification(TContent, EventMessages)

    Declaration
    protected abstract CancelableEnumerableObjectNotification<TContent> UnpublishingNotification(TContent content, EventMessages eventMessages)
    Parameters
    Type Name Description
    TContent content
    EventMessages eventMessages
    Returns
    Type Description
    CancelableEnumerableObjectNotification<TContent>
    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX