Save new revision of custom entity
For Drupal 8 most intern values like the revision flag (newRevision) is protected, which means that you aren't allowed to set them directly. There is a good reason for this, as Drupal wants to do stuff in some cases when these values are set.

Instead you need to use the ::setNewRevision method on the entity. This will throw an exception if the entity doesn't support revisions. So if you don't know what entities you are dealing with, you could do something like this.

function save_new_revisions(EntityInterface $entities) {
  foreach ($entities as $entity) {
    if ($entity-&gt;getEntityType()-&gt;isRevisionable()) {
      $entity-&gt;setNewRevision();
    }
    $entity-&gt;save();
  }
}