You are here

public function EventSubscriber::apiTestPrePublish in Scheduler 8

Operations to perform before Scheduler publishes a node.

Parameters

\Drupal\scheduler\SchedulerEvent $event: The scheduler event.

File

tests/modules/scheduler_api_test/src/EventSubscriber.php, line 49

Class

EventSubscriber
Tests events fired on entity objects.

Namespace

Drupal\scheduler_api_test

Code

public function apiTestPrePublish(SchedulerEvent $event) {

  /** @var \Drupal\node\Entity\Node $node */
  $node = $event
    ->getNode();

  // Before publishing a node make it sticky.
  if (!$node
    ->isPublished() && strpos($node->title->value, 'API TEST') === 0) {
    $node
      ->setSticky(TRUE);
    $event
      ->setNode($node);
  }
}