You are here

public function NodeTabForm::submitStop in Simplenews 8

Same name and namespace in other branches
  1. 8.2 src/Form/NodeTabForm.php \Drupal\simplenews\Form\NodeTabForm::submitStop()
  2. 3.x src/Form/NodeTabForm.php \Drupal\simplenews\Form\NodeTabForm::submitStop()

File

src/Form/NodeTabForm.php, line 332

Class

NodeTabForm
Configure simplenews subscriptions of a user.

Namespace

Drupal\simplenews\Form

Code

public function submitStop(array &$form, FormStateInterface $form_state) {
  $node = $form_state
    ->get('node');

  // Delete the mail spool entries of this newsletter issue.
  $count = $this->spoolStorage
    ->deleteMails(array(
    'nid' => $node
      ->id(),
  ));

  // Set newsletter issue to not sent yet.
  $node->simplenews_issue->status = SIMPLENEWS_STATUS_SEND_NOT;
  $node
    ->save();
  $this
    ->messenger()
    ->addMessage(t('Sending of %title was stopped. @count pending email(s) were deleted.', array(
    '%title' => $node
      ->getTitle(),
    '@count' => $count,
  )));
}