You are here

interface SpoolStorageInterface in Simplenews 3.x

Same name and namespace in other branches
  1. 8.2 src/Spool/SpoolStorageInterface.php \Drupal\simplenews\Spool\SpoolStorageInterface
  2. 8 src/Spool/SpoolStorageInterface.php \Drupal\simplenews\Spool\SpoolStorageInterface

The spool storage manages a queue of mails that need to be sent.

Hierarchy

Expanded class hierarchy of SpoolStorageInterface

All classes that implement SpoolStorageInterface

12 files declare their use of SpoolStorageInterface
IssueWidget.php in src/Plugin/Field/FieldWidget/IssueWidget.php
Mailer.php in src/Mail/Mailer.php
MailerInterface.php in src/Mail/MailerInterface.php
MailSettingsForm.php in src/Form/MailSettingsForm.php
NodeTabForm.php in src/Form/NodeTabForm.php

... See full list

File

src/Spool/SpoolStorageInterface.php, line 10

Namespace

Drupal\simplenews\Spool
View source
interface SpoolStorageInterface {

  /**
   * On Hold.
   */
  const STATUS_HOLD = 0;

  /**
   * Pending, or retrying failure.
   */
  const STATUS_PENDING = 1;

  /**
   * Done, sent successfully.
   */
  const STATUS_DONE = 2;

  /**
   * In progress and locked until expired.
   */
  const STATUS_IN_PROGRESS = 3;

  /**
   * Skipped (not sent, but done).
   */
  const STATUS_SKIPPED = 4;

  /**
   * Failed, not retrying.
   */
  const STATUS_FAILED = 5;

  /**
   * Used when sending an unlimited amount of mails from the spool.
   */
  const UNLIMITED = -1;

  /**
   * This function allocates mails to be sent in current run.
   *
   * Drupal acquire_lock guarantees that no concurrency issue happened.
   * Messages with status SpoolStorageInterface::STATUS_IN_PROGRESS will only
   * be returned if the maximum send time has expired.
   *
   * @param int $limit
   *   (Optional) The maximum number of mails to load from the spool. Defaults
   *   to unlimited.
   * @param array $conditions
   *   (Optional) Array of conditions which are applied to the query. If not
   *   set, status defaults to SpoolStorageInterface::STATUS_PENDING,
   *   SpoolStorageInterface::STATUS_IN_PROGRESS.
   *
   * @return \Drupal\simplenews\Spool\SpoolListInterface
   *   A mail spool list.
   */
  public function getMails($limit = self::UNLIMITED, array $conditions = []);

  /**
   * Update status of mail data in spool table.
   *
   * Time stamp is set to current time.
   *
   * @param array $msids
   *   Array of Mail spool ids to be updated.
   * @param int $status
   *   One of the SpoolStorageInterface::STATUS_* constants.
   */
  public function updateMails(array $msids, $status);

  /**
   * Count data in mail spool table.
   *
   * @param array $conditions
   *   (Optional) Array of conditions which are applied to the query. If not
   *   set, status defaults to SpoolStorageInterface::STATUS_PENDING,
   *   SpoolStorageInterface::STATUS_IN_PROGRESS.
   *
   * @return int
   *   Count of mail spool elements of the passed in arguments.
   */
  public function countMails(array $conditions = []);

  /**
   * Remove old records from mail spool table.
   *
   * All records with status 'send' and time stamp before the expiration date
   * are removed from the spool.
   *
   * @return int
   *   Number of deleted spool rows.
   */
  public function clear();

  /**
   * Remove records from mail spool table according to the conditions.
   *
   * @return int
   *   Count deleted
   */
  public function deleteMails(array $conditions);

  /**
   * Adds a newsletter issue to the mail spool.
   *
   * @param \Drupal\Core\Entity\ContentEntityInterface $issue
   *   The newsletter issue to be sent.
   */
  public function addIssue(ContentEntityInterface $issue);

