Change record status: 
Project: 
Introduced in branch: 
8.3.x
Introduced in version: 
8.3.0
Description: 

Content entities that need a published/unpublished flag base field are now able to declare a "published" entity key in their entity type annotation. Such entities should implement the new \Drupal\Core\Entity\EntityPublishedInterface and use the \Drupal\Core\Entity\EntityPublishedTrait trait. The interface can be implemented directly, by the entity class, or by the entity specialised interface.

use Drupal\Core\Entity\EntityPublishedInterface;
use Drupal\Core\Entity\EntityPublishedTrait;
use ...

/**
 * @ContentEntityType(
 *   id = "custom_entity",
 *   ...
 *   entity_keys = {
 *     "id" = "id",
 *     "published" = "status",
 *     "label" = "label",
 *   },
 *   ...
 * )
 */
class CustomEntity extends ContentEntityBase implements CustomEntityInterface, EntityPublishedInterface {
  use EntityPublishedTrait;
   ...
}

Entities defined in this way can benefit of the new provided methods to set the published status ON/OFF and are able to inspect the status of the published flag field:

$storage = \Drupal::entityTypeManager()->getStorage('custom_entity');
$entity = $storage->load(123);

// Reverse the published status.
if ($entity->isPublished()) {
  $entity->setUnpublished();
}
else {
  $entity->setPublished();
}

$entity->save()
Impacts: 
Module developers
Themers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done