Skip to content
Snippets Groups Projects

Issue #3432343: Add configuration for recipients plugin

6 files
+ 132
11
Compare changes
  • Side-by-side
  • Inline
Files
6
@@ -18,7 +18,7 @@ use Drupal\message\Entity\MessageTemplate;
use Drupal\message\MessageInterface;
use Drupal\message_notify\MessageNotifier;
use Drupal\message_plus\Form\EntityTemplateSettingsForm;
use Drupal\user\EntityOwnerInterface;
use Drupal\message_plus\MessageRecipientsPluginManager;
/**
* Message helper.
@@ -68,6 +68,8 @@ class MessageProvider {
* Queue factory.
* @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
* The config factory.
* @param \Drupal\message_plus\MessageRecipientsPluginManager $messageRecipientsManager
* The recipients message plugin manager.
*/
public function __construct(
protected readonly EntityTypeManagerInterface $entityTypeManager,
@@ -75,7 +77,8 @@ class MessageProvider {
protected readonly AccountInterface $currentUser,
LoggerChannelFactory $logger_channel_factory,
QueueFactory $queue_factory,
protected readonly ConfigFactoryInterface $configFactory
protected readonly ConfigFactoryInterface $configFactory,
protected readonly MessageRecipientsPluginManager $messageRecipientsManager
) {
$this->queue = $queue_factory->get(static::MESSAGE_QUEUE_WORKER);
$this->logger = $logger_channel_factory->get('message_plus');
@@ -272,10 +275,17 @@ class MessageProvider {
*/
protected function getDefaultRecipients(MessageInterface $message, ContentEntityInterface $entity) {
$recipients = [];
// @todo Move functionality to plugins.
$recipients[] = $entity instanceof EntityOwnerInterface
? $entity->getOwner()
: $message->getOwner();
$template_recipients = $message->getTemplate()
->getThirdPartySetting('message_plus', 'recipients', []);
if (
!empty($template_recipients['plugin_id']) &&
!empty($template_recipients['configuration']) &&
$recipients_plugin = $this->messageRecipientsManager
->createInstance($template_recipients['plugin_id'], $template_recipients['configuration'])
) {
$recipients = $recipients_plugin->getRecipients($entity);
}
return $recipients;
}
Loading