You are here

function _api_publish_process in Scheduler 2.x

Generic function to process third-party publishing.

3 calls to _api_publish_process()
scheduler_api_test_scheduler_commerce_product_publish_process in tests/modules/scheduler_api_test/scheduler_api_test.module
Implements hook_scheduler_commerce_product_publish_process().
scheduler_api_test_scheduler_media_publish_process in tests/modules/scheduler_api_test/scheduler_api_test.module
Implements hook_scheduler_media_publish_process().
scheduler_api_test_scheduler_node_publish_process in tests/modules/scheduler_api_test/scheduler_api_test.module
Implements hook_scheduler_node_publish_process().

File

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

Code

function _api_publish_process(EntityInterface $entity) {

  // Entities with 'yellow {type}' in the title are simulated to be processed
  // by this hook, and will not be published by Scheduler.
  if (stristr($entity
    ->label(), "yellow {$entity->getEntityTypeId()}")) {
    $label_field = $entity
      ->getEntityType()
      ->get('entity_keys')['label'];
    $entity
      ->set($label_field, $entity
      ->label() . ' - publishing processed by API test module');
    $entity
      ->setPublished()
      ->save();
    \Drupal::messenger()
      ->addMessage(t('Scheduler_Api_Test: Yellow should not have publishing processed by Scheduler.'), 'status', FALSE);
    return 1;
  }
  return 0;
}