You are here

function contact_storage_update_8003 in Contact Storage 8

Defines fields for the user id and ip address, for the contact messages.

File

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

Code

function contact_storage_update_8003() {
  $storage_definition = BaseFieldDefinition::create('entity_reference')
    ->setLabel(t('User ID'))
    ->setDescription(t('The user ID.'))
    ->setSetting('target_type', 'contact_form')
    ->setDefaultValueCallback('contact_storage_contact_message_default_uid');
  \Drupal::entityDefinitionUpdateManager()
    ->installFieldStorageDefinition('uid', 'contact_message', 'contact_storage', $storage_definition);
  $storage_definition = BaseFieldDefinition::create('string')
    ->setLabel(t('IP address'))
    ->setDescription(t('The IP address of the submitter.'))
    ->setDefaultValueCallback('contact_storage_contact_message_default_ip_address');
  \Drupal::entityDefinitionUpdateManager()
    ->installFieldStorageDefinition('ip_address', 'contact_message', 'contact_storage', $storage_definition);
}