21 private const SUPPORTED_NOTIFICATION_TYPES = [
'translate-mgs-message-added' ];
23 public function __construct(
25 private readonly UserFactory $userFactory,
29 public static function registerHooks( array &$hooks ):
void {
30 $hooks[
'BeforeCreateEchoEvent'][] =
static function (
31 array &$notifications,
32 array &$notificationCategories,
33 array &$notificationIcons
35 Services::getInstance()->getMessageGroupSubscriptionHookHandler()->onBeforeCreateEchoEvent(
37 $notificationCategories,
42 $hooks[
'EchoGetBundleRules'][] =
static function ( Event $event,
string &$bundleKey ) {
43 Services::getInstance()->getMessageGroupSubscriptionHookHandler()->onEchoGetBundleRules(
50 public function onBeforeCreateEchoEvent(
51 array &$notifications,
52 array &$notificationCategories,
53 array &$notificationIcons
55 $messageGroupSubscription = $this->messageGroupSubscription;
56 $userFactory = $this->userFactory;
57 $notificationCategories[
'translate-message-group-subscription' ] = [
58 'tooltip' =>
'echo-pref-tooltip-translate-message-group-subscription'
61 $notifications[
'translate-mgs-message-added' ] = [
62 'category' =>
'translate-message-group-subscription',
64 'section' =>
'message',
65 'presentation-model' => MessageGroupSubscriptionPresentationModel::class,
70 AttributeManager::ATTR_LOCATORS =>
static function ( Event $event ) use (
71 $messageGroupSubscription,
74 $extra = $event->getExtra();
75 $sourceGroupIds = $extra[
'sourceGroupIds'] ?? [];
78 if ( $sourceGroupIds ) {
83 $commonUserIds = $messageGroupSubscription->getGroupSubscriberUnion( $sourceGroupIds );
86 $iterator = $messageGroupSubscription->getGroupSubscribers( $extra[
'groupId'] );
88 foreach ( $iterator as $userIdentityValue ) {
89 if ( in_array( $userIdentityValue->getId(), $commonUserIds ) ) {
92 $usersToNotify[] = $userFactory->newFromUserIdentity( $userIdentityValue );
95 return $usersToNotify;
99 $notificationIcons[
'translate-mgs-icon' ] = [
100 'path' =>
'Translate/resources/images/bell.svg'
106 if ( in_array( $event->getType(), self::SUPPORTED_NOTIFICATION_TYPES ) ) {
107 $bundleKey = $event->getExtraParam(
'groupId' );