You are here

function scheduler_api_test_scheduler_node_list in Scheduler 2.x

Implements hook_scheduler_node_list().

2 calls to scheduler_api_test_scheduler_node_list()
scheduler_api_test_scheduler_commerce_product_list in tests/modules/scheduler_api_test/scheduler_api_test.module
Implements hook_scheduler_commerce_product_list().
scheduler_api_test_scheduler_media_list in tests/modules/scheduler_api_test/scheduler_api_test.module
Implements hook_scheduler_media_list().

File

tests/modules/scheduler_api_test/scheduler_api_test.module, line 72
Hook implementations of the Scheduler API Test module.

Code

function scheduler_api_test_scheduler_node_list($process, $entityTypeId) {
  $ids = [];
  $request_time = \Drupal::time()
    ->getRequestTime();
  $results = _scheduler_api_test_get_entities($entityTypeId);
  foreach ($results as $id => $entity) {

    // If publishing and this is the 'publish me' test entity, set the date and
    // add the id to the list.
    if ($process == 'publish' && !$entity
      ->isPublished() && $entity
      ->label() == "Purple {$entityTypeId} list publish me") {
      $entity
        ->set('publish_on', $request_time)
        ->save();
      $ids[] = $id;
    }

    // If unpublishing and this is the 'unpublish me' test entity, set the date
    // and add the id to the list.
    if ($process == 'unpublish' && $entity
      ->isPublished() && $entity
      ->label() == "Purple {$entityTypeId} list unpublish me") {
      $entity
        ->set('unpublish_on', $request_time)
        ->save();
      $ids[] = $id;
    }
  }
  return $ids;
}