You are here

public function EventSubscriber::apiTestPreUnpublish in Scheduler 8

Operations to perform before Scheduler unpublishes a node.

Parameters

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

File

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

Class

EventSubscriber
Tests events fired on entity objects.

Namespace

Drupal\scheduler_api_test

Code

public function apiTestPreUnpublish(SchedulerEvent $event) {

  /** @var \Drupal\node\Entity\Node $node */
  $node = $event
    ->getNode();
  if ($node
    ->isPublished() && strpos($node->title->value, 'API TEST') === 0) {

    // Before unpublishing a node make it unsticky.
    $node
      ->setSticky(FALSE);
    $event
      ->setNode($node);
  }
}