function block_content_update_8003 in Drupal 8
Add 'revision_created' and 'revision_user' fields to 'block_content' entities.
File
- core/
modules/ block_content/ block_content.install, line 47 - Install, update and uninstall functions for the block_content module.
Code
function block_content_update_8003() {
$revision_created = BaseFieldDefinition::create('created')
->setLabel(t('Revision create time'))
->setDescription(t('The time that the current revision was created.'))
->setRevisionable(TRUE);
\Drupal::entityDefinitionUpdateManager()
->installFieldStorageDefinition('revision_created', 'block_content', 'block_content', $revision_created);
$revision_user = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Revision user'))
->setDescription(t('The user ID of the author of the current revision.'))
->setSetting('target_type', 'user')
->setRevisionable(TRUE);
\Drupal::entityDefinitionUpdateManager()
->installFieldStorageDefinition('revision_user', 'block_content', 'block_content', $revision_user);
}