Class ContentService
Implements the content service.
Namespace: Umbraco.Cms.Core.Services
Assembly: Umbraco.Core.dll
Syntax
public class ContentService : PublishableContentServiceBase<IContent>, IContentService, IPublishableContentService<IContent>, IContentServiceBase<IContent>, IContentServiceBase, IService
Constructors
View SourceContentService(ICoreScopeProvider, ILoggerFactory, IEventMessagesFactory, IDocumentRepository, IEntityRepository, IAuditRepository, IContentTypeRepository, IDocumentBlueprintRepository, ILanguageRepository, Lazy<IPropertyValidationService>, IShortStringHelper, ICultureImpactFactory, IUserIdKeyResolver, PropertyEditorCollection, IIdKeyMap, IOptionsMonitor<ContentSettings>, IRelationService)
Initializes a new instance of the ContentService class.
Declaration
[Obsolete("Use the non-obsolete constructor instead. Scheduled for removal in Umbraco 19.")]
public ContentService(ICoreScopeProvider provider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IDocumentRepository documentRepository, IEntityRepository entityRepository, IAuditRepository auditRepository, IContentTypeRepository contentTypeRepository, IDocumentBlueprintRepository documentBlueprintRepository, ILanguageRepository languageRepository, Lazy<IPropertyValidationService> propertyValidationService, IShortStringHelper shortStringHelper, ICultureImpactFactory cultureImpactFactory, IUserIdKeyResolver userIdKeyResolver, PropertyEditorCollection propertyEditorCollection, IIdKeyMap idKeyMap, IOptionsMonitor<ContentSettings> optionsMonitor, IRelationService relationService)
Parameters
| Type | Name | Description |
|---|---|---|
| ICoreScopeProvider | provider | The core scope provider. |
| ILoggerFactory | loggerFactory | The logger factory. |
| IEventMessagesFactory | eventMessagesFactory | The event messages factory. |
| IDocumentRepository | documentRepository | The document repository. |
| IEntityRepository | entityRepository | The entity repository. |
| IAuditRepository | auditRepository | The audit repository. |
| IContentTypeRepository | contentTypeRepository | The content type repository. |
| IDocumentBlueprintRepository | documentBlueprintRepository | The document blueprint repository. |
| ILanguageRepository | languageRepository | The language repository. |
| Lazy<IPropertyValidationService> | propertyValidationService | The property validation service. |
| IShortStringHelper | shortStringHelper | The short string helper. |
| ICultureImpactFactory | cultureImpactFactory | The culture impact factory. |
| IUserIdKeyResolver | userIdKeyResolver | The user ID key resolver. |
| PropertyEditorCollection | propertyEditorCollection | The property editor collection. |
| IIdKeyMap | idKeyMap | The ID key map. |
| IOptionsMonitor<ContentSettings> | optionsMonitor | The content settings options monitor. |
| IRelationService | relationService | The relation service. |
ContentService(ICoreScopeProvider, ILoggerFactory, IEventMessagesFactory, IDocumentRepository, IEntityRepository, IAuditRepository, IAuditService, IContentTypeRepository, IDocumentBlueprintRepository, ILanguageRepository, Lazy<IPropertyValidationService>, IShortStringHelper, ICultureImpactFactory, IUserIdKeyResolver, PropertyEditorCollection, IIdKeyMap, IOptionsMonitor<ContentSettings>, IRelationService)
Initializes a new instance of the ContentService class.
Declaration
[Obsolete("Use the non-obsolete constructor instead. Scheduled for removal in Umbraco 19.")]
public ContentService(ICoreScopeProvider provider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IDocumentRepository documentRepository, IEntityRepository entityRepository, IAuditRepository auditRepository, IAuditService auditService, IContentTypeRepository contentTypeRepository, IDocumentBlueprintRepository documentBlueprintRepository, ILanguageRepository languageRepository, Lazy<IPropertyValidationService> propertyValidationService, IShortStringHelper shortStringHelper, ICultureImpactFactory cultureImpactFactory, IUserIdKeyResolver userIdKeyResolver, PropertyEditorCollection propertyEditorCollection, IIdKeyMap idKeyMap, IOptionsMonitor<ContentSettings> optionsMonitor, IRelationService relationService)
Parameters
| Type | Name | Description |
|---|---|---|
| ICoreScopeProvider | provider | The core scope provider. |
| ILoggerFactory | loggerFactory | The logger factory. |
| IEventMessagesFactory | eventMessagesFactory | The event messages factory. |
| IDocumentRepository | documentRepository | The document repository. |
| IEntityRepository | entityRepository | The entity repository. |
| IAuditRepository | auditRepository | The audit repository. |
| IAuditService | auditService | The audit service. |
| IContentTypeRepository | contentTypeRepository | The content type repository. |
| IDocumentBlueprintRepository | documentBlueprintRepository | The document blueprint repository. |
| ILanguageRepository | languageRepository | The language repository. |
| Lazy<IPropertyValidationService> | propertyValidationService | The property validation service. |
| IShortStringHelper | shortStringHelper | The short string helper. |
| ICultureImpactFactory | cultureImpactFactory | The culture impact factory. |
| IUserIdKeyResolver | userIdKeyResolver | The user ID key resolver. |
| PropertyEditorCollection | propertyEditorCollection | The property editor collection. |
| IIdKeyMap | idKeyMap | The ID key map. |
| IOptionsMonitor<ContentSettings> | optionsMonitor | The content settings options monitor. |
| IRelationService | relationService | The relation service. |
ContentService(ICoreScopeProvider, ILoggerFactory, IEventMessagesFactory, IDocumentRepository, IEntityRepository, IAuditService, IContentTypeRepository, IDocumentBlueprintRepository, ILanguageRepository, Lazy<IPropertyValidationService>, IShortStringHelper, ICultureImpactFactory, IUserIdKeyResolver, PropertyEditorCollection, IIdKeyMap, IOptionsMonitor<ContentSettings>, IRelationService)
Initializes a new instance of the ContentService class.
Declaration
public ContentService(ICoreScopeProvider provider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IDocumentRepository documentRepository, IEntityRepository entityRepository, IAuditService auditService, IContentTypeRepository contentTypeRepository, IDocumentBlueprintRepository documentBlueprintRepository, ILanguageRepository languageRepository, Lazy<IPropertyValidationService> propertyValidationService, IShortStringHelper shortStringHelper, ICultureImpactFactory cultureImpactFactory, IUserIdKeyResolver userIdKeyResolver, PropertyEditorCollection propertyEditorCollection, IIdKeyMap idKeyMap, IOptionsMonitor<ContentSettings> optionsMonitor, IRelationService relationService)
Parameters
| Type | Name | Description |
|---|---|---|
| ICoreScopeProvider | provider | The core scope provider. |
| ILoggerFactory | loggerFactory | The logger factory. |
| IEventMessagesFactory | eventMessagesFactory | The event messages factory. |
| IDocumentRepository | documentRepository | The document repository. |
| IEntityRepository | entityRepository | The entity repository. |
| IAuditService | auditService | The audit service. |
| IContentTypeRepository | contentTypeRepository | The content type repository. |
| IDocumentBlueprintRepository | documentBlueprintRepository | The document blueprint repository. |
| ILanguageRepository | languageRepository | The language repository. |
| Lazy<IPropertyValidationService> | propertyValidationService | The property validation service. |
| IShortStringHelper | shortStringHelper | The short string helper. |
| ICultureImpactFactory | cultureImpactFactory | The culture impact factory. |
| IUserIdKeyResolver | userIdKeyResolver | The user ID key resolver. |
| PropertyEditorCollection | propertyEditorCollection | The property editor collection. |
| IIdKeyMap | idKeyMap | The ID key map. |
| IOptionsMonitor<ContentSettings> | optionsMonitor | The content settings options monitor. |
| IRelationService | relationService | The relation service. |
Properties
View SourceContentObjectType
Declaration
protected override UmbracoObjectTypes ContentObjectType { get; }
Property Value
| Type | Description |
|---|---|
| UmbracoObjectTypes |
Logger
Declaration
protected override ILogger<ContentService> Logger { get; }
Property Value
| Type | Description |
|---|---|
| ILogger<ContentService> |
ReadLockIds
Declaration
protected override int[] ReadLockIds { get; }
Property Value
| Type | Description |
|---|---|
| int[] |
SupportsBranchPublishing
Declaration
protected override bool SupportsBranchPublishing { get; }
Property Value
| Type | Description |
|---|---|
| bool |
WriteLockIds
Declaration
protected override int[] WriteLockIds { get; }
Property Value
| Type | Description |
|---|---|
| int[] |
Methods
View SourceCheckDataIntegrity(ContentDataIntegrityReportOptions)
Checks the data integrity of the content tree and optionally fixes issues.
Declaration
public override 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. |
Copy(IContent, int, bool, bool, int)
Copies an IContent object by creating a new Content object of the same type and copies all data from the current to the new copy which is returned.
Declaration
public IContent? Copy(IContent content, int parentId, bool relateToOriginal, bool recursive, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The IContent to copy |
| int | parentId | Id of the Content's new Parent |
| bool | relateToOriginal | Boolean indicating whether the copy should be related to the original |
| bool | recursive | A value indicating whether to recursively copy children. |
| int | userId | Optional Id of the User copying the Content |
Returns
| Type | Description |
|---|---|
| IContent | The newly created IContent object |
Copy(IContent, int, bool, int)
Copies an IContent object by creating a new Content object of the same type and copies all data from the current to the new copy which is returned. Recursively copies all children.
Declaration
public IContent? Copy(IContent content, int parentId, bool relateToOriginal, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The IContent to copy |
| int | parentId | Id of the Content's new Parent |
| bool | relateToOriginal | Boolean indicating whether the copy should be related to the original |
| int | userId | Optional Id of the User copying the Content |
Returns
| Type | Description |
|---|---|
| IContent | The newly created IContent object |
Create(string, Guid, string, int)
Creates an IContent object using the alias of the IContentType that this Content should based on.
Declaration
public IContent Create(string name, Guid parentId, string contentTypeAlias, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name of the Content object |
| Guid | parentId | Id of Parent for the new Content |
| string | contentTypeAlias | Alias of the IContentType |
| int | userId | Optional id of the user creating the content |
Returns
| Type | Description |
|---|---|
| IContent |
Remarks
Note that using this method will simply return a new IContent without any identity as it has not yet been persisted. It is intended as a shortcut to creating new content objects that does not invoke a save operation against the database.
Create(string, int, string, int)
Creates an IContent object of a specified content type.
Declaration
public IContent Create(string name, int parentId, string contentTypeAlias, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the content object. |
| int | parentId | The identifier of the parent, or -1. |
| string | contentTypeAlias | The alias of the content type. |
| int | userId | The optional id of the user creating the content. |
Returns
| Type | Description |
|---|---|
| IContent | The content object. |
Remarks
This method simply returns a new, non-persisted, IContent without any identity. It is intended as a shortcut to creating new content objects that does not invoke a save operation against the database.
Create(string, int, IContentType, int)
Creates an IContent object of a specified content type.
Declaration
public IContent Create(string name, int parentId, IContentType contentType, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the content object. |
| int | parentId | The identifier of the parent, or -1. |
| IContentType | contentType | The content type of the content |
| int | userId | The optional id of the user creating the content. |
Returns
| Type | Description |
|---|---|
| IContent | The content object. |
Remarks
This method simply returns a new, non-persisted, IContent without any identity. It is intended as a shortcut to creating new content objects that does not invoke a save operation against the database.
Create(string, IContent?, string, int)
Creates an IContent object of a specified content type, under a parent.
Declaration
public IContent Create(string name, IContent? parent, string contentTypeAlias, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the content object. |
| IContent | parent | The parent content object. |
| string | contentTypeAlias | The alias of the content type. |
| int | userId | The optional id of the user creating the content. |
Returns
| Type | Description |
|---|---|
| IContent | The content object. |
Remarks
This method simply returns a new, non-persisted, IContent without any identity. It is intended as a shortcut to creating new content objects that does not invoke a save operation against the database.
CreateAndSave(string, int, string, int)
Creates an IContent object of a specified content type.
Declaration
public IContent CreateAndSave(string name, int parentId, string contentTypeAlias, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the content object. |
| int | parentId | The identifier of the parent, or -1. |
| string | contentTypeAlias | The alias of the content type. |
| int | userId | The optional id of the user creating the content. |
Returns
| Type | Description |
|---|---|
| IContent | The content object. |
Remarks
This method returns a new, persisted, IContent with an identity.
CreateAndSave(string, IContent, string, int)
Creates an IContent object of a specified content type, under a parent.
Declaration
public IContent CreateAndSave(string name, IContent parent, string contentTypeAlias, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the content object. |
| IContent | parent | The parent content object. |
| string | contentTypeAlias | The alias of the content type. |
| int | userId | The optional id of the user creating the content. |
Returns
| Type | Description |
|---|---|
| IContent | The content object. |
Remarks
This method returns a new, persisted, IContent with an identity.
CreateBlueprintFromContent(IContent, string, int)
Creates a new IContent from a blueprint.
Declaration
public IContent CreateBlueprintFromContent(IContent blueprint, string name, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | blueprint | The blueprint to create the content from. |
| string | name | The name for the new content. |
| int | userId | The optional ID of the user creating the content. |
Returns
| Type | Description |
|---|---|
| IContent | The newly created IContent based on the blueprint. |
DeleteBlueprint(IContent, int)
Deletes a content blueprint.
Declaration
public void DeleteBlueprint(IContent content, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The blueprint content to delete. |
| int | userId | The optional ID of the user deleting the blueprint. |
DeleteBlueprintsOfType(int, int)
Deletes all content blueprints of the specified content type ID.
Declaration
public void DeleteBlueprintsOfType(int contentTypeId, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| int | contentTypeId | The content type ID whose blueprints should be deleted. |
| int | userId | The optional ID of the user deleting the blueprints. |
DeleteBlueprintsOfTypes(IEnumerable<int>, int)
Deletes all content blueprints of the specified content type IDs.
Declaration
public void DeleteBlueprintsOfTypes(IEnumerable<int> contentTypeIds, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<int> | contentTypeIds | The content type IDs whose blueprints should be deleted. |
| int | userId | The optional ID of the user deleting the blueprints. |
DeleteLocked(ICoreScope, IContent, EventMessages)
Declaration
protected override void DeleteLocked(ICoreScope scope, IContent content, EventMessages evtMsgs)
Parameters
| Type | Name | Description |
|---|---|---|
| ICoreScope | scope | |
| IContent | content | |
| EventMessages | evtMsgs |
DeleteOfType(int, int)
Deletes all content items of specified type. All children of deleted content item is moved to Recycle Bin.
Declaration
public void DeleteOfType(int contentTypeId, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| int | contentTypeId | Id of the IContentType |
| int | userId | Optional id of the user deleting the media |
Remarks
This needs extra care and attention as its potentially a dangerous and extensive operation
DeleteOfTypes(IEnumerable<int>, int)
Deletes all content of specified type. All children of deleted content is moved to Recycle Bin.
Declaration
public override void DeleteOfTypes(IEnumerable<int> contentTypeIds, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<int> | contentTypeIds | Id of the IContentType |
| int | userId | Optional Id of the user issuing the delete operation |
Remarks
This needs extra care and attention as its potentially a dangerous and extensive operation.
Deletes content items of the specified type, and only that type. Does *not* handle content types inheritance and compositions, which need to be managed outside of this method.
DeletingNotification(IContent, EventMessages)
Declaration
protected override DeletingNotification<IContent> DeletingNotification(IContent content, EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | |
| EventMessages | eventMessages |
Returns
| Type | Description |
|---|---|
| DeletingNotification<IContent> |
EmptyRecycleBin(int)
Empties the Recycle Bin by deleting all IContent that resides in the bin
Declaration
public OperationResult EmptyRecycleBin(int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| int | userId |
Returns
| Type | Description |
|---|---|
| OperationResult |
EmptyRecycleBinAsync(Guid)
Empties the Recycle Bin by deleting all IContent items that reside in the bin asynchronously.
Declaration
public Task<OperationResult> EmptyRecycleBinAsync(Guid userId)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | userId | The unique key of the user performing the operation. |
Returns
| Type | Description |
|---|---|
| Task<OperationResult> | An OperationResult indicating the result of the operation. |
GetAncestors(int)
Gets a collection of IContent objects, which are ancestors of the current content.
Declaration
public IEnumerable<IContent> GetAncestors(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | Id of the IContent to retrieve ancestors for |
Returns
| Type | Description |
|---|---|
| IEnumerable<IContent> | An Enumerable list of IContent objects |
GetAncestors(IContent)
Gets a collection of IContent objects, which are ancestors of the current content.
Declaration
public IEnumerable<IContent> GetAncestors(IContent content)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | IContent to retrieve ancestors for |
Returns
| Type | Description |
|---|---|
| IEnumerable<IContent> | An Enumerable list of IContent objects |
GetBlueprintById(Guid)
Gets a content blueprint by its unique key.
Declaration
public IContent? GetBlueprintById(Guid id)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | id | The unique key of the blueprint to retrieve. |
Returns
| Type | Description |
|---|---|
| IContent | The IContent blueprint, or |
GetBlueprintById(int)
Gets a content blueprint by its integer ID.
Declaration
public IContent? GetBlueprintById(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The ID of the blueprint to retrieve. |
Returns
| Type | Description |
|---|---|
| IContent | The IContent blueprint, or |
GetBlueprintsForContentTypes(params int[])
Gets all content blueprints for the specified content type IDs.
Declaration
public IEnumerable<IContent> GetBlueprintsForContentTypes(params int[] contentTypeId)
Parameters
| Type | Name | Description |
|---|---|---|
| int[] | contentTypeId | The content type IDs to get blueprints for, or empty to get all blueprints. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IContent> | A collection of IContent blueprints. |
GetByLevel(int)
Gets a collection of IContent objects by Level
Declaration
public IEnumerable<IContent> GetByLevel(int level)
Parameters
| Type | Name | Description |
|---|---|---|
| int | level | The level to retrieve Content from |
Returns
| Type | Description |
|---|---|
| IEnumerable<IContent> | An Enumerable list of IContent objects |
Remarks
Contrary to most methods, this method filters out trashed content items.
GetContentSchedulesByIds(Guid[])
Gets a dictionary of content Ids and their matching content schedules.
Declaration
[Obsolete("Use GetContentSchedulesByKeys instead. Scheduled for removal in Umbraco 19.")]
public IDictionary<int, IEnumerable<ContentSchedule>> GetContentSchedulesByIds(Guid[] keys)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid[] | keys | The content keys. |
Returns
| Type | Description |
|---|---|
| IDictionary<int, IEnumerable<ContentSchedule>> | A dictionary with a node Id and an IEnumerable of matching ContentSchedules. |
GetPagedChildren(int, long, int, out long, string[]?, IQuery<IContent>?, Ordering?, bool)
Gets child documents of a parent with optional property filtering.
Declaration
public IEnumerable<IContent> GetPagedChildren(int id, long pageIndex, int pageSize, out long totalChildren, string[]? propertyAliases, IQuery<IContent>? filter, Ordering? ordering, bool loadTemplates = true)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The parent identifier. |
| long | pageIndex | The page number. |
| int | pageSize | The page size. |
| long | totalChildren | |
| string[] | propertyAliases | The property aliases to load. If null, all properties are loaded. If empty array, no custom properties are loaded. |
| IQuery<IContent> | filter | Query filter. |
| Ordering | ordering | Ordering infos. |
| bool | loadTemplates | Whether to load templates. Set to false for performance optimization when templates are not needed (e.g., collection views). Default is true. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IContent> |
GetPagedChildren(int, long, int, out long, IQuery<IContent>?, Ordering?)
Gets child documents of a parent.
Declaration
[Obsolete("Please use the method overload with all parameters. Scheduled for removal in Umbraco 19.")]
public IEnumerable<IContent> GetPagedChildren(int id, long pageIndex, int pageSize, out long totalChildren, IQuery<IContent>? filter = null, Ordering? ordering = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The parent identifier. |
| long | pageIndex | The page number. |
| int | pageSize | The page size. |
| long | totalChildren | |
| IQuery<IContent> | filter | Query filter. |
| Ordering | ordering | Ordering infos. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IContent> |
GetPagedContentInRecycleBin(long, int, out long, IQuery<IContent>?, Ordering?)
Gets a collection of an IContent objects, which resides in the Recycle Bin
Declaration
public IEnumerable<IContent> GetPagedContentInRecycleBin(long pageIndex, int pageSize, out long totalRecords, IQuery<IContent>? filter = null, Ordering? ordering = null)
Parameters
| Type | Name | Description |
|---|---|---|
| long | pageIndex | |
| int | pageSize | |
| long | totalRecords | |
| IQuery<IContent> | filter | |
| Ordering | ordering |
Returns
| Type | Description |
|---|---|
| IEnumerable<IContent> | An Enumerable list of IContent objects |
GetPagedDescendants(int, long, int, out long, IQuery<IContent>?, Ordering?)
Gets descendant documents of a given parent.
Declaration
public IEnumerable<IContent> GetPagedDescendants(int id, long pageIndex, int pageSize, out long totalChildren, IQuery<IContent>? filter = null, Ordering? ordering = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The parent identifier. |
| long | pageIndex | The page number. |
| int | pageSize | The page size. |
| long | totalChildren | |
| IQuery<IContent> | filter | Query filter. |
| Ordering | ordering | Ordering infos. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IContent> |
GetParent(int)
Gets the parent of the current content as an IContent item.
Declaration
public IContent? GetParent(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | Id of the IContent to retrieve the parent from |
Returns
| Type | Description |
|---|---|
| IContent | Parent IContent object |
GetPermissions(IContent)
Returns implicit/inherited permissions assigned to the content item for all user groups
Declaration
public EntityPermissionCollection GetPermissions(IContent content)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content |
Returns
| Type | Description |
|---|---|
| EntityPermissionCollection |
GetPublishedChildren(int)
Gets a collection of published IContent objects by Parent Id
Declaration
public IEnumerable<IContent> GetPublishedChildren(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | Id of the Parent to retrieve Children from |
Returns
| Type | Description |
|---|---|
| IEnumerable<IContent> | An Enumerable list of published IContent objects |
GetRootContent()
Gets a collection of IContent objects, which reside at the first level / root
Declaration
public IEnumerable<IContent> GetRootContent()
Returns
| Type | Description |
|---|---|
| IEnumerable<IContent> | An Enumerable list of IContent objects |
IsPathPublishable(IContent)
Checks if the passed in IContent can be published based on the ancestors publish state.
Declaration
public bool IsPathPublishable(IContent content)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | IContent to check if ancestors are published |
Returns
| Type | Description |
|---|---|
| bool | True if the Content can be published, otherwise False |
Move(IContent, int, int)
Moves an IContent object to a new location by changing its parent id.
Declaration
public OperationResult Move(IContent content, int parentId, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The IContent to move |
| int | parentId | Id of the Content's new Parent |
| int | userId | Optional Id of the User moving the Content |
Returns
| Type | Description |
|---|---|
| OperationResult |
Remarks
If the IContent object is already published it will be published after being moved to its new location. Otherwise it'll just be saved with a new parent id.
MoveBlueprint(IContent, int)
Moves a content blueprint to a different container.
Declaration
public void MoveBlueprint(IContent content, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The blueprint content to move. |
| int | userId | The optional ID of the user moving the blueprint. |
MoveToRecycleBin(IContent, int)
Moves a document to the recycle bin.
Declaration
public OperationResult MoveToRecycleBin(IContent content, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The document to move to the recycle bin. |
| int | userId | The identifier of the user performing the action. |
Returns
| Type | Description |
|---|---|
| OperationResult | The operation result. |
PublishBranch(IContent, PublishBranchFilter, string[], int)
Publishes a document branch.
Declaration
public IEnumerable<PublishResult> PublishBranch(IContent content, PublishBranchFilter publishBranchFilter, string[] cultures, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The root document. |
| PublishBranchFilter | publishBranchFilter | A value indicating options for force publishing unpublished or re-publishing unchanged content. |
| string[] | cultures | The cultures to publish. |
| int | userId | The identifier of the user performing the operation. |
Returns
| Type | Description |
|---|---|
| IEnumerable<PublishResult> |
Remarks
The root of the branch is always published, regardless of publishBranchFilter.
PublishedNotification(IEnumerable<IContent>, EventMessages)
Declaration
protected override IStatefulNotification PublishedNotification(IEnumerable<IContent> content, EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<IContent> | content | |
| EventMessages | eventMessages |
Returns
| Type | Description |
|---|---|
| IStatefulNotification |
PublishedNotification(IContent, EventMessages)
Declaration
protected override IStatefulNotification PublishedNotification(IContent content, EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | |
| EventMessages | eventMessages |
Returns
| Type | Description |
|---|---|
| IStatefulNotification |
PublishedNotification(IContent, 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 override IStatefulNotification PublishedNotification(IContent content, EventMessages eventMessages, IReadOnlyDictionary<Guid, IReadOnlyCollection<string>>? publishedCultures, IReadOnlyDictionary<Guid, IReadOnlyCollection<string>>? unpublishedCultures)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | 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(IContent, EventMessages)
Declaration
protected override CancelableEnumerableObjectNotification<IContent> PublishingNotification(IContent content, EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | |
| EventMessages | eventMessages |
Returns
| Type | Description |
|---|---|
| CancelableEnumerableObjectNotification<IContent> |
RecycleBinSmells()
Checks if there are any IContent items in the Recycle Bin.
Declaration
public bool RecycleBinSmells()
Returns
| Type | Description |
|---|---|
| bool |
|
RolledBackNotification(IContent, EventMessages)
Declaration
protected override RolledBackNotification<IContent> RolledBackNotification(IContent target, EventMessages messages)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | target | |
| EventMessages | messages |
Returns
| Type | Description |
|---|---|
| RolledBackNotification<IContent> |
RollingBackNotification(IContent, EventMessages)
Declaration
protected override RollingBackNotification<IContent> RollingBackNotification(IContent target, EventMessages messages)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | target | |
| EventMessages | messages |
Returns
| Type | Description |
|---|---|
| RollingBackNotification<IContent> |
SaveBlueprint(IContent, int)
Saves a content blueprint.
Declaration
[Obsolete("Please use the method taking all parameters. Scheduled for removal in Umbraco 20.")]
public void SaveBlueprint(IContent content, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The blueprint content to save. |
| int | userId | The optional ID of the user saving the blueprint. |
SaveBlueprint(IContent, IContent?, int)
Saves a content blueprint with reference to the source content it was created from.
Declaration
public void SaveBlueprint(IContent content, IContent? createdFromContent, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The blueprint content to save. |
| IContent | createdFromContent | The original content the blueprint was created from, or |
| int | userId | The optional ID of the user saving the blueprint. |
SavedNotification(IEnumerable<IContent>, EventMessages)
Declaration
protected override SavedNotification<IContent> SavedNotification(IEnumerable<IContent> content, EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<IContent> | content | |
| EventMessages | eventMessages |
Returns
| Type | Description |
|---|---|
| SavedNotification<IContent> |
SavedNotification(IEnumerable<IContent>, EventMessages, IReadOnlyDictionary<Guid, IReadOnlyCollection<string>>?)
Creates the "saved" notification for multiple items, carrying the cultures that were saved per item.
Declaration
protected override SavedNotification<IContent> SavedNotification(IEnumerable<IContent> content, EventMessages eventMessages, IReadOnlyDictionary<Guid, IReadOnlyCollection<string>>? savedCultures)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<IContent> | 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<IContent> | 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(IContent, EventMessages)
Declaration
protected override SavedNotification<IContent> SavedNotification(IContent content, EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | |
| EventMessages | eventMessages |
Returns
| Type | Description |
|---|---|
| SavedNotification<IContent> |
SavedNotification(IContent, EventMessages, IReadOnlyDictionary<Guid, IReadOnlyCollection<string>>?)
Creates the "saved" notification for a single item, carrying the cultures that were saved.
Declaration
protected override SavedNotification<IContent> SavedNotification(IContent content, EventMessages eventMessages, IReadOnlyDictionary<Guid, IReadOnlyCollection<string>>? savedCultures)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | 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<IContent> | 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<IContent>, EventMessages)
Declaration
protected override SavingNotification<IContent> SavingNotification(IEnumerable<IContent> content, EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<IContent> | content | |
| EventMessages | eventMessages |
Returns
| Type | Description |
|---|---|
| SavingNotification<IContent> |
SavingNotification(IContent, EventMessages)
Declaration
protected override SavingNotification<IContent> SavingNotification(IContent content, EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | |
| EventMessages | eventMessages |
Returns
| Type | Description |
|---|---|
| SavingNotification<IContent> |
SendToPublication(IContent?, int)
Sends an IContent to Publication, which executes handlers and events for the 'Send to Publication' action.
Declaration
public bool SendToPublication(IContent? content, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | The IContent to send to publication |
| int | userId | Optional Id of the User issuing the send to publication |
Returns
| Type | Description |
|---|---|
| bool | True if sending publication was successful otherwise false |
SetPermission(IContent, string, IEnumerable<int>)
Assigns a single permission to the current content item for the specified group ids
Declaration
public void SetPermission(IContent entity, string permission, IEnumerable<int> groupIds)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | entity | |
| string | permission | |
| IEnumerable<int> | groupIds |
SetPermissions(EntityPermissionSet)
Used to bulk update the permissions set for a content item. This will replace all permissions assigned to an entity with a list of user id & permission pairs.
Declaration
public void SetPermissions(EntityPermissionSet permissionSet)
Parameters
| Type | Name | Description |
|---|---|---|
| EntityPermissionSet | permissionSet |
Sort(IEnumerable<int>?, int)
Sorts a collection of IContent objects by updating the SortOrder according
to the ordering of items identified by the ids.
Declaration
public OperationResult Sort(IEnumerable<int>? ids, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<int> | ids | |
| int | userId |
Returns
| Type | Description |
|---|---|
| OperationResult | Result indicating what action was taken when handling the command. |
Remarks
Using this method will ensure that the Published-state is maintained upon sorting so the cache is updated accordingly - as needed.
Sort(IEnumerable<IContent>, int)
Sorts a collection of IContent objects by updating the SortOrder according
to the ordering of items in the passed in items.
Declaration
public OperationResult Sort(IEnumerable<IContent> items, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<IContent> | items | |
| int | userId |
Returns
| Type | Description |
|---|---|
| OperationResult | Result indicating what action was taken when handling the command. |
Remarks
Using this method will ensure that the Published-state is maintained upon sorting so the cache is updated accordingly - as needed.
SortChildren(int, IReadOnlyList<int>, int)
Sorts the children of a parent by persisting the supplied (already ordered) child identifiers as the new sort order, in a single set-based update.
Declaration
public OperationResult SortChildren(int parentId, IReadOnlyList<int> orderedChildIds, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| int | parentId | The identifier of the parent, or Root for the root. |
| IReadOnlyList<int> | orderedChildIds | The child document identifiers, in the desired order. |
| int | userId | The identifier of the user performing the action. |
Returns
| Type | Description |
|---|---|
| OperationResult | The operation result. |
Remarks
Unlike Sort(IEnumerable<int>?, int), this does not load the children or fire per-item save/sort notifications; it persists the order directly and refreshes the affected cache branch.
TreeChangeNotification(IEnumerable<IContent>, TreeChangeTypes, EventMessages)
Declaration
protected override TreeChangeNotification<IContent> TreeChangeNotification(IEnumerable<IContent> content, TreeChangeTypes changeTypes, EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<IContent> | content | |
| TreeChangeTypes | changeTypes | |
| EventMessages | eventMessages |
Returns
| Type | Description |
|---|---|
| TreeChangeNotification<IContent> |
TreeChangeNotification(IContent, TreeChangeTypes, IEnumerable<string>?, IEnumerable<string>?, EventMessages)
Declaration
protected override TreeChangeNotification<IContent> TreeChangeNotification(IContent content, TreeChangeTypes changeTypes, IEnumerable<string>? publishedCultures, IEnumerable<string>? unpublishedCultures, EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | |
| TreeChangeTypes | changeTypes | |
| IEnumerable<string> | publishedCultures | |
| IEnumerable<string> | unpublishedCultures | |
| EventMessages | eventMessages |
Returns
| Type | Description |
|---|---|
| TreeChangeNotification<IContent> |
TreeChangeNotification(IContent, TreeChangeTypes, EventMessages)
Declaration
protected override TreeChangeNotification<IContent> TreeChangeNotification(IContent content, TreeChangeTypes changeTypes, EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | |
| TreeChangeTypes | changeTypes | |
| EventMessages | eventMessages |
Returns
| Type | Description |
|---|---|
| TreeChangeNotification<IContent> |
UnpublishedNotification(IContent, EventMessages)
Declaration
protected override IStatefulNotification UnpublishedNotification(IContent content, EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | |
| EventMessages | eventMessages |
Returns
| Type | Description |
|---|---|
| IStatefulNotification |
UnpublishedNotification(IContent, EventMessages, IReadOnlyDictionary<Guid, IReadOnlyCollection<string>>?)
Creates the "unpublished" notification for a single item, carrying the cultures that were unpublished.
Declaration
protected override IStatefulNotification UnpublishedNotification(IContent content, EventMessages eventMessages, IReadOnlyDictionary<Guid, IReadOnlyCollection<string>>? unpublishedCultures)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | 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(IContent, EventMessages)
Declaration
protected override CancelableEnumerableObjectNotification<IContent> UnpublishingNotification(IContent content, EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| IContent | content | |
| EventMessages | eventMessages |
Returns
| Type | Description |
|---|---|
| CancelableEnumerableObjectNotification<IContent> |