public function EventSubscriber::apiTestPrePublishImmediately in Scheduler 8
Operations before Scheduler publishes a node immediately not via cron.
Parameters
\Drupal\scheduler\SchedulerEvent $event: The scheduler event.
File
- tests/
modules/ scheduler_api_test/ src/ EventSubscriber.php, line 81
Class
- EventSubscriber
- Tests events fired on entity objects.
Namespace
Drupal\scheduler_api_testCode
public function apiTestPrePublishImmediately(SchedulerEvent $event) {
/** @var \Drupal\node\Entity\Node $node */
$node = $event
->getNode();
// Before publishing immediately set the node to sticky.
if (!$node
->isPromoted() && strpos($node->title->value, 'API TEST') === 0) {
$node
->setSticky(TRUE);
$event
->setNode($node);
}
}