Merge IContentTypeWithHistoryCleanup with IContentType.cs

This commit is contained in:
Nikolaj Geisle
2022-05-23 10:30:03 +02:00
parent 43add037e6
commit 94eb49cdb6
8 changed files with 18 additions and 31 deletions

View File

@@ -13,7 +13,7 @@ namespace Umbraco.Cms.Core.Models
/// </summary>
[Serializable]
[DataContract(IsReference = true)]
public class ContentType : ContentTypeCompositionBase, IContentTypeWithHistoryCleanup
public class ContentType : ContentTypeCompositionBase, IContentType
{
public const bool SupportsPublishingConst = true;

View File

@@ -4,19 +4,6 @@ using Umbraco.Cms.Core.Models.ContentEditing;
namespace Umbraco.Cms.Core.Models
{
/// <summary>
/// Defines a content type that contains a history cleanup policy.
/// </summary>
[Obsolete("This will be merged into IContentType in Umbraco 10.")]
public interface IContentTypeWithHistoryCleanup : IContentType
{
/// <summary>
/// Gets or sets the history cleanup configuration.
/// </summary>
/// <value>The history cleanup configuration.</value>
HistoryCleanup? HistoryCleanup { get; set; }
}
/// <summary>
/// Defines a ContentType, which Content is based on
/// </summary>
@@ -70,5 +57,11 @@ namespace Umbraco.Cms.Core.Models
/// <param name="newAlias"></param>
/// <returns></returns>
IContentType DeepCloneWithResetIdentities(string newAlias);
/// <summary>
/// Gets or sets the history cleanup configuration.
/// </summary>
/// <value>The history cleanup configuration.</value>
HistoryCleanup? HistoryCleanup { get; set; }
}
}

View File

@@ -131,7 +131,7 @@ namespace Umbraco.Cms.Core.Models.Mapping
MapSaveToTypeBase<DocumentTypeSave, PropertyTypeBasic>(source, target, context);
MapComposition(source, target, alias => _contentTypeService.Get(alias));
if (target is IContentTypeWithHistoryCleanup targetWithHistoryCleanup)
if (target is IContentType targetWithHistoryCleanup)
{
MapHistoryCleanup(source, targetWithHistoryCleanup);
}
@@ -147,7 +147,7 @@ namespace Umbraco.Cms.Core.Models.Mapping
: _fileService.GetTemplate(source.DefaultTemplate));
}
private static void MapHistoryCleanup(DocumentTypeSave source, IContentTypeWithHistoryCleanup target)
private static void MapHistoryCleanup(DocumentTypeSave source, IContentType target)
{
// If source history cleanup is null we don't have to map all properties
if (source.HistoryCleanup is null)
@@ -209,7 +209,7 @@ namespace Umbraco.Cms.Core.Models.Mapping
{
MapTypeToDisplayBase<DocumentTypeDisplay, PropertyTypeDisplay>(source, target);
if (source is IContentTypeWithHistoryCleanup sourceWithHistoryCleanup)
if (source is IContentType sourceWithHistoryCleanup)
{
target.HistoryCleanup = new HistoryCleanupViewModel
{

View File

@@ -511,7 +511,7 @@ namespace Umbraco.Cms.Core.Services
genericProperties,
tabs);
if (contentType is IContentTypeWithHistoryCleanup withCleanup && withCleanup.HistoryCleanup is not null)
if (contentType is IContentType withCleanup && withCleanup.HistoryCleanup is not null)
{
xml.Add(SerializeCleanupPolicy(withCleanup.HistoryCleanup));
}

View File

@@ -890,7 +890,7 @@ namespace Umbraco.Cms.Infrastructure.Packaging
UpdateContentTypesPropertyGroups(contentType, documentType.Element("Tabs"));
UpdateContentTypesProperties(contentType, documentType.Element("GenericProperties"));
if (contentType is IContentTypeWithHistoryCleanup withCleanup)
if (contentType is IContentType withCleanup)
{
UpdateHistoryCleanupPolicy(withCleanup, documentType.Element("HistoryCleanupPolicy"));
}
@@ -898,7 +898,7 @@ namespace Umbraco.Cms.Infrastructure.Packaging
return contentType;
}
private void UpdateHistoryCleanupPolicy(IContentTypeWithHistoryCleanup withCleanup, XElement? element)
private void UpdateHistoryCleanupPolicy(IContentType withCleanup, XElement? element)
{
if (element == null)
{

View File

@@ -302,7 +302,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
{
// historyCleanup property is not mandatory for api endpoint, handle the case where it's not present.
// DocumentTypeSave doesn't handle this for us like ContentType constructors do.
if (entity is IContentTypeWithHistoryCleanup entityWithHistoryCleanup)
if (entity is IContentType entityWithHistoryCleanup)
{
ContentVersionCleanupPolicyDto dto = new ContentVersionCleanupPolicyDto()
{

View File

@@ -169,9 +169,6 @@ namespace Umbraco.Cms.Infrastructure.Runtime
// Acquire the main domain - if this fails then anything that should be registered with MainDom will not operate
AcquireMainDom();
// TODO (V10): Remove this obsoleted notification publish.
await _eventAggregator.PublishAsync(new UmbracoApplicationMainDomAcquiredNotification(), cancellationToken);
// Notify for unattended install
await _eventAggregator.PublishAsync(new RuntimeUnattendedInstallNotification(), cancellationToken);
DetermineRuntimeLevel();
@@ -210,9 +207,6 @@ namespace Umbraco.Cms.Infrastructure.Runtime
break;
}
// TODO (V10): Remove this obsoleted notification publish
await _eventAggregator.PublishAsync(new UmbracoApplicationComponentsInstallingNotification(State.Level), cancellationToken);
// Initialize the components
_components.Initialize();

View File

@@ -776,7 +776,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Packaging
// Act
var contentTypes = PackageDataInstallation
.ImportDocumentType(withoutCleanupPolicy, 0)
.OfType<IContentTypeWithHistoryCleanup>();
.OfType<IContentType>();
// Assert
Assert.Multiple(() =>
@@ -795,7 +795,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Packaging
// Act
var contentTypes = PackageDataInstallation
.ImportDocumentType(docTypeElement, 0)
.OfType<IContentTypeWithHistoryCleanup>();
.OfType<IContentType>();
// Assert
Assert.Multiple(() =>
@@ -817,11 +817,11 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Packaging
// Act
var contentTypes = PackageDataInstallation
.ImportDocumentType(withCleanupPolicy, 0)
.OfType<IContentTypeWithHistoryCleanup>();
.OfType<IContentType>();
var contentTypesUpdated = PackageDataInstallation
.ImportDocumentType(withoutCleanupPolicy, 0)
.OfType<IContentTypeWithHistoryCleanup>();
.OfType<IContentType>();
// Assert
Assert.Multiple(() =>