function _simplenews_scheduler_send_new_edition in Simplenews Scheduler 8
Same name and namespace in other branches
- 6.2 simplenews_scheduler.module \_simplenews_scheduler_send_new_edition()
- 7 simplenews_scheduler.module \_simplenews_scheduler_send_new_edition()
- 2.0.x simplenews_scheduler.module \_simplenews_scheduler_send_new_edition()
Helper for hook_cron() to send a new edition.
Parameters
$edition_time: The time of the operation. Usually the current time unless testing.
$newsletter_parent_data: A row of data from {simplenews_scheduler}, as returned by simplenews_scheduler_get_newsletters_due().
$eid: The node id of the new edition to send. This should already have been created by _simplenews_scheduler_new_edition().
1 call to _simplenews_scheduler_send_new_edition()
- simplenews_scheduler_cron in ./
simplenews_scheduler.module - Implements hook_cron().
File
- ./
simplenews_scheduler.module, line 521 - Simplenews Scheduler module allows a schedule to be set for sending (and resending) a Simplenews item.
Code
function _simplenews_scheduler_send_new_edition($edition_time, $newsletter_parent_data, $eid) {
$pid = $newsletter_parent_data->nid;
// persist last_run
db_update('simplenews_scheduler')
->fields(array(
'last_run' => $edition_time,
))
->condition('nid', $pid)
->execute();
// Send the newsletter edition to each subscriber of the parent newsletter.
$node = \Drupal::entityManager()
->getStorage('node')
->load($eid);
\Drupal::service('simplenews.spool_storage')
->addFromEntity($node);
$node
->save();
}