You are here

public function UpdateUtils::getRevisionDefault in Scheduled Updates 8

Get whether a new revision should be created by default for this entity.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity_to_update:

Return value

bool

Overrides UpdateUtilsInterface::getRevisionDefault

File

src/UpdateUtils.php, line 104

Class

UpdateUtils
Service to determine information about Scheduled Update Types.

Namespace

Drupal\scheduled_updates

Code

public function getRevisionDefault(ContentEntityInterface $entity_to_update) {
  $bundle_type_id = $entity_to_update
    ->getEntityType()
    ->getBundleEntityType();
  $bundle = $this->entityTypeManager
    ->getStorage($bundle_type_id)
    ->load($entity_to_update
    ->bundle());

  // This should exist because of previous check in
  // supportsRevisionBundleDefault but just in case.
  if ($bundle instanceof NodeTypeInterface) {
    return $bundle
      ->isNewRevision();
  }
  return FALSE;
}