Backup of db before drupal security update
[yaffs-website] / web / core / modules / block_content / block_content.install
1 <?php
2
3 /**
4  * @file
5  * Install, update and uninstall functions for the block_content module.
6  */
7
8 use Drupal\Core\Field\BaseFieldDefinition;
9
10 /**
11  * Add 'revision_translation_affected' field to 'block_content' entities.
12  */
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.'))
24     ->setReadOnly(TRUE)
25     ->setRevisionable(TRUE)
26     ->setTranslatable(TRUE);
27
28   \Drupal::entityDefinitionUpdateManager()
29     ->installFieldStorageDefinition('revision_translation_affected', 'block_content', 'block_content', $storage_definition);
30 }
31
32 /**
33  * Generalizes the d6_block_content_type and d6_block_content_body_field
34  * migrations.
35  */
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
39   // are stable.
40   // @see https://www.drupal.org/node/2569469
41 }
42
43 /**
44  * Add 'revision_created' and 'revision_user' fields to 'block_content' entities.
45  */
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);
51
52   \Drupal::entityDefinitionUpdateManager()
53     ->installFieldStorageDefinition('revision_created', 'block_content', 'block_content', $revision_created);
54
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);
60
61   \Drupal::entityDefinitionUpdateManager()
62     ->installFieldStorageDefinition('revision_user', 'block_content', 'block_content', $revision_user);
63 }
64
65 /**
66  * Fix the block_content entity type to specify its revision data table.
67  */
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);
73
74 }