diff --git a/src/Umbraco.Infrastructure/Services/Notifications/CancelableEnumerableObjectNotification.cs b/src/Umbraco.Core/Events/CancelableEnumerableObjectNotification.cs similarity index 85% rename from src/Umbraco.Infrastructure/Services/Notifications/CancelableEnumerableObjectNotification.cs rename to src/Umbraco.Core/Events/CancelableEnumerableObjectNotification.cs index 3875967530..1db0380af5 100644 --- a/src/Umbraco.Infrastructure/Services/Notifications/CancelableEnumerableObjectNotification.cs +++ b/src/Umbraco.Core/Events/CancelableEnumerableObjectNotification.cs @@ -2,9 +2,8 @@ // See LICENSE for more details. using System.Collections.Generic; -using Umbraco.Cms.Core.Events; -namespace Umbraco.Cms.Infrastructure.Services.Notifications +namespace Umbraco.Cms.Core.Events { public abstract class CancelableEnumerableObjectNotification : CancelableObjectNotification> { diff --git a/src/Umbraco.Infrastructure/Services/Notifications/CancelableObjectNotification.cs b/src/Umbraco.Core/Events/CancelableObjectNotification.cs similarity index 86% rename from src/Umbraco.Infrastructure/Services/Notifications/CancelableObjectNotification.cs rename to src/Umbraco.Core/Events/CancelableObjectNotification.cs index 603ee9efbb..a976ff51d9 100644 --- a/src/Umbraco.Infrastructure/Services/Notifications/CancelableObjectNotification.cs +++ b/src/Umbraco.Core/Events/CancelableObjectNotification.cs @@ -1,9 +1,7 @@ // Copyright (c) Umbraco. // See LICENSE for more details. -using Umbraco.Cms.Core.Events; - -namespace Umbraco.Cms.Infrastructure.Services.Notifications +namespace Umbraco.Cms.Core.Events { public abstract class CancelableObjectNotification : ObjectNotification, ICancelableNotification where T : class { diff --git a/src/Umbraco.Infrastructure/Services/Notifications/CopiedNotification.cs b/src/Umbraco.Core/Events/CopiedNotification.cs similarity index 86% rename from src/Umbraco.Infrastructure/Services/Notifications/CopiedNotification.cs rename to src/Umbraco.Core/Events/CopiedNotification.cs index 653f3913aa..807ffa1282 100644 --- a/src/Umbraco.Infrastructure/Services/Notifications/CopiedNotification.cs +++ b/src/Umbraco.Core/Events/CopiedNotification.cs @@ -1,9 +1,7 @@ // Copyright (c) Umbraco. // See LICENSE for more details. -using Umbraco.Cms.Core.Events; - -namespace Umbraco.Cms.Infrastructure.Services.Notifications +namespace Umbraco.Cms.Core.Events { public abstract class CopiedNotification : ObjectNotification where T : class { diff --git a/src/Umbraco.Infrastructure/Services/Notifications/CopyingNotification.cs b/src/Umbraco.Core/Events/CopyingNotification.cs similarity index 84% rename from src/Umbraco.Infrastructure/Services/Notifications/CopyingNotification.cs rename to src/Umbraco.Core/Events/CopyingNotification.cs index ae658577b6..c89146b494 100644 --- a/src/Umbraco.Infrastructure/Services/Notifications/CopyingNotification.cs +++ b/src/Umbraco.Core/Events/CopyingNotification.cs @@ -1,9 +1,7 @@ // Copyright (c) Umbraco. // See LICENSE for more details. -using Umbraco.Cms.Core.Events; - -namespace Umbraco.Cms.Infrastructure.Services.Notifications +namespace Umbraco.Cms.Core.Events { public abstract class CopyingNotification : CancelableObjectNotification where T : class { diff --git a/src/Umbraco.Infrastructure/Services/Notifications/DeletedNotification.cs b/src/Umbraco.Core/Events/DeletedNotification.cs similarity index 80% rename from src/Umbraco.Infrastructure/Services/Notifications/DeletedNotification.cs rename to src/Umbraco.Core/Events/DeletedNotification.cs index 99016ca073..6645059428 100644 --- a/src/Umbraco.Infrastructure/Services/Notifications/DeletedNotification.cs +++ b/src/Umbraco.Core/Events/DeletedNotification.cs @@ -2,9 +2,8 @@ // See LICENSE for more details. using System.Collections.Generic; -using Umbraco.Cms.Core.Events; -namespace Umbraco.Cms.Infrastructure.Services.Notifications +namespace Umbraco.Cms.Core.Events { public abstract class DeletedNotification : EnumerableObjectNotification { diff --git a/src/Umbraco.Infrastructure/Services/Notifications/EnumerableObjectNotification.cs b/src/Umbraco.Core/Events/EnumerableObjectNotification.cs similarity index 84% rename from src/Umbraco.Infrastructure/Services/Notifications/EnumerableObjectNotification.cs rename to src/Umbraco.Core/Events/EnumerableObjectNotification.cs index 0201040ecf..a80b8bf7ee 100644 --- a/src/Umbraco.Infrastructure/Services/Notifications/EnumerableObjectNotification.cs +++ b/src/Umbraco.Core/Events/EnumerableObjectNotification.cs @@ -2,9 +2,8 @@ // See LICENSE for more details. using System.Collections.Generic; -using Umbraco.Cms.Core.Events; -namespace Umbraco.Cms.Infrastructure.Services.Notifications +namespace Umbraco.Cms.Core.Events { public abstract class EnumerableObjectNotification : ObjectNotification> { diff --git a/src/Umbraco.Core/Events/EventAggregator.cs b/src/Umbraco.Core/Events/EventAggregator.cs index edb97c1672..f4602039dd 100644 --- a/src/Umbraco.Core/Events/EventAggregator.cs +++ b/src/Umbraco.Core/Events/EventAggregator.cs @@ -55,6 +55,30 @@ namespace Umbraco.Cms.Core.Events PublishNotification(notification); Task.WaitAll(PublishNotificationAsync(notification)); } + + public bool PublishCancelable(TCancelableNotification notification) + where TCancelableNotification : ICancelableNotification + { + if (notification == null) + { + throw new ArgumentNullException(nameof(notification)); + } + + Publish(notification); + return notification.Cancel; + } + + public async Task PublishCancelableAsync(TCancelableNotification notification) + where TCancelableNotification : ICancelableNotification + { + if (notification == null) + { + throw new ArgumentNullException(nameof(notification)); + } + + await PublishAsync(notification); + return notification.Cancel; + } } /// diff --git a/src/Umbraco.Core/Events/IEventAggregator.cs b/src/Umbraco.Core/Events/IEventAggregator.cs index 82cc1a68ca..d59f75b040 100644 --- a/src/Umbraco.Core/Events/IEventAggregator.cs +++ b/src/Umbraco.Core/Events/IEventAggregator.cs @@ -29,5 +29,23 @@ namespace Umbraco.Cms.Core.Events /// The notification object. void Publish(TNotification notification) where TNotification : INotification; + + /// + /// Publishes a cancelable notification to the notification subscribers + /// + /// The type of notification being handled. + /// + /// True if the notification was cancelled by a subscriber, false otherwise + bool PublishCancelable(TCancelableNotification notification) + where TCancelableNotification : ICancelableNotification; + + /// + /// Publishes a cancelable notification async to the notification subscribers + /// + /// The type of notification being handled. + /// + /// True if the notification was cancelled by a subscriber, false otherwise + Task PublishCancelableAsync(TCancelableNotification notification) + where TCancelableNotification : ICancelableNotification; } } diff --git a/src/Umbraco.Core/Events/ImportPackageEventArgs.cs b/src/Umbraco.Core/Events/ImportPackageEventArgs.cs deleted file mode 100644 index 5b04bff318..0000000000 --- a/src/Umbraco.Core/Events/ImportPackageEventArgs.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Collections.Generic; -using Umbraco.Cms.Core.Models.Packaging; - -namespace Umbraco.Cms.Core.Events -{ - public class ImportPackageEventArgs : CancellableEnumerableObjectEventArgs, IEquatable> - { - public ImportPackageEventArgs(TEntity eventObject, IPackageInfo packageMetaData, bool canCancel) - : base(new[] { eventObject }, canCancel) - { - PackageMetaData = packageMetaData ?? throw new ArgumentNullException(nameof(packageMetaData)); - } - - public ImportPackageEventArgs(TEntity eventObject, IPackageInfo packageMetaData) - : this(eventObject, packageMetaData, true) - { - - } - - public IPackageInfo PackageMetaData { get; } - - public IEnumerable InstallationSummary => EventObject; - - public bool Equals(ImportPackageEventArgs other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - // TODO: MetaData for package metadata has no equality operators :/ - return base.Equals(other) && PackageMetaData.Equals(other.PackageMetaData); - } - - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != this.GetType()) return false; - return Equals((ImportPackageEventArgs) obj); - } - - public override int GetHashCode() - { - unchecked - { - return (base.GetHashCode() * 397) ^ PackageMetaData.GetHashCode(); - } - } - - public static bool operator ==(ImportPackageEventArgs left, ImportPackageEventArgs right) - { - return Equals(left, right); - } - - public static bool operator !=(ImportPackageEventArgs left, ImportPackageEventArgs right) - { - return !Equals(left, right); - } - } -} diff --git a/src/Umbraco.Core/Events/ImportedPackageNotification.cs b/src/Umbraco.Core/Events/ImportedPackageNotification.cs new file mode 100644 index 0000000000..f4f0bac1b4 --- /dev/null +++ b/src/Umbraco.Core/Events/ImportedPackageNotification.cs @@ -0,0 +1,19 @@ +using Umbraco.Cms.Core.Models.Packaging; +using Umbraco.Cms.Core.Packaging; + +namespace Umbraco.Cms.Core.Events +{ + public class ImportedPackageNotification : StatefulNotification + { + + public ImportedPackageNotification(InstallationSummary installationSummary, IPackageInfo packageMetaData) + { + InstallationSummary = installationSummary; + PackageMetaData = packageMetaData; + } + + public IPackageInfo PackageMetaData { get; } + + public InstallationSummary InstallationSummary { get; } + } +} diff --git a/src/Umbraco.Core/Events/ImportingPackageNotification.cs b/src/Umbraco.Core/Events/ImportingPackageNotification.cs new file mode 100644 index 0000000000..143fad3ff4 --- /dev/null +++ b/src/Umbraco.Core/Events/ImportingPackageNotification.cs @@ -0,0 +1,19 @@ +using Umbraco.Cms.Core.Models.Packaging; + +namespace Umbraco.Cms.Core.Events +{ + public class ImportingPackageNotification : StatefulNotification, ICancelableNotification + { + public ImportingPackageNotification(string packageName, IPackageInfo packageMetaData) + { + PackageName = packageName; + PackageMetaData = packageMetaData; + } + + public string PackageName { get; } + + public IPackageInfo PackageMetaData { get; } + + public bool Cancel { get; set; } + } +} diff --git a/src/Umbraco.Infrastructure/Services/Notifications/MovedNotification.cs b/src/Umbraco.Core/Events/MovedNotification.cs similarity index 86% rename from src/Umbraco.Infrastructure/Services/Notifications/MovedNotification.cs rename to src/Umbraco.Core/Events/MovedNotification.cs index 35b587f73c..af96e70feb 100644 --- a/src/Umbraco.Infrastructure/Services/Notifications/MovedNotification.cs +++ b/src/Umbraco.Core/Events/MovedNotification.cs @@ -2,9 +2,8 @@ // See LICENSE for more details. using System.Collections.Generic; -using Umbraco.Cms.Core.Events; -namespace Umbraco.Cms.Infrastructure.Services.Notifications +namespace Umbraco.Cms.Core.Events { public abstract class MovedNotification : ObjectNotification>> { diff --git a/src/Umbraco.Infrastructure/Services/Notifications/MovingNotification.cs b/src/Umbraco.Core/Events/MovingNotification.cs similarity index 86% rename from src/Umbraco.Infrastructure/Services/Notifications/MovingNotification.cs rename to src/Umbraco.Core/Events/MovingNotification.cs index 2781c0ba57..917cc283aa 100644 --- a/src/Umbraco.Infrastructure/Services/Notifications/MovingNotification.cs +++ b/src/Umbraco.Core/Events/MovingNotification.cs @@ -2,9 +2,8 @@ // See LICENSE for more details. using System.Collections.Generic; -using Umbraco.Cms.Core.Events; -namespace Umbraco.Cms.Infrastructure.Services.Notifications +namespace Umbraco.Cms.Core.Events { public abstract class MovingNotification : CancelableObjectNotification>> { diff --git a/src/Umbraco.Infrastructure/Services/Notifications/ObjectNotification.cs b/src/Umbraco.Core/Events/ObjectNotification.cs similarity index 81% rename from src/Umbraco.Infrastructure/Services/Notifications/ObjectNotification.cs rename to src/Umbraco.Core/Events/ObjectNotification.cs index 16c57f210e..f1d957d42b 100644 --- a/src/Umbraco.Infrastructure/Services/Notifications/ObjectNotification.cs +++ b/src/Umbraco.Core/Events/ObjectNotification.cs @@ -1,9 +1,7 @@ // Copyright (c) Umbraco. // See LICENSE for more details. -using Umbraco.Cms.Core.Events; - -namespace Umbraco.Cms.Infrastructure.Services.Notifications +namespace Umbraco.Cms.Core.Events { public abstract class ObjectNotification : StatefulNotification where T : class { diff --git a/src/Umbraco.Infrastructure/Services/Notifications/RolledBackNotification.cs b/src/Umbraco.Core/Events/RolledBackNotification.cs similarity index 77% rename from src/Umbraco.Infrastructure/Services/Notifications/RolledBackNotification.cs rename to src/Umbraco.Core/Events/RolledBackNotification.cs index 326b224478..596cb29520 100644 --- a/src/Umbraco.Infrastructure/Services/Notifications/RolledBackNotification.cs +++ b/src/Umbraco.Core/Events/RolledBackNotification.cs @@ -1,9 +1,7 @@ // Copyright (c) Umbraco. // See LICENSE for more details. -using Umbraco.Cms.Core.Events; - -namespace Umbraco.Cms.Infrastructure.Services.Notifications +namespace Umbraco.Cms.Core.Events { public abstract class RolledBackNotification : ObjectNotification where T : class { diff --git a/src/Umbraco.Infrastructure/Services/Notifications/RollingBackNotification.cs b/src/Umbraco.Core/Events/RollingBackNotification.cs similarity index 78% rename from src/Umbraco.Infrastructure/Services/Notifications/RollingBackNotification.cs rename to src/Umbraco.Core/Events/RollingBackNotification.cs index 6afa46d6f1..265669bcdf 100644 --- a/src/Umbraco.Infrastructure/Services/Notifications/RollingBackNotification.cs +++ b/src/Umbraco.Core/Events/RollingBackNotification.cs @@ -1,9 +1,7 @@ // Copyright (c) Umbraco. // See LICENSE for more details. -using Umbraco.Cms.Core.Events; - -namespace Umbraco.Cms.Infrastructure.Services.Notifications +namespace Umbraco.Cms.Core.Events { public abstract class RollingBackNotification : CancelableObjectNotification where T : class { diff --git a/src/Umbraco.Infrastructure/Services/Notifications/SavedNotification.cs b/src/Umbraco.Core/Events/SavedNotification.cs similarity index 84% rename from src/Umbraco.Infrastructure/Services/Notifications/SavedNotification.cs rename to src/Umbraco.Core/Events/SavedNotification.cs index b6a363019f..9ed7afd933 100644 --- a/src/Umbraco.Infrastructure/Services/Notifications/SavedNotification.cs +++ b/src/Umbraco.Core/Events/SavedNotification.cs @@ -2,9 +2,8 @@ // See LICENSE for more details. using System.Collections.Generic; -using Umbraco.Cms.Core.Events; -namespace Umbraco.Cms.Infrastructure.Services.Notifications +namespace Umbraco.Cms.Core.Events { public abstract class SavedNotification : EnumerableObjectNotification { diff --git a/src/Umbraco.Infrastructure/Services/Notifications/SavingNotification.cs b/src/Umbraco.Core/Events/SavingNotification.cs similarity index 84% rename from src/Umbraco.Infrastructure/Services/Notifications/SavingNotification.cs rename to src/Umbraco.Core/Events/SavingNotification.cs index df84628b93..d58607be10 100644 --- a/src/Umbraco.Infrastructure/Services/Notifications/SavingNotification.cs +++ b/src/Umbraco.Core/Events/SavingNotification.cs @@ -2,9 +2,8 @@ // See LICENSE for more details. using System.Collections.Generic; -using Umbraco.Cms.Core.Events; -namespace Umbraco.Cms.Infrastructure.Services.Notifications +namespace Umbraco.Cms.Core.Events { public abstract class SavingNotification : CancelableEnumerableObjectNotification { diff --git a/src/Umbraco.Infrastructure/Services/Notifications/SortedNotification.cs b/src/Umbraco.Core/Events/SortedNotification.cs similarity index 80% rename from src/Umbraco.Infrastructure/Services/Notifications/SortedNotification.cs rename to src/Umbraco.Core/Events/SortedNotification.cs index 88b0e11cf6..11c81f001b 100644 --- a/src/Umbraco.Infrastructure/Services/Notifications/SortedNotification.cs +++ b/src/Umbraco.Core/Events/SortedNotification.cs @@ -2,9 +2,8 @@ // See LICENSE for more details. using System.Collections.Generic; -using Umbraco.Cms.Core.Events; -namespace Umbraco.Cms.Infrastructure.Services.Notifications +namespace Umbraco.Cms.Core.Events { public abstract class SortedNotification : EnumerableObjectNotification { diff --git a/src/Umbraco.Infrastructure/Services/Notifications/SortingNotification.cs b/src/Umbraco.Core/Events/SortingNotification.cs similarity index 81% rename from src/Umbraco.Infrastructure/Services/Notifications/SortingNotification.cs rename to src/Umbraco.Core/Events/SortingNotification.cs index 7d040a8b28..78a301dfb5 100644 --- a/src/Umbraco.Infrastructure/Services/Notifications/SortingNotification.cs +++ b/src/Umbraco.Core/Events/SortingNotification.cs @@ -2,9 +2,8 @@ // See LICENSE for more details. using System.Collections.Generic; -using Umbraco.Cms.Core.Events; -namespace Umbraco.Cms.Infrastructure.Services.Notifications +namespace Umbraco.Cms.Core.Events { public abstract class SortingNotification : CancelableEnumerableObjectNotification { diff --git a/src/Umbraco.Infrastructure/Services/Notifications/StatefulNotification.cs b/src/Umbraco.Core/Events/StatefulNotification.cs similarity index 87% rename from src/Umbraco.Infrastructure/Services/Notifications/StatefulNotification.cs rename to src/Umbraco.Core/Events/StatefulNotification.cs index 07831611fe..4d86262322 100644 --- a/src/Umbraco.Infrastructure/Services/Notifications/StatefulNotification.cs +++ b/src/Umbraco.Core/Events/StatefulNotification.cs @@ -1,9 +1,8 @@ // Copyright (c) Umbraco. using System.Collections.Generic; -using Umbraco.Cms.Core.Events; -namespace Umbraco.Cms.Infrastructure.Services.Notifications +namespace Umbraco.Cms.Core.Events { public abstract class StatefulNotification : IStatefulNotification { diff --git a/src/Umbraco.Core/Events/UnattendedInstallNotification.cs b/src/Umbraco.Core/Events/UnattendedInstallNotification.cs index 5bfb64e08f..20373ad15b 100644 --- a/src/Umbraco.Core/Events/UnattendedInstallNotification.cs +++ b/src/Umbraco.Core/Events/UnattendedInstallNotification.cs @@ -1,7 +1,4 @@ -using System; -using Umbraco.Cms.Core.Events; - -namespace Umbraco.Core.Events +namespace Umbraco.Cms.Core.Events { /// /// Used to notify that an Unattended install has completed diff --git a/src/Umbraco.Core/Events/UninstallPackageEventArgs.cs b/src/Umbraco.Core/Events/UninstallPackageEventArgs.cs deleted file mode 100644 index e83210b3a0..0000000000 --- a/src/Umbraco.Core/Events/UninstallPackageEventArgs.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Collections.Generic; -using Umbraco.Cms.Core.Packaging; - -namespace Umbraco.Cms.Core.Events -{ - public class UninstallPackageEventArgs: CancellableObjectEventArgs> - { - public UninstallPackageEventArgs(IEnumerable eventObject, bool canCancel) - : base(eventObject, canCancel) - { - } - - public IEnumerable UninstallationSummary => EventObject; - } -} diff --git a/src/Umbraco.Core/Events/UninstallPackageNotification.cs b/src/Umbraco.Core/Events/UninstallPackageNotification.cs new file mode 100644 index 0000000000..2ce76fd5fc --- /dev/null +++ b/src/Umbraco.Core/Events/UninstallPackageNotification.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using Umbraco.Cms.Core.Packaging; + +namespace Umbraco.Cms.Core.Events +{ + public class UninstallPackageNotification : INotification + { + public UninstallPackageNotification(IEnumerable uninstallationSummary) => UninstallationSummary = uninstallationSummary; + + public IEnumerable UninstallationSummary { get; } + } +} + + diff --git a/src/Umbraco.Infrastructure/RuntimeState.cs b/src/Umbraco.Infrastructure/RuntimeState.cs index 02d4375186..76700e2001 100644 --- a/src/Umbraco.Infrastructure/RuntimeState.cs +++ b/src/Umbraco.Infrastructure/RuntimeState.cs @@ -11,7 +11,6 @@ using Umbraco.Cms.Core.Services; using Umbraco.Cms.Infrastructure.Migrations.Install; using Umbraco.Cms.Infrastructure.Migrations.Upgrade; using Umbraco.Cms.Infrastructure.Persistence; -using Umbraco.Core.Events; namespace Umbraco.Cms.Core { diff --git a/src/Umbraco.Infrastructure/Services/Implement/PackagingService.cs b/src/Umbraco.Infrastructure/Services/Implement/PackagingService.cs index 4a6e1eb8e3..f3b199751e 100644 --- a/src/Umbraco.Infrastructure/Services/Implement/PackagingService.cs +++ b/src/Umbraco.Infrastructure/Services/Implement/PackagingService.cs @@ -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 @@ -117,8 +120,12 @@ namespace Umbraco.Cms.Core.Services.Implement var compiledPackage = GetCompiledPackageInfo(packageFile); if (compiledPackage == null) throw new InvalidOperationException("Could not read the package file " + packageFile); - if (ImportingPackage.IsRaisedEventCancelled(new ImportPackageEventArgs(packageFile.Name, compiledPackage), this)) + // Trigger the Importing Package Notification and stop execution if event/user is cancelling it + var importingPackageNotification = new ImportingPackageNotification(packageFile.Name, compiledPackage); + if (_eventAggregator.PublishCancelable(importingPackageNotification)) + { return new InstallationSummary { MetaData = compiledPackage }; + } var summary = _packageInstallation.InstallPackageData(packageDefinition, compiledPackage, userId); @@ -126,7 +133,8 @@ namespace Umbraco.Cms.Core.Services.Implement _auditService.Add(AuditType.PackagerInstall, userId, -1, "Package", $"Package data installed for package '{compiledPackage.Name}'."); - ImportedPackage.RaiseEvent(new ImportPackageEventArgs(summary, compiledPackage, false), this); + // trigger the ImportedPackage event + _eventAggregator.Publish(new ImportedPackageNotification(summary, compiledPackage).WithStateFrom(importingPackageNotification)); return summary; } @@ -168,7 +176,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; } @@ -236,26 +244,5 @@ namespace Umbraco.Cms.Core.Services.Implement } #endregion - - #region Event Handlers - - /// - /// Occurs before Importing umbraco package - /// - public static event TypedEventHandler> ImportingPackage; - - /// - /// Occurs after a package is imported - /// - public static event TypedEventHandler> ImportedPackage; - - /// - /// Occurs after a package is uninstalled - /// - public static event TypedEventHandler UninstalledPackage; - - #endregion - - } } diff --git a/src/Umbraco.Infrastructure/Services/Notifications/ContentNotificationExtensions.cs b/src/Umbraco.Infrastructure/Services/Notifications/ContentNotificationExtensions.cs index c04a04ef87..426a82240c 100644 --- a/src/Umbraco.Infrastructure/Services/Notifications/ContentNotificationExtensions.cs +++ b/src/Umbraco.Infrastructure/Services/Notifications/ContentNotificationExtensions.cs @@ -1,6 +1,7 @@ // Copyright (c) Umbraco. // See LICENSE for more details. +using Umbraco.Cms.Core.Events; using Umbraco.Cms.Core.Models; namespace Umbraco.Cms.Infrastructure.Services.Notifications diff --git a/src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilderExtensions.cs b/src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilderExtensions.cs index 9a52b0b72a..322fa42291 100644 --- a/src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilderExtensions.cs +++ b/src/Umbraco.Web.Common/DependencyInjection/UmbracoBuilderExtensions.cs @@ -55,8 +55,6 @@ using Umbraco.Cms.Web.Common.Routing; using Umbraco.Cms.Web.Common.Security; using Umbraco.Cms.Web.Common.Templates; using Umbraco.Cms.Web.Common.UmbracoContext; -using Umbraco.Core.Events; -using static Umbraco.Cms.Core.Cache.HttpContextRequestAppCache; using IHostingEnvironment = Umbraco.Cms.Core.Hosting.IHostingEnvironment; namespace Umbraco.Extensions diff --git a/src/Umbraco.Web.Common/Install/CreateUnattendedUserNotificationHandler.cs b/src/Umbraco.Web.Common/Install/CreateUnattendedUserNotificationHandler.cs index 7017298a8e..73b1fc3c36 100644 --- a/src/Umbraco.Web.Common/Install/CreateUnattendedUserNotificationHandler.cs +++ b/src/Umbraco.Web.Common/Install/CreateUnattendedUserNotificationHandler.cs @@ -9,7 +9,6 @@ using Umbraco.Cms.Core.Events; using Umbraco.Cms.Core.Models.Membership; using Umbraco.Cms.Core.Security; using Umbraco.Cms.Core.Services; -using Umbraco.Core.Events; using Umbraco.Extensions; namespace Umbraco.Cms.Web.Common.Install