Uninstall package event/notificiation ported

This commit is contained in:
Warren Buckley
2021-03-16 16:13:15 +00:00
parent 55de69b647
commit b60c0377fb
2 changed files with 23 additions and 8 deletions

View File

@@ -0,0 +1,16 @@
using System.Collections.Generic;
using Umbraco.Cms.Core.Packaging;
namespace Umbraco.Cms.Core.Events
{
public class UninstallPackageNotification : ICancelableNotification
{
public UninstallPackageNotification(IEnumerable<UninstallationSummary> uninstallationSummary) => UninstallationSummary = uninstallationSummary;
public IEnumerable<UninstallationSummary> UninstallationSummary { get; }
public bool Cancel { get; set; }
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -22,6 +22,7 @@ namespace Umbraco.Cms.Core.Services.Implement
{
private readonly IPackageInstallation _packageInstallation;
private readonly IHostingEnvironment _hostingEnvironment;
private readonly IEventAggregator _eventAggregator;
private readonly IAuditService _auditService;
private readonly ICreatedPackagesRepository _createdPackages;
private readonly IInstalledPackagesRepository _installedPackages;
@@ -32,13 +33,15 @@ namespace Umbraco.Cms.Core.Services.Implement
ICreatedPackagesRepository createdPackages,
IInstalledPackagesRepository installedPackages,
IPackageInstallation packageInstallation,
IHostingEnvironment hostingEnvironment)
IHostingEnvironment hostingEnvironment,
IEventAggregator eventAggregator)
{
_auditService = auditService;
_createdPackages = createdPackages;
_installedPackages = installedPackages;
_packageInstallation = packageInstallation;
_hostingEnvironment = hostingEnvironment;
_eventAggregator = eventAggregator;
}
#region Package Files
@@ -168,7 +171,7 @@ namespace Umbraco.Cms.Core.Services.Implement
}
// trigger the UninstalledPackage event
UninstalledPackage.RaiseEvent(new UninstallPackageEventArgs(allSummaries, false), this);
_eventAggregator.Publish(new UninstallPackageNotification(allSummaries));
return summary;
}
@@ -249,11 +252,7 @@ namespace Umbraco.Cms.Core.Services.Implement
/// </summary>
public static event TypedEventHandler<IPackagingService, ImportPackageEventArgs<InstallationSummary>> ImportedPackage;
/// <summary>
/// Occurs after a package is uninstalled
/// </summary>
public static event TypedEventHandler<IPackagingService, UninstallPackageEventArgs> UninstalledPackage;
#endregion