function scheduler_api_test_scheduler_unpublish_action in Scheduler 8
Implements hook_scheduler_unpublish_action().
File
- tests/
modules/ scheduler_api_test/ scheduler_api_test.module, line 177 - Hook implementations of the Scheduler API Test module.
Code
function scheduler_api_test_scheduler_unpublish_action($node) {
if (stristr($node->title->value, 'blue')) {
// Nodes with blue in the title are simulated to cause a failure and should
// then be skipped by Scheduler.
$node
->set('title', $node->title->value . ' - unpublishing failed in API test module');
\Drupal::messenger()
->addMessage(t('Scheduler_Api_Test: Blue nodes should cause Scheduler to abandon unpublishing.'), 'status', FALSE);
return -1;
}
if (stristr($node->title->value, 'orange')) {
// Nodes with orange in the title are simulated to be processed by this
// hook, and will not be published by Scheduler.
$node
->set('title', $node->title->value . ' - unpublishing processed by API test module');
$node
->setUnpublished();
\Drupal::messenger()
->addMessage(t('Scheduler_Api_Test: Orange nodes should not have unpublishing processed by Scheduler.'), 'status', FALSE);
return 1;
}
return 0;
}