Files
Umbraco-CMS/src/Umbraco.Core/Extensions/DeliveryApiSettingsExtensions.cs
Kenn Jacobsen d2a8068ca6 Filter out disallowed content types from the delivery API content index (#14156)
* Filter out disallowed content types from the delivery api content index

* Added .

* Allow children of disallowed content types in the index

---------

Co-authored-by: Elitsa <elm@umbraco.dk>
2023-04-27 10:30:30 +02:00

20 lines
910 B
C#

using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Models.PublishedContent;
namespace Umbraco.Extensions;
public static class DeliveryApiSettingsExtensions
{
public static bool IsAllowedContentType(this DeliveryApiSettings settings, IPublishedContent content)
=> settings.IsAllowedContentType(content.ContentType.Alias);
public static bool IsDisallowedContentType(this DeliveryApiSettings settings, IPublishedContent content)
=> settings.IsDisallowedContentType(content.ContentType.Alias);
public static bool IsAllowedContentType(this DeliveryApiSettings settings, string contentTypeAlias)
=> settings.IsDisallowedContentType(contentTypeAlias) is false;
public static bool IsDisallowedContentType(this DeliveryApiSettings settings, string contentTypeAlias)
=> settings.DisallowedContentTypeAliases.InvariantContains(contentTypeAlias);
}