/** * Allows to prevent unpublication of a scheduled node. * * @param \Drupal\node\NodeInterface $node * The scheduled node that is about to be unpublished. * * @return bool * FALSE if the node should not be unpublished. TRUE otherwise. */ function hook_scheduler_allow_unpublishing(NodeInterface $node) { $allowed = TRUE; // Prevent unpublication of competition entries if not all prizes have been // claimed. if ($node->getType() == 'competition' && ($items = $node->field_competition_prizes->getValue())) { $allowed = (bool) count($items); // If unpublication is denied then inform the user why. if (!$allowed) { drupal_set_message(t('The competition will only be unpublished after all prizes have been claimed by the winners.')); } } return $allowed; }