You are here

function scheduler_cron in Scheduler 8

Same name and namespace in other branches
  1. 5 scheduler.module \scheduler_cron()
  2. 6 scheduler.module \scheduler_cron()
  3. 7 scheduler.module \scheduler_cron()
  4. 2.x scheduler.module \scheduler_cron()

Implements hook_cron().

9 calls to scheduler_cron()
SchedulerApiTest::testAllowedPublishing in tests/src/Functional/SchedulerApiTest.php
Covers hook_scheduler_allow_publishing()
SchedulerApiTest::testAllowedUnpublishing in tests/src/Functional/SchedulerApiTest.php
Covers hook_scheduler_allow_unpublishing()
SchedulerApiTest::testApiNodeAction in tests/src/Functional/SchedulerApiTest.php
Covers six events.
SchedulerApiTest::testHookPublishUnpublishAction in tests/src/Functional/SchedulerApiTest.php
Test when other modules process the publish and unpublish actions.
SchedulerApiTest::testNidList in tests/src/Functional/SchedulerApiTest.php
Covers hook_scheduler_nid_list($action)

... See full list

1 string reference to 'scheduler_cron'
scheduler_cron_is_running in ./scheduler.module
Return whether Scheduler cron is running.

File

./scheduler.module, line 566
Scheduler publishes and unpublishes nodes on dates specified by the user.

Code

function scheduler_cron() {

  // Use drupal_static so that any function can find out if we are running
  // Scheduler cron. Set the default value to FALSE, then turn on the flag.
  // @see scheduler_cron_is_running()
  $scheduler_cron =& drupal_static(__FUNCTION__, FALSE);
  $scheduler_cron = TRUE;

  /** @var \Drupal\scheduler\SchedulerManager $scheduler_manager */
  $scheduler_manager = \Drupal::service('scheduler.manager');
  $scheduler_manager
    ->publish();
  $scheduler_manager
    ->unpublish();

  // Scheduler 7.x provided hook_scheduler_api() which has been replaced by
  // event dispatching in 8.x. Display a warning in the log if any of these
  // hooks still exist, so that admins and developers are informed.
  foreach (Drupal::moduleHandler()
    ->getImplementations('scheduler_api') as $module) {
    \Drupal::logger('scheduler')
      ->warning('Function %function has not been executed. In Drupal 8, implementations of hook_scheduler_api() should be replaced by Scheduler event listeners.', [
      '%function' => $module . '_scheduler_api',
    ]);
  }

  // Reset the static scheduler_cron flag.
  drupal_static_reset(__FUNCTION__);
}