function scheduler_api_test_scheduler_list in Scheduler 2.x
Implements hook_scheduler_list().
File
- tests/
modules/ scheduler_api_test/ scheduler_api_test.module, line 48 - Hook implementations of the Scheduler API Test module.
Code
function scheduler_api_test_scheduler_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() == "Pink {$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() == "Pink {$entityTypeId} list unpublish me") {
$entity
->set('unpublish_on', $request_time)
->save();
$ids[] = $id;
}
}
return $ids;
}