You are here

public function EventSubscriber::apiTestPublish in Scheduler 8

Operations to perform after Scheduler publishes a node.

Parameters

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

File

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

Class

EventSubscriber
Tests events fired on entity objects.

Namespace

Drupal\scheduler_api_test

Code

public function apiTestPublish(SchedulerEvent $event) {

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

  // After publishing a node promote it to the front page.
  if ($node
    ->isPublished() && strpos($node->title->value, 'API TEST') === 0) {
    $node
      ->setPromoted(TRUE);
    $event
      ->setNode($node);
  }
}