ContentTypeService GetAllElementTypes method

Added an extension method to get all the Element Types from
the ContentTypeService.

Refactored NestedContent's controller accordingly.
This commit is contained in:
leekelleher
2019-09-02 14:54:51 +01:00
committed by Sebastiaan Janssen
parent ff72a341b2
commit 83588b2dc8
2 changed files with 18 additions and 2 deletions

View File

@@ -7,6 +7,21 @@ namespace Umbraco.Core.Services
{
public static class ContentTypeServiceExtensions
{
/// <summary>
/// Gets all of the element types (e.g. content types that have been marked as an element type).
/// </summary>
/// <param name="contentTypeService">The content type service.</param>
/// <returns>Returns all the element types.</returns>
public static IEnumerable<IContentType> GetAllElementTypes(this IContentTypeService contentTypeService)
{
if (contentTypeService == null)
{
return Enumerable.Empty<IContentType>();
}
return contentTypeService.GetAll().Where(x => x.IsElement);
}
/// <summary>
/// Returns the available composite content types for a given content type
/// </summary>

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using Umbraco.Core.Services;
using Umbraco.Web.Editors;
using Umbraco.Web.Mvc;
@@ -11,8 +12,8 @@ namespace Umbraco.Web.PropertyEditors
[System.Web.Http.HttpGet]
public IEnumerable<object> GetContentTypes()
{
return Services.ContentTypeService.GetAll()
.Where(x => x.IsElement)
return Services.ContentTypeService
.GetAllElementTypes()
.OrderBy(x => x.SortOrder)
.Select(x => new
{