Interface IContentTypeBaseService<TItem>
Provides a common base interface for IContentTypeService, IMediaTypeService and IMemberTypeService.
Namespace: Umbraco.Cms.Core.Services
Assembly: Umbraco.Core.dll
Syntax
public interface IContentTypeBaseService<TItem> : IContentTypeBaseService, IService where TItem : IContentTypeComposition
Type Parameters
| Name | Description |
|---|---|
| TItem | The type of the item. |
Methods
View SourceCopy(TItem, int)
Copies a content type to a container.
Declaration
[Obsolete("Please use CopyAsync. Scheduled for removal in Umbraco 18.")]
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. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult<MoveOperationStatusType, TItem>> | An attempt containing the operation result with the copied content type. |
Copy(TItem, string, string, int)
Copies a content type with a new alias and name.
Declaration
[Obsolete("Please use CopyAsync. Scheduled for removal in Umbraco 18.")]
TItem Copy(TItem original, string alias, string name, int parentId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | original | The content type to copy. |
| string | alias | The alias for the copy. |
| string | name | The name for the copy. |
| int | parentId | The identifier of the parent container. |
Returns
| Type | Description |
|---|---|
| TItem | The copied content type. |
Copy(TItem, string, string, TItem)
Copies a content type with a new alias and name under a parent.
Declaration
[Obsolete("Please use CopyAsync. Scheduled for removal in Umbraco 18.")]
TItem Copy(TItem original, string alias, string name, TItem parent)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | original | The content type to copy. |
| string | alias | The alias for the copy. |
| string | name | The name for the copy. |
| TItem | parent | The parent content type. |
Returns
| Type | Description |
|---|---|
| TItem | The copied content type. |
CopyAsync(Guid, Guid?)
Copies a content type to a container asynchronously.
Declaration
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
int Count()
Returns
| Type | Description |
|---|---|
| int | The count of content types. |
CreateAsync(TItem, Guid)
Creates a new content type.
Declaration
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 container (folder) for organizing content types.
Declaration
Attempt<OperationResult<OperationResultType, EntityContainer>?> CreateContainer(int parentContainerId, Guid key, string name, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| int | parentContainerId | The identifier of the parent container, or -1 for root level. |
| Guid | key | The unique identifier for the new container. |
| string | name | The name of the container. |
| int | userId | The identifier of the user performing the action. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult<OperationResultType, EntityContainer>> | An attempt containing the operation result with the created container. |
Delete(IEnumerable<TItem>, int)
Deletes a collection of content types.
Declaration
void Delete(IEnumerable<TItem> item, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<TItem> | item | The content types to delete. |
| int | userId | The identifier of the user performing the action. |
Delete(TItem, int)
Deletes a content type.
Declaration
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
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 a container.
Declaration
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 performing the action. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult> | An attempt containing the operation result. |
Get(Guid)
Gets a content type.
Declaration
TItem? Get(Guid key)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key |
Returns
| Type | Description |
|---|---|
| TItem |
Get(int)
Gets a content type.
Declaration
TItem? Get(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id |
Returns
| Type | Description |
|---|---|
| TItem |
Get(string)
Gets a content type.
Declaration
TItem? Get(string alias)
Parameters
| Type | Name | Description |
|---|---|---|
| string | alias |
Returns
| Type | Description |
|---|---|
| TItem |
GetAll()
Gets all content types.
Declaration
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
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
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
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
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
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
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
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
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. |
GetContainer(Guid)
Gets a container by its unique identifier.
Declaration
EntityContainer? GetContainer(Guid containerId)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | containerId | The unique identifier of the container. |
Returns
| Type | Description |
|---|---|
| EntityContainer | The container, or |
GetContainer(int)
Gets a container by its identifier.
Declaration
EntityContainer? GetContainer(int containerId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | containerId | The identifier of the container. |
Returns
| Type | Description |
|---|---|
| EntityContainer | The container, or |
GetContainers(int[])
Gets multiple containers by their identifiers.
Declaration
IEnumerable<EntityContainer> GetContainers(int[] containerIds)
Parameters
| Type | Name | Description |
|---|---|---|
| int[] | containerIds | The identifiers of the containers to retrieve. |
Returns
| Type | Description |
|---|---|
| IEnumerable<EntityContainer> | A collection of containers. |
GetContainers(string, int)
Gets containers by name and level.
Declaration
IEnumerable<EntityContainer> GetContainers(string folderName, int level)
Parameters
| Type | Name | Description |
|---|---|---|
| string | folderName | The name of the folder. |
| int | level | The level in the hierarchy. |
Returns
| Type | Description |
|---|---|
| IEnumerable<EntityContainer> | A collection of matching containers. |
GetContainers(TItem)
Gets all containers in the path of a content type.
Declaration
IEnumerable<EntityContainer> GetContainers(TItem contentType)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | contentType | The content type. |
Returns
| Type | Description |
|---|---|
| IEnumerable<EntityContainer> | A collection of containers in the content type's path. |
GetDescendants(int, bool)
Gets all descendant content types of a given content type.
Declaration
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
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
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. |
HasChildren(Guid)
Checks if a content type has child content types.
Declaration
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
bool HasChildren(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The identifier of the content type. |
Returns
| Type | Description |
|---|---|
| bool |
|
HasContainerInPath(params int[])
Gets a value indicating whether there is a list view content item in the path.
Declaration
bool HasContainerInPath(params int[] ids)
Parameters
| Type | Name | Description |
|---|---|---|
| int[] | ids |
Returns
| Type | Description |
|---|---|
| bool |
HasContainerInPath(string)
Given the path of a content item, this will return true if the content item exists underneath a list view content item
Declaration
bool HasContainerInPath(string contentPath)
Parameters
| Type | Name | Description |
|---|---|---|
| string | contentPath |
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
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 container.
Declaration
[Obsolete("Please use MoveAsync. Scheduled for removal in Umbraco 18.")]
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. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult<MoveOperationStatusType>> | An attempt containing the operation result. |
MoveAsync(Guid, Guid?)
Moves a content type to a container asynchronously.
Declaration
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. |
RenameContainer(int, string, int)
Renames a container.
Declaration
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 performing the action. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult<OperationResultType, EntityContainer>> | An attempt containing the operation result with the renamed container. |
Save(IEnumerable<TItem>, int)
Saves a collection of content types.
Declaration
[Obsolete("Please use the respective Create or Update instead")]
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
[Obsolete("Please use the respective Create or Update instead")]
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
[Obsolete("Please use the respective Create or Update instead")]
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 a container.
Declaration
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 performing the action. |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult> | An attempt containing the operation result. |
UpdateAsync(TItem, Guid)
Updates an existing content type.
Declaration
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
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 |