You are here

protected function MultiversionStorageSchemaConverter::installMultiversionFields in Multiversion 8.2

Install fields provided by Multiversion.

Parameters

\Drupal\Core\Entity\ContentEntityTypeInterface $entity_type:

1 call to MultiversionStorageSchemaConverter::installMultiversionFields()
MultiversionStorageSchemaConverter::convertToMultiversionable in src/Entity/Storage/Sql/MultiversionStorageSchemaConverter.php

File

src/Entity/Storage/Sql/MultiversionStorageSchemaConverter.php, line 707

Class

MultiversionStorageSchemaConverter

Namespace

Drupal\multiversion\Entity\Storage\Sql

Code

protected function installMultiversionFields(ContentEntityTypeInterface $entity_type) {
  $fields[] = BaseFieldDefinition::create('boolean')
    ->setName('_deleted')
    ->setTargetEntityTypeId($entity_type
    ->id())
    ->setTargetBundle(NULL)
    ->setLabel(t('Deleted flag'))
    ->setDescription(t('Indicates if the entity is flagged as deleted or not.'))
    ->setRevisionable(TRUE)
    ->setTranslatable(FALSE)
    ->setDefaultValue(FALSE)
    ->setCardinality(1);
  $fields[] = BaseFieldDefinition::create('revision_token')
    ->setName('_rev')
    ->setTargetEntityTypeId($entity_type
    ->id())
    ->setTargetBundle(NULL)
    ->setLabel(t('Revision token'))
    ->setDescription(t('The token for this entity revision.'))
    ->setRevisionable(TRUE)
    ->setTranslatable(FALSE)
    ->setCardinality(1)
    ->setReadOnly(TRUE);
  foreach ($fields as $field) {
    $this->entityDefinitionUpdateManager
      ->installFieldStorageDefinition($field
      ->getName(), $entity_type
      ->id(), 'multiversion', $field);
  }
}