Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V9: Send content type notifications on copy #12463

Merged
merged 1 commit into from May 31, 2022

Conversation

nikolajlauridsen
Copy link
Contributor

This PR migrates #12330 to V9, adding the missing content type events when copying:

  • MemberTypes
  • DocumentTypes
  • MediaTypes

These missing events are:

  • Saving
  • Changed
  • Saved

Testing

Add notifications handlers the the expected event and try and copy the different content types.

I used this notification handler and put a breakpoint on each handle method:

using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Notifications;

namespace Umbraco.Cms.Web.UI
{
    public class TestHandler :
        INotificationHandler<MemberTypeSavedNotification>,
        INotificationHandler<MemberTypeChangedNotification>,
        INotificationHandler<MemberTypeSavingNotification>,
        INotificationHandler<ContentTypeSavedNotification>,
        INotificationHandler<ContentTypeSavingNotification>,
        INotificationHandler<ContentTypeChangedNotification>,
        INotificationHandler<MediaTypeSavedNotification>,
        INotificationHandler<MediaTypeChangedNotification>,
        INotificationHandler<MediaTypeSavingNotification>
    {
        private readonly ILogger<TestHandler> _logger;

        public TestHandler(ILogger<TestHandler> logger) => _logger = logger;

        public void Handle(MemberTypeSavingNotification notification) => _logger.LogInformation("Member type saving notification received");

        public void Handle(MemberTypeChangedNotification notification) => _logger.LogInformation("Member type changed notification received");

        public void Handle(MemberTypeSavedNotification notification) => _logger.LogInformation("Member type saved notification received");

        public void Handle(ContentTypeSavingNotification notification) => _logger.LogInformation("Content type saving notification received");

        public void Handle(ContentTypeChangedNotification notification) => _logger.LogInformation("Content type changed notification received");

        public void Handle(ContentTypeSavedNotification notification) => _logger.LogInformation("Content type saved notification received");

        public void Handle(MediaTypeSavingNotification notification) => _logger.LogInformation("MediaTypeSavingNotification received");

        public void Handle(MediaTypeChangedNotification notification) => _logger.LogInformation("Media type changed notification received");

        public void Handle(MediaTypeSavedNotification notification) => _logger.LogInformation("Media type saved notification received");

    }

    public class TestHandlerComposer : IComposer
    {
        public void Compose(IUmbracoBuilder builder) =>
            builder
                .AddNotificationHandler<MemberTypeSavedNotification, TestHandler>()
                .AddNotificationHandler<MemberTypeChangedNotification, TestHandler>()
                .AddNotificationHandler<MemberTypeSavingNotification, TestHandler>()
                .AddNotificationHandler<ContentTypeSavedNotification, TestHandler>()
                .AddNotificationHandler<ContentTypeChangedNotification, TestHandler>()
                .AddNotificationHandler<ContentTypeSavingNotification, TestHandler>()
                .AddNotificationHandler<MediaTypeSavedNotification, TestHandler>()
                .AddNotificationHandler<MediaTypeChangedNotification, TestHandler>()
                .AddNotificationHandler<MediaTypeSavingNotification, TestHandler>();
    }
}

@Zeegaan
Copy link
Member

Zeegaan commented May 31, 2022

Tests out great 🎉

@Zeegaan Zeegaan merged commit 156fe59 into v9/9.5 May 31, 2022
@Zeegaan Zeegaan deleted the v9/bugfix/add-missing-notifications branch May 31, 2022 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants