5 * Install, update and uninstall functions for the block_content module.
8 use Drupal\Core\Field\BaseFieldDefinition;
11 * Add 'revision_translation_affected' field to 'block_content' entities.
13 function block_content_update_8001() {
14 // Install the definition that this field had in
15 // \Drupal\block_content\Entity\BlockContent::baseFieldDefinitions()
16 // at the time that this update function was written. If/when code is
17 // deployed that changes that definition, the corresponding module must
18 // implement an update function that invokes
19 // \Drupal::entityDefinitionUpdateManager()->updateFieldStorageDefinition()
20 // with the new definition.
21 $storage_definition = BaseFieldDefinition::create('boolean')
22 ->setLabel(t('Revision translation affected'))
23 ->setDescription(t('Indicates if the last edit of a translation belongs to current revision.'))
25 ->setRevisionable(TRUE)
26 ->setTranslatable(TRUE);
28 \Drupal::entityDefinitionUpdateManager()
29 ->installFieldStorageDefinition('revision_translation_affected', 'block_content', 'block_content', $storage_definition);
33 * Generalizes the d6_block_content_type and d6_block_content_body_field
36 function block_content_update_8002() {
37 // Removed in issue #2569605. The Migrate and Migrate Drupal modules are
38 // marked experimental and do not need to support the update path until they
40 // @see https://www.drupal.org/node/2569469
44 * Add 'revision_created' and 'revision_user' fields to 'block_content' entities.
46 function block_content_update_8003() {
47 $revision_created = BaseFieldDefinition::create('created')
48 ->setLabel(t('Revision create time'))
49 ->setDescription(t('The time that the current revision was created.'))
50 ->setRevisionable(TRUE);
52 \Drupal::entityDefinitionUpdateManager()
53 ->installFieldStorageDefinition('revision_created', 'block_content', 'block_content', $revision_created);
55 $revision_user = BaseFieldDefinition::create('entity_reference')
56 ->setLabel(t('Revision user'))
57 ->setDescription(t('The user ID of the author of the current revision.'))
58 ->setSetting('target_type', 'user')
59 ->setRevisionable(TRUE);
61 \Drupal::entityDefinitionUpdateManager()
62 ->installFieldStorageDefinition('revision_user', 'block_content', 'block_content', $revision_user);
66 * Fix the block_content entity type to specify its revision data table.
68 function block_content_update_8300() {
69 $definition_update_manager = \Drupal::entityDefinitionUpdateManager();
70 $entity_type = $definition_update_manager->getEntityType('block_content');
71 $entity_type->set('revision_data_table', 'block_content_field_revision');
72 $definition_update_manager->updateEntityType($entity_type);