You are here

contact_storage_test.install in Drupal 9

Contains install and update hooks.

File

core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.install
View source
<?php

/**
 * @file
 * Contains install and update hooks.
 */
use Drupal\Core\Entity\Sql\SqlContentEntityStorage;

/**
 * Implements hook_install().
 */
function contact_storage_test_install() {
  $entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
  $original = $entity_definition_update_manager
    ->getEntityType('contact_message');
  $entity_definition_update_manager
    ->uninstallEntityType($original);

  // Update the entity type definition and make it use the default SQL storage.
  // @see contact_storage_test_entity_type_alter()
  $entity_type = clone $original;
  $entity_type
    ->setStorageClass(SqlContentEntityStorage::class);
  $keys = $entity_type
    ->getKeys();
  $keys['id'] = 'id';
  $entity_type
    ->set('entity_keys', $keys);
  $entity_type
    ->set('base_table', 'contact_message');
  $entity_definition_update_manager
    ->installEntityType($entity_type);
}

Functions

Namesort descending Description
contact_storage_test_install Implements hook_install().