Class ContentTypeServiceBase<TRepository, TItem>
Generic base class for content type services that provides CRUD operations, validation, composition handling, and container management for content types.
Namespace: Umbraco.Cms.Core.Services
Assembly: Umbraco.Core.dll
Syntax
public abstract class ContentTypeServiceBase<TRepository, TItem> : ContentTypeServiceBase, IContentTypeBaseService<TItem>, IContentTypeBaseService, IService where TRepository : IContentTypeRepositoryBase<TItem> where TItem : class, IContentTypeComposition
Type Parameters
| Name | Description |
|---|---|
| TRepository | The type of the content type repository. |
| TItem | The type of content type. |
Constructors
View SourceContentTypeServiceBase(ICoreScopeProvider, ILoggerFactory, IEventMessagesFactory, TRepository, IAuditRepository, IEntityContainerRepository, IEntityRepository, IEventAggregator, IUserIdKeyResolver, ContentTypeFilterCollection)
Initializes a new instance of the ContentTypeServiceBase<TRepository, TItem> class.
Declaration
[Obsolete("Use the non-obsolete constructor instead. Scheduled for removal in Umbraco 19.")]
protected ContentTypeServiceBase(ICoreScopeProvider provider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, TRepository repository, IAuditRepository auditRepository, IEntityContainerRepository containerRepository, IEntityRepository entityRepository, IEventAggregator eventAggregator, IUserIdKeyResolver userIdKeyResolver, ContentTypeFilterCollection contentTypeFilters)
Parameters
| Type | Name | Description |
|---|---|---|
| ICoreScopeProvider | provider | The core scope provider. |
| ILoggerFactory | loggerFactory | The logger factory. |
| IEventMessagesFactory | eventMessagesFactory | The event messages factory. |
| TRepository | repository | The content type repository. |
| IAuditRepository | auditRepository | The audit repository. |
| IEntityContainerRepository | containerRepository | The entity container repository. |
| IEntityRepository | entityRepository | The entity repository. |
| IEventAggregator | eventAggregator | The event aggregator. |
| IUserIdKeyResolver | userIdKeyResolver | The user ID key resolver. |
| ContentTypeFilterCollection | contentTypeFilters | The content type filter collection. |
ContentTypeServiceBase(ICoreScopeProvider, ILoggerFactory, IEventMessagesFactory, TRepository, IAuditService, IEntityContainerRepository, IEntityRepository, IEventAggregator, IUserIdKeyResolver, ContentTypeFilterCollection)
Initializes a new instance of the ContentTypeServiceBase<TRepository, TItem> class.
Declaration
protected ContentTypeServiceBase(ICoreScopeProvider provider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, TRepository repository, IAuditService auditService, IEntityContainerRepository containerRepository, IEntityRepository entityRepository, IEventAggregator eventAggregator, IUserIdKeyResolver userIdKeyResolver, ContentTypeFilterCollection contentTypeFilters)
Parameters
| Type | Name | Description |
|---|---|---|
| ICoreScopeProvider | provider | The core scope provider. |
| ILoggerFactory | loggerFactory | The logger factory. |
| IEventMessagesFactory | eventMessagesFactory | The event messages factory. |
| TRepository | repository | The content type repository. |
| IAuditService | auditService | The audit service. |
| IEntityContainerRepository | containerRepository | The entity container repository. |
| IEntityRepository | entityRepository | The entity repository. |
| IEventAggregator | eventAggregator | The event aggregator. |
| IUserIdKeyResolver | userIdKeyResolver | The user ID key resolver. |
| ContentTypeFilterCollection | contentTypeFilters | The content type filter collection. |
Properties
View SourceContainedObjectType
Gets the object type GUID for content types contained by this service.
Declaration
protected abstract Guid ContainedObjectType { get; }
Property Value
| Type | Description |
|---|---|
| Guid |
ContainerObjectType
Gets the container object type GUID.
Declaration
protected Guid ContainerObjectType { get; }
Property Value
| Type | Description |
|---|---|
| Guid |
ReadLockIds
Gets the read lock IDs for this content type.
Declaration
protected abstract int[] ReadLockIds { get; }
Property Value
| Type | Description |
|---|---|
| int[] |
Repository
Gets the content type repository.
Declaration
protected TRepository Repository { get; }
Property Value
| Type | Description |
|---|---|
| TRepository |
WriteLockIds
Gets the write lock IDs for this content type.
Declaration
protected abstract int[] WriteLockIds { get; }
Property Value
| Type | Description |
|---|---|
| int[] |
Methods
View SourceCanDelete(TItem)
Determines whether the specified content type can be deleted.
Declaration
protected virtual bool CanDelete(TItem item)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | item | The content type to check. |
Returns
| Type | Description |
|---|---|
| bool |
|
Copy(TItem, int)
Copies a content type to a specified container.
Declaration
[Obsolete("Please use CopyAsync. Scheduled for removal in Umbraco 18.")]
public Attempt<OperationResult<MoveOperationStatusType, TItem>?> Copy(TItem copying, int containerId)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | copying | The content type to copy. |
| int | containerId | The identifier of the target container. Use -1 for root. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult<MoveOperationStatusType, TItem>> | An attempt result containing the operation status and the copied content type. |
Copy(TItem, string, string, int)
Copies the specified content type to a new content type with the specified alias and name.
Declaration
[Obsolete("Please use CopyAsync. Scheduled for removal in Umbraco 18.")]
public TItem Copy(TItem original, string alias, string name, int parentId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | original | The original content type to copy. |
| string | alias | The alias for the new content type. |
| string | name | The name for the new content type. |
| int | parentId | The parent identifier for the new content type. Use -1 for root. |
Returns
| Type | Description |
|---|---|
| TItem | The newly created content type copy. |
Copy(TItem, string, string, TItem?)
Copies the specified content type to a new content type with the specified alias, name, and parent.
Declaration
[Obsolete("Please use CopyAsync. Scheduled for removal in Umbraco 18.")]
public TItem Copy(TItem original, string alias, string name, TItem? parent)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | original | The original content type to copy. |
| string | alias | The alias for the new content type. |
| string | name | The name for the new content type. |
| TItem | parent | The parent content type for the new content type. Use null for root. |
Returns
| Type | Description |
|---|---|
| TItem | The newly created content type copy. |
CopyAsync(Guid, Guid?)
Copies a content type to a container asynchronously.
Declaration
public Task<Attempt<TItem?, ContentTypeStructureOperationStatus>> CopyAsync(Guid key, Guid? containerKey)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | The unique identifier of the content type to copy. |
| Guid? | containerKey | The unique identifier of the target container, or |
Returns
| Type | Description |
|---|---|
| Task<Attempt<TItem, ContentTypeStructureOperationStatus>> | An attempt containing the copied content type or an error status. |
Count()
Gets the total count of content types.
Declaration
public int Count()
Returns
| Type | Description |
|---|---|
| int | The count of content types. |
CreateAsync(TItem, Guid)
Creates a new content type.
Declaration
public Task<Attempt<ContentTypeOperationStatus>> CreateAsync(TItem item, Guid performingUserKey)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | item | The content type to create. |
| Guid | performingUserKey | The unique identifier of the user performing the action. |
Returns
| Type | Description |
|---|---|
| Task<Attempt<ContentTypeOperationStatus>> | An attempt containing the operation status. |
CreateContainer(int, Guid, string, int)
Creates a new entity container for organizing content types.
Declaration
[Obsolete("Please use IContentTypeContainerService or IMediaTypeContainerService for all content or media type container operations. Scheduled for removal in Umbraco 18.")]
public Attempt<OperationResult<OperationResultType, EntityContainer>?> CreateContainer(int parentId, Guid key, string name, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| int | parentId | The parent container identifier. Use -1 for root. |
| Guid | key | The unique key for the container. |
| string | name | The name of the container. |
| int | userId | The identifier of the user creating the container. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult<OperationResultType, EntityContainer>> | An attempt result containing the operation status and the created container. |
Delete(IEnumerable<TItem>, int)
Deletes a collection of content types.
Declaration
public void Delete(IEnumerable<TItem> items, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<TItem> | items | |
| int | userId | The identifier of the user performing the action. |
Delete(TItem, int)
Deletes a content type.
Declaration
public void Delete(TItem item, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | item | The content type to delete. |
| int | userId | The identifier of the user performing the action. |
DeleteAsync(Guid, Guid)
Deletes a content type by its unique identifier.
Declaration
public Task<ContentTypeOperationStatus> DeleteAsync(Guid key, Guid performingUserKey)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | The unique identifier of the content type to delete. |
| Guid | performingUserKey | The unique identifier of the user performing the action. |
Returns
| Type | Description |
|---|---|
| Task<ContentTypeOperationStatus> | The operation status. |
DeleteContainer(int, int)
Deletes an entity container.
Declaration
[Obsolete("Please use IContentTypeContainerService or IMediaTypeContainerService for all content or media type container operations. Scheduled for removal in Umbraco 18.")]
public Attempt<OperationResult?> DeleteContainer(int containerId, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| int | containerId | The identifier of the container to delete. |
| int | userId | The identifier of the user deleting the container. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult> | An attempt result containing the operation status. |
DeleteItemsOfTypes(IEnumerable<int>)
Deletes content items of the specified types.
Declaration
protected abstract void DeleteItemsOfTypes(IEnumerable<int> typeIds)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<int> | typeIds | The type IDs whose content should be deleted. |
Get(Guid)
Gets a content type.
Declaration
public TItem? Get(Guid id)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | id |
Returns
| Type | Description |
|---|---|
| TItem |
Get(int)
Gets a content type.
Declaration
public TItem? Get(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id |
Returns
| Type | Description |
|---|---|
| TItem |
Get(string)
Gets a content type.
Declaration
public TItem? Get(string alias)
Parameters
| Type | Name | Description |
|---|---|---|
| string | alias |
Returns
| Type | Description |
|---|---|
| TItem |
GetAll()
Gets all content types.
Declaration
public IEnumerable<TItem> GetAll()
Returns
| Type | Description |
|---|---|
| IEnumerable<TItem> | A collection of all content types. |
GetAllAllowedAsRootAsync(int, int)
Returns all the content type allowed as root.
Declaration
public Task<PagedModel<TItem>> GetAllAllowedAsRootAsync(int skip, int take)
Parameters
| Type | Name | Description |
|---|---|---|
| int | skip | |
| int | take |
Returns
| Type | Description |
|---|---|
| Task<PagedModel<TItem>> |
GetAllowedChildrenAsync(Guid, int, int)
Returns all content types allowed as children for a given content type key.
Declaration
public Task<Attempt<PagedModel<TItem>?, ContentTypeOperationStatus>> GetAllowedChildrenAsync(Guid key, int skip, int take)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | The content type key. |
| int | skip | The number of items to skip. |
| int | take | The number of items to take. |
Returns
| Type | Description |
|---|---|
| Task<Attempt<PagedModel<TItem>, ContentTypeOperationStatus>> |
GetAllowedChildrenAsync(Guid, Guid?, int, int)
Returns all content types allowed as children for a given content type key.
Declaration
public Task<Attempt<PagedModel<TItem>?, ContentTypeOperationStatus>> GetAllowedChildrenAsync(Guid key, Guid? parentContentKey, int skip, int take)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | The content type key. |
| Guid? | parentContentKey | The parent content key. |
| int | skip | The number of items to skip. |
| int | take | The number of items to take. |
Returns
| Type | Description |
|---|---|
| Task<Attempt<PagedModel<TItem>, ContentTypeOperationStatus>> |
GetAllowedParentKeysAsync(Guid)
Gets the keys of all content types that allow the provided content type key as a child (i.e. all potential parents of the provided key).
Declaration
public Task<Attempt<IEnumerable<Guid>, ContentTypeOperationStatus>> GetAllowedParentKeysAsync(Guid key)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | The key of the child content type. |
Returns
| Type | Description |
|---|---|
| Task<Attempt<IEnumerable<Guid>, ContentTypeOperationStatus>> | A collection of the keys of all potential parents. |
Exceptions
| Type | Condition |
|---|---|
| NotImplementedException | Default implementation due to breaking changes. |
GetAsync(Guid)
Gets a content type.
Declaration
public Task<TItem?> GetAsync(Guid guid)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | guid | The key of the content type. |
Returns
| Type | Description |
|---|---|
| Task<TItem> | The found content type, null if none was found. |
GetChildren(Guid)
Gets all child content types of a given content type.
Declaration
public IEnumerable<TItem> GetChildren(Guid id)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | id | The unique identifier of the parent content type. |
Returns
| Type | Description |
|---|---|
| IEnumerable<TItem> | A collection of child content types. |
GetChildren(int)
Gets all child content types of a given content type.
Declaration
public IEnumerable<TItem> GetChildren(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The identifier of the parent content type. |
Returns
| Type | Description |
|---|---|
| IEnumerable<TItem> | A collection of child content types. |
GetComposedOf(int)
Gets all content types that are composed of a given content type.
Declaration
public IEnumerable<TItem> GetComposedOf(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The identifier of the composition content type. |
Returns
| Type | Description |
|---|---|
| IEnumerable<TItem> | A collection of content types that use the specified composition. |
GetComposedOf(int, IEnumerable<TItem>)
Declaration
public IEnumerable<TItem> GetComposedOf(int id, IEnumerable<TItem> all)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | |
| IEnumerable<TItem> | all |
Returns
| Type | Description |
|---|---|
| IEnumerable<TItem> |
GetContainer(Guid)
Gets an entity container by its GUID identifier.
Declaration
[Obsolete("Please use IContentTypeContainerService or IMediaTypeContainerService for all content or media type container operations. Scheduled for removal in Umbraco 18.")]
public EntityContainer? GetContainer(Guid containerId)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | containerId | The GUID identifier of the container. |
Returns
| Type | Description |
|---|---|
| EntityContainer | The entity container if found; otherwise, null. |
GetContainer(int)
Gets an entity container by its integer identifier.
Declaration
[Obsolete("Please use IContentTypeContainerService or IMediaTypeContainerService for all content or media type container operations. Scheduled for removal in Umbraco 18.")]
public EntityContainer? GetContainer(int containerId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | containerId | The integer identifier of the container. |
Returns
| Type | Description |
|---|---|
| EntityContainer | The entity container if found; otherwise, null. |
GetContainers(int[])
Gets entity containers by their integer identifiers.
Declaration
[Obsolete("Please use IContentTypeContainerService or IMediaTypeContainerService for all content or media type container operations. Scheduled for removal in Umbraco 18.")]
public IEnumerable<EntityContainer> GetContainers(int[] containerIds)
Parameters
| Type | Name | Description |
|---|---|---|
| int[] | containerIds | The array of container identifiers. |
Returns
| Type | Description |
|---|---|
| IEnumerable<EntityContainer> | A collection of entity containers. |
GetContainers(string, int)
Gets entity containers by name and level.
Declaration
[Obsolete("Please use IContentTypeContainerService or IMediaTypeContainerService for all content or media type container operations. Scheduled for removal in Umbraco 18.")]
public IEnumerable<EntityContainer> GetContainers(string name, int level)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the containers to find. |
| int | level | The level of the containers in the hierarchy. |
Returns
| Type | Description |
|---|---|
| IEnumerable<EntityContainer> | A collection of entity containers matching the criteria. |
GetContainers(TItem)
Gets the ancestor containers of the specified content type item.
Declaration
[Obsolete("Please use IContentTypeContainerService or IMediaTypeContainerService for all content or media type container operations. Scheduled for removal in Umbraco 18.")]
public IEnumerable<EntityContainer> GetContainers(TItem item)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | item | The content type item to get ancestor containers for. |
Returns
| Type | Description |
|---|---|
| IEnumerable<EntityContainer> | A collection of ancestor entity containers. |
GetContentTypeChangedNotification(IEnumerable<ContentTypeChange<TItem>>, EventMessages)
Gets a content type changed notification.
Declaration
protected abstract ContentTypeChangeNotification<TItem> GetContentTypeChangedNotification(IEnumerable<ContentTypeChange<TItem>> changes, EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<ContentTypeChange<TItem>> | changes | The collection of content type changes. |
| EventMessages | eventMessages | The event messages. |
Returns
| Type | Description |
|---|---|
| ContentTypeChangeNotification<TItem> | The content type changed notification. |
GetContentTypeRefreshedNotification(IEnumerable<ContentTypeChange<TItem>>, EventMessages)
Gets a content type refreshed notification that is published within the transaction.
Declaration
protected abstract ContentTypeRefreshNotification<TItem> GetContentTypeRefreshedNotification(IEnumerable<ContentTypeChange<TItem>> changes, EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<ContentTypeChange<TItem>> | changes | The collection of content type changes. |
| EventMessages | eventMessages | The event messages. |
Returns
| Type | Description |
|---|---|
| ContentTypeRefreshNotification<TItem> | The content type refreshed notification. |
Remarks
This notification is identical to GetContentTypeChangedNotification, however it needs to be a different notification type because it's published within the transaction. The purpose of this notification being published within the transaction is so that listeners can perform database operations from within the same transaction and guarantee data consistency so that if anything goes wrong the entire transaction can be rolled back. This is used by Nucache.
GetDeletedNotification(IEnumerable<TItem>, EventMessages)
Gets a deleted notification for multiple content type items.
Declaration
protected abstract DeletedNotification<TItem> GetDeletedNotification(IEnumerable<TItem> items, EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<TItem> | items | The content type items that were deleted. |
| EventMessages | eventMessages | The event messages. |
Returns
| Type | Description |
|---|---|
| DeletedNotification<TItem> | The deleted notification. |
GetDeletingNotification(IEnumerable<TItem>, EventMessages)
Gets a deleting notification for multiple content type items.
Declaration
protected abstract DeletingNotification<TItem> GetDeletingNotification(IEnumerable<TItem> items, EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<TItem> | items | The content type items being deleted. |
| EventMessages | eventMessages | The event messages. |
Returns
| Type | Description |
|---|---|
| DeletingNotification<TItem> | The deleting notification. |
GetDeletingNotification(TItem, EventMessages)
Gets a deleting notification for a single content type item.
Declaration
protected abstract DeletingNotification<TItem> GetDeletingNotification(TItem item, EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | item | The content type item being deleted. |
| EventMessages | eventMessages | The event messages. |
Returns
| Type | Description |
|---|---|
| DeletingNotification<TItem> | The deleting notification. |
GetDescendants(int, bool)
Gets all descendant content types of a given content type.
Declaration
public IEnumerable<TItem> GetDescendants(int id, bool andSelf)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The identifier of the parent content type. |
| bool | andSelf | Whether to include the parent content type itself. |
Returns
| Type | Description |
|---|---|
| IEnumerable<TItem> | A collection of descendant content types. |
GetMany(IEnumerable<Guid>?)
Gets multiple content types by their unique identifiers.
Declaration
public IEnumerable<TItem> GetMany(IEnumerable<Guid>? ids)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<Guid> | ids | The unique identifiers of the content types to retrieve. |
Returns
| Type | Description |
|---|---|
| IEnumerable<TItem> | A collection of content types. |
GetMany(params int[])
Gets multiple content types by their identifiers.
Declaration
public IEnumerable<TItem> GetMany(params int[] ids)
Parameters
| Type | Name | Description |
|---|---|---|
| int[] | ids | The identifiers of the content types to retrieve. |
Returns
| Type | Description |
|---|---|
| IEnumerable<TItem> | A collection of content types. |
GetMovedNotification(IEnumerable<MoveEventInfo<TItem>>, EventMessages)
Gets a moved notification for multiple content type items.
Declaration
protected abstract MovedNotification<TItem> GetMovedNotification(IEnumerable<MoveEventInfo<TItem>> moveInfo, EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<MoveEventInfo<TItem>> | moveInfo | The collection of move event information. |
| EventMessages | eventMessages | The event messages. |
Returns
| Type | Description |
|---|---|
| MovedNotification<TItem> | The moved notification. |
GetMovingNotification(MoveEventInfo<TItem>, EventMessages)
Gets a moving notification for a content type item.
Declaration
protected abstract MovingNotification<TItem> GetMovingNotification(MoveEventInfo<TItem> moveInfo, EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| MoveEventInfo<TItem> | moveInfo | The move event information. |
| EventMessages | eventMessages | The event messages. |
Returns
| Type | Description |
|---|---|
| MovingNotification<TItem> | The moving notification. |
GetSavedNotification(IEnumerable<TItem>, EventMessages)
Gets a saved notification for multiple content type items.
Declaration
protected abstract SavedNotification<TItem> GetSavedNotification(IEnumerable<TItem> items, EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<TItem> | items | The content type items that were saved. |
| EventMessages | eventMessages | The event messages. |
Returns
| Type | Description |
|---|---|
| SavedNotification<TItem> | The saved notification. |
GetSavedNotification(TItem, EventMessages)
Gets a saved notification for a single content type item.
Declaration
protected abstract SavedNotification<TItem> GetSavedNotification(TItem item, EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | item | The content type item that was saved. |
| EventMessages | eventMessages | The event messages. |
Returns
| Type | Description |
|---|---|
| SavedNotification<TItem> | The saved notification. |
GetSavingNotification(IEnumerable<TItem>, EventMessages)
Gets a saving notification for multiple content type items.
Declaration
protected abstract SavingNotification<TItem> GetSavingNotification(IEnumerable<TItem> items, EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<TItem> | items | The content type items being saved. |
| EventMessages | eventMessages | The event messages. |
Returns
| Type | Description |
|---|---|
| SavingNotification<TItem> | The saving notification. |
GetSavingNotification(TItem, EventMessages)
Gets a saving notification for a single content type item.
Declaration
protected abstract SavingNotification<TItem> GetSavingNotification(TItem item, EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | item | The content type item being saved. |
| EventMessages | eventMessages | The event messages. |
Returns
| Type | Description |
|---|---|
| SavingNotification<TItem> | The saving notification. |
HasChildren(Guid)
Checks if a content type has child content types.
Declaration
public bool HasChildren(Guid id)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | id | The unique identifier of the content type. |
Returns
| Type | Description |
|---|---|
| bool |
|
HasChildren(int)
Checks if a content type has child content types.
Declaration
public bool HasChildren(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The identifier of the content type. |
Returns
| Type | Description |
|---|---|
| bool |
|
HasContainerInPath(params int[])
Checks whether any of the specified content items exist underneath a list view content item.
Declaration
public bool HasContainerInPath(params int[] ids)
Parameters
| Type | Name | Description |
|---|---|---|
| int[] | ids | The IDs of the content items to check. |
Returns
| Type | Description |
|---|---|
| bool |
|
HasContainerInPath(string)
Determines whether the content item with the specified path exists underneath a list view content item.
Declaration
public bool HasContainerInPath(string contentPath)
Parameters
| Type | Name | Description |
|---|---|---|
| string | contentPath | The path of the content item to check. |
Returns
| Type | Description |
|---|---|
| bool |
|
HasContentNodes(int)
Returns true or false depending on whether content nodes have been created based on the provided content type id.
Declaration
public bool HasContentNodes(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The identifier of the content type. |
Returns
| Type | Description |
|---|---|
| bool |
|
Move(TItem, int)
Moves a content type to a specified container.
Declaration
[Obsolete("Please use MoveAsync. Scheduled for removal in Umbraco 18.")]
public Attempt<OperationResult<MoveOperationStatusType>?> Move(TItem moving, int containerId)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | moving | The content type to move. |
| int | containerId | The identifier of the target container. Use -1 for root. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult<MoveOperationStatusType>> | An attempt result containing the operation status. |
MoveAsync(Guid, Guid?)
Moves a content type to a container asynchronously.
Declaration
public Task<Attempt<TItem?, ContentTypeStructureOperationStatus>> MoveAsync(Guid key, Guid? containerKey)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | The unique identifier of the content type to move. |
| Guid? | containerKey | The unique identifier of the target container, or |
Returns
| Type | Description |
|---|---|
| Task<Attempt<TItem, ContentTypeStructureOperationStatus>> | An attempt containing the moved content type or an error status. |
PerformGetAllowedParentKeysAsync(Guid)
Retrieves a collection of allowed parent keys for the specified key.
Declaration
protected virtual Task<IEnumerable<Guid>> PerformGetAllowedParentKeysAsync(Guid key)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | The unique identifier of the key for which to retrieve allowed parent keys. |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<Guid>> |
RenameContainer(int, string, int)
Renames an entity container.
Declaration
[Obsolete("Please use IContentTypeContainerService or IMediaTypeContainerService for all content or media type container operations. Scheduled for removal in Umbraco 18.")]
public Attempt<OperationResult<OperationResultType, EntityContainer>?> RenameContainer(int id, string name, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The identifier of the container to rename. |
| string | name | The new name for the container. |
| int | userId | The identifier of the user renaming the container. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult<OperationResultType, EntityContainer>> | An attempt result containing the operation status and the renamed container. |
Save(IEnumerable<TItem>, int)
Saves a collection of content types.
Declaration
public void Save(IEnumerable<TItem> items, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<TItem> | items | The content types to save. |
| int | userId | The identifier of the user performing the action. |
Save(TItem?, int)
Saves a content type.
Declaration
public void Save(TItem? item, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | item | The content type to save. |
| int | userId | The identifier of the user performing the action. |
SaveAsync(TItem, Guid)
Saves a content type asynchronously.
Declaration
public Task SaveAsync(TItem item, Guid performingUserKey)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | item | The content type to save. |
| Guid | performingUserKey | The unique identifier of the user performing the action. |
Returns
| Type | Description |
|---|---|
| Task |
SaveContainer(EntityContainer, int)
Saves an entity container.
Declaration
[Obsolete("Please use IContentTypeContainerService or IMediaTypeContainerService for all content or media type container operations. Scheduled for removal in Umbraco 18.")]
public Attempt<OperationResult?> SaveContainer(EntityContainer container, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| EntityContainer | container | The container to save. |
| int | userId | The identifier of the user saving the container. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult> | An attempt result containing the operation status. |
UpdateAsync(TItem, Guid)
Updates an existing content type.
Declaration
public Task<Attempt<ContentTypeOperationStatus>> UpdateAsync(TItem item, Guid performingUserKey)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | item | The content type to update. |
| Guid | performingUserKey | The unique identifier of the user performing the action. |
Returns
| Type | Description |
|---|---|
| Task<Attempt<ContentTypeOperationStatus>> | An attempt containing the operation status. |
ValidateComposition(TItem?)
Validates that a content type's composition is valid.
Declaration
public Attempt<string[]?> ValidateComposition(TItem? compo)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | compo | The content type composition to validate. |
Returns
| Type | Description |
|---|---|
| Attempt<string[]> | An attempt containing an array of error messages if validation fails, or |
ValidateLocked(TItem)
Validates a content type composition for conflicts within a lock context.
Declaration
protected void ValidateLocked(TItem compositionContentType)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | compositionContentType | The content type to validate. |
Exceptions
| Type | Condition |
|---|---|
| InvalidCompositionException | Thrown when the composition is invalid. |