X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Flib%2FDrupal%2FCore%2FEntity%2FEntityFieldManager.php;fp=web%2Fcore%2Flib%2FDrupal%2FCore%2FEntity%2FEntityFieldManager.php;h=f847cfa3840bb99cfab6044ded65e7e57308b888;hp=63c35e9743b3e63ea32eb0dfbbb0d046a25425ab;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/web/core/lib/Drupal/Core/Entity/EntityFieldManager.php b/web/core/lib/Drupal/Core/Entity/EntityFieldManager.php index 63c35e974..f847cfa38 100644 --- a/web/core/lib/Drupal/Core/Entity/EntityFieldManager.php +++ b/web/core/lib/Drupal/Core/Entity/EntityFieldManager.php @@ -190,8 +190,10 @@ class EntityFieldManager implements EntityFieldManagerInterface { * flagged as translatable. */ protected function buildBaseFieldDefinitions($entity_type_id) { + /** @var \Drupal\Core\Entity\ContentEntityTypeInterface $entity_type */ $entity_type = $this->entityTypeManager->getDefinition($entity_type_id); $class = $entity_type->getClass(); + /** @var string[] $keys */ $keys = array_filter($entity_type->getKeys()); // Fail with an exception for non-fieldable entity types. @@ -221,6 +223,21 @@ class EntityFieldManager implements EntityFieldManagerInterface { } // Make sure that revisionable entity types are correctly defined. + if ($entity_type->isRevisionable()) { + // Disable the BC layer to prevent a recursion, this only needs the + // revision_default key that is always set. + $field_name = $entity_type->getRevisionMetadataKeys(FALSE)['revision_default']; + $base_field_definitions[$field_name] = BaseFieldDefinition::create('boolean') + ->setLabel($this->t('Default revision')) + ->setDescription($this->t('A flag indicating whether this was a default revision when it was saved.')) + ->setStorageRequired(TRUE) + ->setInternal(TRUE) + ->setTranslatable(FALSE) + ->setRevisionable(TRUE); + } + + // Make sure that revisionable and translatable entity types are correctly + // defined. if ($entity_type->isRevisionable() && $entity_type->isTranslatable()) { // The 'revision_translation_affected' field should always be defined. // This field has been added unconditionally in Drupal 8.4.0 and it is