modules/acm_promotion/src/AcmPromotionsManager.php
protected function deletePromotions(array $types, array $validIDs = []) {
    $query = $this->nodeStorage->getQuery();
    $query->condition('type', 'acm_promotion');
    $query->condition('field_acm_promotion_type', $types, 'IN');

    if ($validIDs) {
      $query->condition('field_acm_promotion_rule_id', $validIDs, 'NOT IN');
    }

    $nids = $query->execute();

    foreach ($nids as $nid) {
      /* @var $node \Drupal\node\NodeInterface */
      $node = $this->nodeStorage->load($nid);
      if ($node instanceof NodeInterface) {
        $node->delete();
        $this->logger->notice('Deleted orphan promotion node @promotion having rule_id:@rule_id.', [
          '@promotion' => $node->label(),
          '@rule_id' => $node->get('field_acm_promotion_rule_id')->first()->getString(),
        ]);
      }
    }
  }
protected function deletePromotions(array $types, array $validIDs = []) {
    $query = $this->nodeStorage->getQuery();
    $query->condition('type', 'acm_promotion');
    $query->condition('field_acm_promotion_type', $types, 'IN');

    if ($validIDs) {
      $query->condition('field_acm_promotion_rule_id', $validIDs, 'NOT IN');
    }

    $nids = $query->execute();

    foreach ($nids as $nid) {
      /* @var $node \Drupal\node\NodeInterface */
      $node = $this->nodeStorage->load($nid);
      if ($node instanceof NodeInterface) {
        $node->delete();
        $this->logger->notice('Deleted orphan promotion node @promotion having rule_id:@rule_id.', [
          '@promotion' => $node->label(),
          '@rule_id' => $node->get('field_acm_promotion_rule_id')->first()->getString(),
        ]);
      }
    }
  }
protected function deletePromotions ( array $ types , array $ validIDs = [ ] ) { $ query = $ this -> nodeStorage -> getQuery ( ) ; $ query -> condition ( 'type' , 'acm_promotion' ) ; $ query -> condition ( 'field_acm_promotion_type' , $ types , 'IN' ) ; if ( $ validIDs ) { $ query -> condition ( 'field_acm_promotion_rule_id' , $ validIDs , 'NOT IN' ) ; } $ nids = $ query -> execute ( ) ; foreach ( $ nids as $ nid ) { /* @var $node \Drupal\node\NodeInterface */ $ node = $ this -> nodeStorage -> load ( $ nid ) ; if ( $ node instanceof NodeInterface ) { $ node -> delete ( ) ; $ this -> logger -> notice ( 'Deleted orphan promotion node @promotion having rule_id:@rule_id.' , [ '@promotion' => $ node -> label ( ) , '@rule_id' => $ node -> get ( 'field_acm_promotion_rule_id' ) -> first ( ) -> getString ( ) , ] ) ; } } }
Delete Promotion nodes, not part of API Response.

@param array $types
Promotions types to delete.
@param array $validIDs
Valid Rule ID's from API.
Delete Promotion nodes not part of API Response .