notification-bundle icon indicating copy to clipboard operation
notification-bundle copied to clipboard

Adding removeNotificationAction to NotificationController

Open LeandroLuccerini opened this issue 6 years ago • 2 comments

This PR is about removing Notifications from Notifiable point of view.

Let's think about a User (that is a Notifiable) point of view. It can be able to delete his own notifications.

What i have done

As you can see in commits descriptions

  1. Added a database level "ON DELETE CASCADE" behaviour to NotifibiableNotification. This means that if a notification is deleted all the links between it and a Notifiable are deleted too. It was realized by ON DELETE and not by doctrine persist clause just for performances.
  2. Added NotificationController#removeNotificationAction to handle deletion of a NotifiableNotification. Added also the generation of "notification_remove" route into Twig\NotificationExtension
  3. Added UniqueConstraint to NotifiableNotification on columns notifiable_entity_id and notification_id to assure no duplicates of the same notification for a Notifiable
  4. Updated NotificationManager#removeNotification, now removes also Notification without any link in NotifiableNotification to keep the database clean. I've also removed the flush parameter as no flush is requested to execute the query.

BC breaks

Accepting this PR means update the database schema by php bin\console doctrine:schema:update --dump-sql --force and remove $flush parameter when using NotificationManager#removeNotification

Let me know what you think. Thanks

LeandroLuccerini avatar Nov 16 '18 17:11 LeandroLuccerini

Any news on this PR?

GGGGino avatar Dec 23 '18 01:12 GGGGino

:+1:

Jeroenkeesom avatar Jan 09 '19 20:01 Jeroenkeesom