Hi,
Thanks for all the work done on this Drupal 8 module.
But there is a lack of documentation and examples for the Drupal 8 version of this module.

I would like to send an email to all the users subscribed to a node.

In a hook_entity_update(Drupal\Core\Entity\EntityInterface $entity) :

- How can I get the subscribers list?
- I tried to use \Drupal::service('message_subscribe.subscribers')->sendMessage() but with no success.

Could you share an example?

Thank you very much!

Comments

maelcorm created an issue. See original summary.

liquidcms’s picture

Just starting to sort out Subscriptions but I see KarenS has created an exampe module and in that she first creates a message:

  $message = Message::create([
    'template' => $template,
    'uid' => $node->getOwnerId(),
  ]);
  $message->set('field_node_reference', $node);
  $message->set('field_published', $node->isPublished());
  $message->save();

and then does what you have tried:

  // Queue messages to the regular node subscribers about changes in published nodes.
  $subscribers = \Drupal::service('message_subscribe.subscribers');
  $subscribers->sendMessage($node, $message);
bluegeek9’s picture

Title: Drupal 8 - Documentation ? » Documentation
Category: Support request » Plan
Priority: Major » Normal

I am using this issue as a parent for other message subscribe issues related to documentation.

bluegeek9’s picture

Status: Active » Fixed
bluegeek9’s picture

//www.flaticon.com/free-icons/thank-you Thank you for your contribution! Your continued support to this project makes other volunteer contributions more sustainable.
There are multiple ways to show appreciation for the work contributed to this project including:
  • Triaging issues and adding more context to existing issues.
  • Writing documentation or patches for this project.
  • Writing blog posts or speaking about it at conferences.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.