21 private UserFactory $userFactory;
22 private const SUPPORTED_NOTIFICATION_TYPES = [
'translate-mgs-message-added' ];
24 public function __construct(
26 UserFactory $userFactory
28 $this->messageGroupSubscription = $messageGroupSubscription;
29 $this->userFactory = $userFactory;
32 public static function registerHooks( array &$hooks ):
void {
33 $hooks[
'BeforeCreateEchoEvent'][] =
static function (
34 array &$notifications,
35 array &$notificationCategories,
36 array &$notificationIcons
38 Services::getInstance()->getMessageGroupSubscriptionHookHandler()->onBeforeCreateEchoEvent(
40 $notificationCategories,
45 $hooks[
'EchoGetBundleRules'][] =
static function ( Event $event,
string &$bundleKey ) {
46 Services::getInstance()->getMessageGroupSubscriptionHookHandler()->onEchoGetBundleRules(
53 public function onBeforeCreateEchoEvent(
54 array &$notifications,
55 array &$notificationCategories,
56 array &$notificationIcons
58 $messageGroupSubscription = $this->messageGroupSubscription;
59 $userFactory = $this->userFactory;
60 $notificationCategories[
'translate-message-group-subscription' ] = [
61 'tooltip' =>
'echo-pref-tooltip-translate-message-group-subscription'
64 $notifications[
'translate-mgs-message-added' ] = [
65 'category' =>
'translate-message-group-subscription',
67 'section' =>
'message',
68 'presentation-model' => MessageGroupSubscriptionPresentationModel::class,
73 AttributeManager::ATTR_LOCATORS =>
static function ( Event $event ) use (
74 $messageGroupSubscription,
77 $extra = $event->getExtra();
78 $sourceGroupIds = $extra[
'sourceGroupIds'] ?? [];
81 if ( $sourceGroupIds ) {
91 foreach ( $iterator as $userIdentityValue ) {
92 if ( in_array( $userIdentityValue->getId(), $commonUserIds ) ) {
95 $usersToNotify[] = $userFactory->newFromUserIdentity( $userIdentityValue );
98 return $usersToNotify;
102 $notificationIcons[
'translate-mgs-icon' ] = [
103 'path' =>
'Translate/resources/images/bell.svg'
109 if ( in_array( $event->getType(), self::SUPPORTED_NOTIFICATION_TYPES ) ) {
110 $bundleKey = $event->getExtraParam(
'groupId' );