Provide a public method to list the roles that can use private messaging

Created on 23 January 2025, 2 months ago

Problem/Motivation

The roles that can use private messaging is of great interest.
In this module we need it in \Drupal\private_message\Plugin\EntityReferenceSelection\NotBlockedUserSelection::getCanUseRids() but it's a protected method.

Other modules, be it custom or contrib, can need this too.
I can provide an example: Private message flood, see this comment:
https://git.drupalcode.org/project/private_message_flood/-/merge_request...

As you see there, the permission of this module is being used by them! If one day we change the permission, that module will be impacted without previous advise. It would be much better if the roles list would be provided here.

Proposed resolution

  • Enable a static method in a Trait or a service that can be called anywhere, listing the roles that can use private messages;
  • Use that method in (or instead of) \Drupal\private_message\Plugin\EntityReferenceSelection\NotBlockedUserSelection::getCanUseRids().
📌 Task
Status

Active

Version

4.0

Component

Code

Created by

🇵🇹Portugal dxvargas

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024