You are here

function contact_storage_install in Contact Storage 8

Implements hook_install().

File

./contact_storage.install, line 17
Contains install and update hooks.

Code

function contact_storage_install() {
  $entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
  $original_contact_message = $entity_definition_update_manager
    ->getEntityType('contact_message');
  $original_contact_form = \Drupal::entityTypeManager()
    ->getDefinition('contact_form');
  $entity_type_contact_message = clone $original_contact_message;
  $entity_definition_update_manager
    ->uninstallEntityType($original_contact_message);

  // Update the entity type definition and make it use the default SQL storage.
  // @see contact_storage_entity_type_alter()
  $entity_types = [
    'contact_message' => $entity_type_contact_message,
    'contact_form' => $original_contact_form,
  ];
  contact_storage_entity_type_alter($entity_types);
  $entity_definition_update_manager
    ->installEntityType($entity_types['contact_message']);
  _contact_storage_ensure_fields();
}