You are here

public function EventSubscriber::apiTestUnpublish in Scheduler 8

Operations to perform after Scheduler unpublishes a node.

Parameters

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

File

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

Class

EventSubscriber
Tests events fired on entity objects.

Namespace

Drupal\scheduler_api_test

Code

public function apiTestUnpublish(SchedulerEvent $event) {

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

  // After unpublishing a node remove it from the front page.
  if (!$node
    ->isPublished() && strpos($node->title->value, 'API TEST') === 0) {
    $node
      ->setPromoted(FALSE);
    $event
      ->setNode($node);
  }
}