You are here

function simplenews_scheduler_scheduler_update in Simplenews Scheduler 2.0.x

Same name and namespace in other branches
  1. 8 simplenews_scheduler.module \simplenews_scheduler_scheduler_update()
  2. 6.2 simplenews_scheduler.module \simplenews_scheduler_scheduler_update()
  3. 7 simplenews_scheduler.module \simplenews_scheduler_scheduler_update()

Updates a scheduler record with any housekeeping changes and saves it.

This should be called once a new edition has been created. This sets the next_run time on the scheduler.

@todo: Make this a general API function for saving a new or existing scheduler?

Parameters

$newsletter_parent_data: A row of data from {simplenews_scheduler}, as returned by simplenews_scheduler_get_newsletters_due().

$now_time: The time of the operation.

2 calls to simplenews_scheduler_scheduler_update()
SimplenewsSchedulerEditionDueTest::testEditionsDue in tests/src/Functional/SimplenewsSchedulerEditionDueTest.php
Test simplenews_scheduler_get_newsletters_due().
simplenews_scheduler_cron in ./simplenews_scheduler.module
Implements hook_cron().

File

./simplenews_scheduler.module, line 349
Simplenews Scheduler module allows a schedule to be set for sending (and resending) a Simplenews item.

Code

function simplenews_scheduler_scheduler_update($newsletter_parent_data, $now_time) {

  // Set the run time for the next edition.
  $newsletter_parent_data->next_run = simplenews_scheduler_calculate_next_run_time($newsletter_parent_data, $now_time);
  \Drupal::database()
    ->merge('simplenews_scheduler')
    ->key(array(
    'nid' => $newsletter_parent_data->nid,
  ))
    ->fields(get_object_vars($newsletter_parent_data))
    ->execute();
}