Class PublishableContentServiceBase<TContent>
Base class for publishable content services.
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:
- As the Elements feature evolves, they might be needed eventually.
- 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 SourcePublishableContentServiceBase(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 SourceContentObjectType
Declaration
protected abstract UmbracoObjectTypes ContentObjectType { get; }
Property Value
| Type | Description |
|---|---|
| UmbracoObjectTypes |
Logger
Declaration
protected abstract ILogger<PublishableContentServiceBase<TContent>> Logger { get; }
Property Value
| Type | Description |
|---|---|
| ILogger<PublishableContentServiceBase<TContent>> |
ReadLockIds
Declaration
protected abstract int[] ReadLockIds { get; }
Property Value
| Type | Description |
|---|---|
| int[] |
SupportsBranchPublishing
Declaration
protected abstract bool SupportsBranchPublishing { get; }
Property Value
| Type | Description |
|---|---|
| bool |
WriteLockIds
Declaration
protected abstract int[] WriteLockIds { get; }
Property Value
| Type | Description |
|---|---|
| int[] |
Methods
View SourceAudit(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 |
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 |
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 |
Returns
| Type | Description |
|---|---|
| Dictionary<Guid, IReadOnlyCollection<string>> | The per-item culture map, or |
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.
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. |
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 |
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 |
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...
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. |
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. |
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. |
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. |
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.
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 |
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.
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 |
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 |
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> |
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 |
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 |
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. |
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 |
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.
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.
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 |
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 |
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. |
GetContentType(string)
Declaration
protected IContentType GetContentType(string contentTypeAlias)
Parameters
| Type | Name | Description |
|---|---|---|
| string | contentTypeAlias |
Returns
| Type | Description |
|---|---|
| IContentType |
GetLanguageDetailsForAuditEntry(IEnumerable<string>)
Declaration
protected string GetLanguageDetailsForAuditEntry(IEnumerable<string> affectedCultures)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<string> | affectedCultures |
Returns
| Type | Description |
|---|---|
| string |
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 |
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> |
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> |
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 |
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. |
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.
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.
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.
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 |
HasUnsavedChanges(TContent)
Declaration
protected static bool HasUnsavedChanges(TContent content)
Parameters
| Type | Name | Description |
|---|---|---|
| TContent | content |
Returns
| Type | Description |
|---|---|
| bool |
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 |
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 |
|
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. |
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. |
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.
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 |
PublishedNotification(TContent, EventMessages)
Declaration
protected abstract IStatefulNotification PublishedNotification(TContent content, EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| TContent | content | |
| EventMessages | eventMessages |
Returns
| Type | Description |
|---|---|
| IStatefulNotification |
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 |
| IReadOnlyDictionary<Guid, IReadOnlyCollection<string>> | unpublishedCultures | The cultures that were unpublished as part of the publish, keyed by item key, or |
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.
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> |
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.
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> |
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> |
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 |
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. |
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.
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> |
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.
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> |
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 |
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.
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> |
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> |
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> |
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> |
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> |
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.
UnpublishedNotification(TContent, EventMessages)
Declaration
protected abstract IStatefulNotification UnpublishedNotification(TContent content, EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| TContent | content | |
| EventMessages | eventMessages |
Returns
| Type | Description |
|---|---|
| IStatefulNotification |
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 |
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.
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> |