You are here

public function EventSubscriber::apiTestPublishImmediately in Scheduler 8

Operations after 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 129

Class

EventSubscriber
Tests events fired on entity objects.

Namespace

Drupal\scheduler_api_test

Code

public function apiTestPublishImmediately(SchedulerEvent $event) {

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

  // After publishing immediately set the node to promoted and change the
  // title.
  if (!$node
    ->isPromoted() && strpos($node->title->value, 'API TEST') === 0) {
    $node
      ->setTitle('Published immediately')
      ->setPromoted(TRUE);
    $event
      ->setNode($node);
  }
}