annotate core/modules/block_content/block_content.install @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 1fec387a4317
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 /**
Chris@0 4 * @file
Chris@0 5 * Install, update and uninstall functions for the block_content module.
Chris@0 6 */
Chris@0 7
Chris@0 8 use Drupal\Core\Field\BaseFieldDefinition;
Chris@0 9
Chris@0 10 /**
Chris@0 11 * Add 'revision_translation_affected' field to 'block_content' entities.
Chris@0 12 */
Chris@0 13 function block_content_update_8001() {
Chris@0 14 // Install the definition that this field had in
Chris@0 15 // \Drupal\block_content\Entity\BlockContent::baseFieldDefinitions()
Chris@0 16 // at the time that this update function was written. If/when code is
Chris@0 17 // deployed that changes that definition, the corresponding module must
Chris@0 18 // implement an update function that invokes
Chris@0 19 // \Drupal::entityDefinitionUpdateManager()->updateFieldStorageDefinition()
Chris@0 20 // with the new definition.
Chris@0 21 $storage_definition = BaseFieldDefinition::create('boolean')
Chris@0 22 ->setLabel(t('Revision translation affected'))
Chris@0 23 ->setDescription(t('Indicates if the last edit of a translation belongs to current revision.'))
Chris@0 24 ->setReadOnly(TRUE)
Chris@0 25 ->setRevisionable(TRUE)
Chris@0 26 ->setTranslatable(TRUE);
Chris@0 27
Chris@0 28 \Drupal::entityDefinitionUpdateManager()
Chris@0 29 ->installFieldStorageDefinition('revision_translation_affected', 'block_content', 'block_content', $storage_definition);
Chris@0 30 }
Chris@0 31
Chris@0 32 /**
Chris@0 33 * Generalizes the d6_block_content_type and d6_block_content_body_field
Chris@0 34 * migrations.
Chris@0 35 */
Chris@0 36 function block_content_update_8002() {
Chris@0 37 // Removed in issue #2569605. The Migrate and Migrate Drupal modules are
Chris@0 38 // marked experimental and do not need to support the update path until they
Chris@0 39 // are stable.
Chris@0 40 // @see https://www.drupal.org/node/2569469
Chris@0 41 }
Chris@0 42
Chris@0 43 /**
Chris@0 44 * Add 'revision_created' and 'revision_user' fields to 'block_content' entities.
Chris@0 45 */
Chris@0 46 function block_content_update_8003() {
Chris@0 47 $revision_created = BaseFieldDefinition::create('created')
Chris@0 48 ->setLabel(t('Revision create time'))
Chris@0 49 ->setDescription(t('The time that the current revision was created.'))
Chris@0 50 ->setRevisionable(TRUE);
Chris@0 51
Chris@0 52 \Drupal::entityDefinitionUpdateManager()
Chris@0 53 ->installFieldStorageDefinition('revision_created', 'block_content', 'block_content', $revision_created);
Chris@0 54
Chris@0 55 $revision_user = BaseFieldDefinition::create('entity_reference')
Chris@0 56 ->setLabel(t('Revision user'))
Chris@0 57 ->setDescription(t('The user ID of the author of the current revision.'))
Chris@0 58 ->setSetting('target_type', 'user')
Chris@0 59 ->setRevisionable(TRUE);
Chris@0 60
Chris@0 61 \Drupal::entityDefinitionUpdateManager()
Chris@0 62 ->installFieldStorageDefinition('revision_user', 'block_content', 'block_content', $revision_user);
Chris@0 63 }
Chris@0 64
Chris@0 65 /**
Chris@0 66 * Fix the block_content entity type to specify its revision data table.
Chris@0 67 */
Chris@0 68 function block_content_update_8300() {
Chris@0 69 $definition_update_manager = \Drupal::entityDefinitionUpdateManager();
Chris@0 70 $entity_type = $definition_update_manager->getEntityType('block_content');
Chris@0 71 $entity_type->set('revision_data_table', 'block_content_field_revision');
Chris@0 72 $definition_update_manager->updateEntityType($entity_type);
Chris@0 73
Chris@0 74 }