  /**
   * Deletes a newsletter issue from the mail spool.
   *
   * @param \Drupal\Core\Entity\ContentEntityInterface $issue
   *   The newsletter issue to be deleted.
   */
  public function deleteIssue(ContentEntityInterface $issue);

  /**
   * Save mail message in mail cache table.
   *
   * @param array $spool
   *   The message to be stored in the spool table, as an array containing the
   *   following keys:
   *   - entity_type
   *   - entity_id
   *   - newsletter_id
   *   - snid or data
   *   - status: (optional) Defaults to SpoolStorageInterface::STATUS_PENDING
   *   - time: (optional) Defaults to REQUEST_TIME.
   */
  public function addMail(array $spool);

  /**
   * Builds a recipient handler class for a given newsletter issue.
   *
   * @param \Drupal\Core\Entity\ContentEntityInterface $issue
   *   The newsletter issue to be sent.
   * @param array $edited_values
   *   (optional) Modified values, if called from an edit form.
   * @param bool $return_options
   *   (optional, defaults to FALSE) If set, also return the set of valid
   *   options for choice of recipient handler.
   *
   * @return \Drupal\simplenews\RecipientHandler\RecipientHandlerInterface|array
   *   A constructed recipient handler plugin.  If $return_options is set then
   *   the return is an array of two items: the recipient handler plugin and
   *   the result of RecipientHandlerManager::getOptions().
   *
   * @throws \Exception
   *   If the handler class does not exist.
   */
  public function getRecipientHandler(ContentEntityInterface $issue, array $edited_values = NULL, $return_options = FALSE);

  /**
   * Returns a summary of key newsletter issue parameters.
   *
   * @param \Drupal\Core\Entity\ContentEntityInterface $issue
   *   The newsletter issue entity.
   *
   * @return array
   *   An array containing the following elements:
   *   - count: total number of emails that will be sent or have been sent.
   *   - sent_count: number of emails sent.
   *   - error_count: number of send errors.
   *   - description: readable description of status and email counts.
   */
  public function issueSummary(ContentEntityInterface $issue);

  /**
   * Returns a count of the recipients for a newsletter issue.
   *
   * @param \Drupal\Core\Entity\ContentEntityInterface $issue
   *   The newsletter issue entity.
   *
   * @return int
   *   Count of recipients.
   */
  public function issueCountRecipients(ContentEntityInterface $issue);

}

Members

Namesort descending Modifiers Type Description Overrides
SpoolStorageInterface::addIssue public function Adds a newsletter issue to the mail spool. 1
SpoolStorageInterface::addMail public function Save mail message in mail cache table. 1
SpoolStorageInterface::clear public function Remove old records from mail spool table. 1
SpoolStorageInterface::countMails public function Count data in mail spool table. 1
SpoolStorageInterface::deleteIssue public function Deletes a newsletter issue from the mail spool. 1
SpoolStorageInterface::deleteMails public function Remove records from mail spool table according to the conditions. 1
SpoolStorageInterface::getMails public function This function allocates mails to be sent in current run. 1
SpoolStorageInterface::getRecipientHandler public function Builds a recipient handler class for a given newsletter issue. 1
SpoolStorageInterface::issueCountRecipients public function Returns a count of the recipients for a newsletter issue. 1
SpoolStorageInterface::issueSummary public function Returns a summary of key newsletter issue parameters. 1
SpoolStorageInterface::STATUS_DONE constant Done, sent successfully.
SpoolStorageInterface::STATUS_FAILED constant Failed, not retrying.
SpoolStorageInterface::STATUS_HOLD constant On Hold.
SpoolStorageInterface::STATUS_IN_PROGRESS constant In progress and locked until expired.
SpoolStorageInterface::STATUS_PENDING constant Pending, or retrying failure.
SpoolStorageInterface::STATUS_SKIPPED constant Skipped (not sent, but done).
SpoolStorageInterface::UNLIMITED constant Used when sending an unlimited amount of mails from the spool.
SpoolStorageInterface::updateMails public function Update status of mail data in spool table. 1