You are here

public function ScheduledPublishCron::doUpdate in Scheduled Publish 8

Same name and namespace in other branches
  1. 8.3 src/Service/ScheduledPublishCron.php \Drupal\scheduled_publish\Service\ScheduledPublishCron::doUpdate()
  2. 8.2 src/Service/ScheduledPublishCron.php \Drupal\scheduled_publish\Service\ScheduledPublishCron::doUpdate()

File

src/Service/ScheduledPublishCron.php, line 48

Class

ScheduledPublishCron
Class ScheduledPublishCron

Namespace

Drupal\scheduled_publish\Service

Code

public function doUpdate() : void {
  $bundles = $this->entityBundleInfoService
    ->getBundleInfo('node');
  foreach ($bundles as $bundleName => $value) {
    $scheduledFields = $this
      ->getScheduledFields($bundleName);
    if (\count($scheduledFields) > 0) {
      $query = $this->entityTypeManager
        ->getStorage('node')
        ->getQuery('AND');
      $query
        ->condition('type', $bundleName);
      $nodes = $query
        ->execute();
      foreach ($nodes as $nodeId) {

        /** @var \Drupal\node\Entity\Node $node */
        $node = Node::load($nodeId);
        foreach ($scheduledFields as $scheduledField) {
          $this
            ->updateNodeField($node, $scheduledField);
        }
      }
    }
  }
}