function _api_unpublish_process in Scheduler 2.x
Generic function to process third-party unpublishing.
3 calls to _api_unpublish_process()
- scheduler_api_test_scheduler_commerce_product_unpublish_process in tests/
modules/ scheduler_api_test/ scheduler_api_test.module - Implements hook_scheduler_commerce_product_unpublish_process().
- scheduler_api_test_scheduler_media_unpublish_process in tests/
modules/ scheduler_api_test/ scheduler_api_test.module - Implements hook_scheduler_media_unpublish_process().
- scheduler_api_test_scheduler_node_unpublish_process in tests/
modules/ scheduler_api_test/ scheduler_api_test.module - Implements hook_scheduler_node_unpublish_process().
File
- tests/
modules/ scheduler_api_test/ scheduler_api_test.module, line 486 - Hook implementations of the Scheduler API Test module.
Code
function _api_unpublish_process(EntityInterface $entity) {
// Entities with 'orange {type}' in the title are simulated to be processed by
// this hook, and will not be unpublished by Scheduler.
if (stristr($entity
->label(), "orange {$entity->getEntityTypeId()}")) {
$label_field = $entity
->getEntityType()
->get('entity_keys')['label'];
$entity
->set($label_field, $entity
->label() . ' - unpublishing processed by API test module')
->save();
$entity
->setUnpublished()
->save();
\Drupal::messenger()
->addMessage(t('Scheduler_Api_Test: Orange should not have unpublishing processed by Scheduler.'), 'status', FALSE);
return 1;
}
return 0;
}