Skip to content

Which message should be passed to SubscribersInterface::getSubscribers()? #107

@pfrenssen

Description

@pfrenssen

I'm looking at using Message Subscribe for subscribing users to forum discussions.

I'm confused about the following method that is included in SubscribersInterface:

  /**
   * Retrieve a list of subscribers for a given entity.
   *
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The entity to retrieve subscribers for.
   * @param \Drupal\message\MessageInterface $message
   *   The message entity.
   * @param array $options
   *   (optional) An array of options with the same elements as the
   *   `$subscribe_options` array for `self::sendMessage()`.
   * @param array $context
   *   (optional) The context array, passed by reference. This has the same
   *   elements as the `$context` paramater for `self::sendMessage()`.
   *
   * @return \Drupal\message_subscribe\Subscribers\DeliveryCandidateInterface[]
   *   Array of delivery candidate objects keyed with the user IDs to send
   *   notifications to.
   */
  public function getSubscribers(EntityInterface $entity, MessageInterface $message, array $options = [], array &$context = []);

If we call this method we are required to pass in a Message entity. Which message should this be? Is this solely intended to retrieve the list of subscribers when we are already about to send a message?

What are we supposed to do if we want to get a list of subscribers to show in the admin UI?

Looking at the current implementation it even seems that this $message is unneeded. It gets passed on to the message_subscribe_message_subscribe_get_subscribers() hook implementation but there it is unused.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions