protected function MultiversionStorageSchemaConverter::installPublishedStatusField in Multiversion 8.2
Parameters
\Drupal\Core\Entity\ContentEntityTypeInterface $entity_type:
1 call to MultiversionStorageSchemaConverter::installPublishedStatusField()
- MultiversionStorageSchemaConverter::convertToMultiversionable in src/
Entity/ Storage/ Sql/ MultiversionStorageSchemaConverter.php
File
- src/
Entity/ Storage/ Sql/ MultiversionStorageSchemaConverter.php, line 641
Class
Namespace
Drupal\multiversion\Entity\Storage\SqlCode
protected function installPublishedStatusField(ContentEntityTypeInterface $entity_type) {
// Get the 'published' key for the published status field.
$published_key = $entity_type
->getKey('published') ?: 'status';
// Add the status field.
$field = BaseFieldDefinition::create('boolean')
->setName($published_key)
->setTargetEntityTypeId($entity_type
->id())
->setTargetBundle(NULL)
->setLabel(t('Publishing status'))
->setDescription(t('A boolean indicating the published state.'))
->setRevisionable(TRUE)
->setTranslatable(TRUE)
->setDefaultValue(TRUE);
$has_content_translation_status_field = \Drupal::moduleHandler()
->moduleExists('content_translation') && $this->entityDefinitionUpdateManager
->getFieldStorageDefinition('content_translation_status', $entity_type
->id());
if ($has_content_translation_status_field) {
$field
->setInitialValueFromField('content_translation_status', TRUE);
}
else {
$field
->setInitialValue(TRUE);
}
$this->entityDefinitionUpdateManager
->installFieldStorageDefinition($published_key, $entity_type
->id(), $field
->getProvider(), $field);
// Uninstall the 'content_translation_status' field if needed.
if ($has_content_translation_status_field) {
$content_translation_status = $this->entityDefinitionUpdateManager
->getFieldStorageDefinition('content_translation_status', 'taxonomy_term');
$this->entityDefinitionUpdateManager
->uninstallFieldStorageDefinition($content_translation_status);
}
}