You are here

function simplenews_node_presave in Simplenews 3.x

Same name and namespace in other branches
  1. 8.2 simplenews.module \simplenews_node_presave()
  2. 8 simplenews.module \simplenews_node_presave()
  3. 7 simplenews.module \simplenews_node_presave()

Implements hook_ENTITY_TYPE_presave() for node entity.

File

./simplenews.module, line 119
Simplenews node handling, sent email, newsletter block and general hooks.

Code

function simplenews_node_presave(NodeInterface $node) {
  if (!$node
    ->hasField('simplenews_issue')) {
    return;
  }

  // Check if the newsletter is set to send on publish and needs to be sent.
  if ($node->simplenews_issue->status == SIMPLENEWS_STATUS_SEND_PUBLISH && $node
    ->isPublished()) {
    \Drupal::service('simplenews.spool_storage')
      ->addIssue($node);
  }
}