function scheduler_api_test_scheduler_unpublish_process in Scheduler 2.x
Implements hook_scheduler_unpublish_process().
File
- tests/
modules/ scheduler_api_test/ scheduler_api_test.module, line 471 - Hook implementations of the Scheduler API Test module.
Code
function scheduler_api_test_scheduler_unpublish_process(EntityInterface $entity) {
// Any entity with 'blue {type}' in the title is simulated to cause a failure
// and should then be skipped by Scheduler.
if (stristr($entity
->label(), "blue {$entity->getEntityTypeId()}")) {
$label_field = $entity
->getEntityType()
->get('entity_keys')['label'];
$entity
->set($label_field, $entity
->label() . ' - unpublishing failed in API test module')
->save();
\Drupal::messenger()
->addMessage(t('Scheduler_Api_Test: Blue should cause Scheduler to abandon unpublishing.'), 'status', FALSE);
return -1;
}
return 0;
}