Class ContentTypeServiceExtensions
Provides extension methods for the IContentTypeService interface.
Inheritance
Namespace: Umbraco.Extensions
Assembly: Umbraco.Core.dll
Syntax
public static class ContentTypeServiceExtensions
Methods
View SourceGetAllElementTypes(IContentTypeService)
Gets all of the element types (e.g. content types that have been marked as an element type).
Declaration
public static IEnumerable<IContentType> GetAllElementTypes(this IContentTypeService contentTypeService)
Parameters
| Type | Name | Description |
|---|---|---|
| IContentTypeService | contentTypeService | The content type service. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IContentType> | Returns all the element types. |
GetAvailableCompositeContentTypes(IContentTypeService, IContentTypeComposition?, IContentTypeComposition[], string[]?, string[]?, bool)
Gets the composite content types available to a given content type, indicating whether each one is actually allowed to be selected.
Declaration
public static ContentTypeAvailableCompositionsResults GetAvailableCompositeContentTypes(this IContentTypeService ctService, IContentTypeComposition? source, IContentTypeComposition[] allContentTypes, string[]? filterContentTypes = null, string[]? filterPropertyTypes = null, bool isElement = false)
Parameters
| Type | Name | Description |
|---|---|---|
| IContentTypeService | ctService | The content type service. |
| IContentTypeComposition | source | The content type to find available compositions for, or |
| IContentTypeComposition[] | allContentTypes | All existing content types of the same kind (document, media or member type). |
| string[] | filterContentTypes | This is normally an empty list but if additional content type aliases are passed in, any content types containing those aliases will be filtered out along with any content types that have matching property types that are included in the filtered content types |
| string[] | filterPropertyTypes | This is normally an empty list but if additional property type aliases are passed in, any content types that have these aliases will be filtered out. This is required because in the case of creating/modifying a content type because new property types being added to it are not yet persisted so cannot be looked up via the db, they need to be passed in. |
| bool | isElement | Whether the composite content types should be applicable for an element type |
Returns
| Type | Description |
|---|---|
| ContentTypeAvailableCompositionsResults | Every candidate composition (excluding |
Remarks
A composition is marked not allowed when it is source's own ancestor, when it is filtered
out via filterContentTypes or filterPropertyTypes, or when selecting it
would push a property alias down onto one of source's descendants that already defines it.
GetComposedOf<TItem>(IContentTypeBaseService<TItem>, int, ComposedOfType)
Gets the content types that are composed of a given content type, restricted to the requested relationship kind.
Declaration
public static IEnumerable<TItem> GetComposedOf<TItem>(this IContentTypeBaseService<TItem> contentTypeBaseService, int id, ComposedOfType composedOfType) where TItem : IContentTypeComposition
Parameters
| Type | Name | Description |
|---|---|---|
| IContentTypeBaseService<TItem> | contentTypeBaseService | The content type service. |
| int | id | The identifier of the composition content type. |
| ComposedOfType | composedOfType | Which relationships to include: composition, inheritance, or both. |
Returns
| Type | Description |
|---|---|
| IEnumerable<TItem> | The content types that build upon the specified content type in the requested way. |
Type Parameters
| Name | Description |
|---|---|
| TItem | The content type kind (document, media or member type). |
Remarks
A convenience filter over GetComposedOf(int). Inheritance and
composition share the same underlying storage; a referencing content type is an inheritance child when its
tree parent is id, otherwise it is a true composition user.