You are here

public function ParagraphLineageRevisioner::shouldCreateNewRevision in Paragraphs Edit 8.2

Checks if a given entity should be saved as a new revision by default.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to check for default new revision.

Return value

bool TRUE if this entity is set to be saved as a new revision by default, FALSE otherwise.

File

src/ParagraphLineageRevisioner.php, line 106

Class

ParagraphLineageRevisioner
ParagraphLineageRevisioner class.

Namespace

Drupal\paragraphs_edit

Code

public function shouldCreateNewRevision(EntityInterface $entity) {
  $new_revision_default = FALSE;
  if ($bundle_entity_type = $entity
    ->getEntityType()
    ->getBundleEntityType()) {
    $bundle_entity = $this->entityTypeManager
      ->getStorage($bundle_entity_type)
      ->load($entity
      ->bundle());
    if ($bundle_entity instanceof RevisionableEntityBundleInterface) {
      $new_revision_default = $bundle_entity
        ->shouldCreateNewRevision();
    }
  }
  return $new_revision_default;
}