You are here

protected static function RevisionLogEntityTrait::getRevisionMetadataKey in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Entity/RevisionLogEntityTrait.php \Drupal\Core\Entity\RevisionLogEntityTrait::getRevisionMetadataKey()

Gets the name of a revision metadata field.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type: A content entity type definition.

string $key: The revision metadata key to get, must be one of 'revision_created', 'revision_user' or 'revision_log_message'.

Return value

string The name of the field for the specified $key.

File

core/lib/Drupal/Core/Entity/RevisionLogEntityTrait.php, line 127

Class

RevisionLogEntityTrait
Provides a trait for accessing revision logging and ownership information.

Namespace

Drupal\Core\Entity

Code

protected static function getRevisionMetadataKey(EntityTypeInterface $entity_type, $key) {

  // We need to prevent ContentEntityType::getRevisionMetadataKey() from
  // providing fallback as that requires fetching the entity type's field
  // definition leading to an infinite recursion.

  /** @var \Drupal\Core\Entity\ContentEntityTypeInterface $entity_type */
  $revision_metadata_keys = $entity_type
    ->getRevisionMetadataKeys(FALSE) + [
    'revision_created' => 'revision_created',
    'revision_user' => 'revision_user',
    'revision_log_message' => 'revision_log_message',
  ];
  return $revision_metadata_keys[$key];
}