Interface IPublishableContentService<TContent>
Namespace: Umbraco.Cms.Core.Services
Assembly: Umbraco.Core.dll
Syntax
public interface IPublishableContentService<TContent> : IContentServiceBase<TContent>, IContentServiceBase, IService where TContent : class, IPublishableContentBase
Type Parameters
| Name | Description |
|---|---|
| TContent |
Methods
View SourceDelete(TContent, int)
Deletes content.
Declaration
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.
DeleteOfTypes(IEnumerable<int>, int)
Deletes all content of given types.
Declaration
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.
GetByIds(IEnumerable<Guid>)
Gets content.
Declaration
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. |
GetContentScheduleByContentId(Guid)
Gets publish/unpublish schedule for a content node.
Declaration
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
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
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. |
GetVersion(int)
Gets a version of content.
Declaration
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
IEnumerable<int> GetVersionIds(int id, int topRows)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The identifier of the content. |
| int | topRows | The number of top versions to get. |
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
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
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.
PerformScheduledPublish(DateTime)
Publishes and unpublishes scheduled content.
Declaration
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
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
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.
Rollback(int, int, string, int)
Rolls back the content to a specific version.
Declaration
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.
Save(TContent, int?, ContentScheduleCollection?)
Saves content.
Declaration
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
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 when a handler of either the saving or the publishing notification cancels the operation, as the publishing notification is raised before the content is persisted.
The default implementation of this method saves and publishes as two separate operations, so it retains the save when a publishing notification handler cancels. Implementations that combine the two should follow the contract described above.
Unpublish(TContent, string?, int)
Unpublishes content.
Declaration
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.