2015-08-27 05:28:17 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Install, update and uninstall functions for the block_content module.
|
|
|
|
*/
|
|
|
|
|
|
|
|
use Drupal\Core\Field\BaseFieldDefinition;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add 'revision_translation_affected' field to 'block_content' entities.
|
|
|
|
*/
|
|
|
|
function block_content_update_8001() {
|
|
|
|
// Install the definition that this field had in
|
|
|
|
// \Drupal\block_content\Entity\BlockContent::baseFieldDefinitions()
|
|
|
|
// at the time that this update function was written. If/when code is
|
|
|
|
// deployed that changes that definition, the corresponding module must
|
|
|
|
// implement an update function that invokes
|
|
|
|
// \Drupal::entityDefinitionUpdateManager()->updateFieldStorageDefinition()
|
|
|
|
// with the new definition.
|
|
|
|
$storage_definition = BaseFieldDefinition::create('boolean')
|
|
|
|
->setLabel(t('Revision translation affected'))
|
|
|
|
->setDescription(t('Indicates if the last edit of a translation belongs to current revision.'))
|
|
|
|
->setReadOnly(TRUE)
|
|
|
|
->setRevisionable(TRUE)
|
|
|
|
->setTranslatable(TRUE);
|
|
|
|
|
|
|
|
\Drupal::entityDefinitionUpdateManager()
|
|
|
|
->installFieldStorageDefinition('revision_translation_affected', 'block_content', 'block_content', $storage_definition);
|
|
|
|
}
|
2015-09-14 20:00:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Generalizes the d6_block_content_type and d6_block_content_body_field
|
|
|
|
* migrations.
|
|
|
|
*/
|
|
|
|
function block_content_update_8002() {
|
|
|
|
if (\Drupal::moduleHandler()->moduleExists('migrate')) {
|
|
|
|
$config = \Drupal::configFactory();
|
|
|
|
$templates = \Drupal::service('migrate.template_storage');
|
|
|
|
|
|
|
|
$migration = $config->getEditable('migrate.migration.d6_block_content_type');
|
|
|
|
if ($migration) {
|
|
|
|
$template = $templates->getTemplateByName('block_content_type');
|
|
|
|
$migration
|
|
|
|
->set('id', $template['id'])
|
|
|
|
->set('label', $template['label'])
|
|
|
|
->set('migration_tags', $template['migration_tags'])
|
|
|
|
->set('source', array_merge($migration->get('source'), $template['source']))
|
|
|
|
->clear('source.constants')
|
|
|
|
->set('process', $template['process'])
|
|
|
|
->save(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
$migration = $config->getEditable('migrate.migration.d6_block_content_body_field');
|
|
|
|
if ($migration) {
|
|
|
|
$template = $templates->getTemplateByName('block_content_body_field');
|
|
|
|
$migration
|
|
|
|
->set('id', $template['id'])
|
|
|
|
->set('label', $template['label'])
|
|
|
|
->set('migration_tags', $template['migration_tags'])
|
|
|
|
->set('source', array_merge($migration->get('source'), $template['source']))
|
|
|
|
->clear('source.constants')
|
|
|
|
->set('process', $template['process'])
|
|
|
|
->set('migration_dependencies', $template['migration_dependencies'])
|
|
|
|
->save(TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|