function EntityDecoupledTranslationRevisionsTest::generateNewEntityLabel

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Entity/EntityDecoupledTranslationRevisionsTest.php \Drupal\KernelTests\Core\Entity\EntityDecoupledTranslationRevisionsTest::generateNewEntityLabel()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Entity/EntityDecoupledTranslationRevisionsTest.php \Drupal\KernelTests\Core\Entity\EntityDecoupledTranslationRevisionsTest::generateNewEntityLabel()
  3. 10 core/tests/Drupal/KernelTests/Core/Entity/EntityDecoupledTranslationRevisionsTest.php \Drupal\KernelTests\Core\Entity\EntityDecoupledTranslationRevisionsTest::generateNewEntityLabel()

Generates a new label for the specified revision.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $revision: An entity object.

int $previous_revision_id: The previous revision identifier for this revision translation.

bool $next: (optional) Whether the label describes the current revision or the one to be created. Defaults to FALSE.

Return value

string A revision label.

1 call to EntityDecoupledTranslationRevisionsTest::generateNewEntityLabel()
EntityDecoupledTranslationRevisionsTest::doEditStep in core/tests/Drupal/KernelTests/Core/Entity/EntityDecoupledTranslationRevisionsTest.php
Saves a new revision of the test entity.

File

core/tests/Drupal/KernelTests/Core/Entity/EntityDecoupledTranslationRevisionsTest.php, line 472

Class

EntityDecoupledTranslationRevisionsTest
Test decoupled translation revisions.

Namespace

Drupal\KernelTests\Core\Entity

Code

protected function generateNewEntityLabel(ContentEntityInterface $revision, $previous_revision_id, $next = FALSE) {
    $language_label = $revision->language()
        ->getName();
    $revision_type = $revision->isDefaultRevision() ? 'Default' : 'Pending';
    $revision_id = $next ? $this->storage
        ->getLatestRevisionId($revision->id()) + 1 : $revision->getLoadedRevisionId();
    return sprintf('%s (%s %d -> %d)', $language_label, $revision_type, $previous_revision_id, $revision_id);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.