You are here

function name_field_config_create in Name Field 8

Implements hook_field_config_create().

File

./name.module, line 733
Defines an API for displaying and inputing names.

Code

function name_field_config_create(FieldConfigInterface $entity) {
  if (!$entity
    ->isSyncing() && $entity
    ->getTargetEntityTypeId() == 'user' && $entity
    ->getTargetBundle() == 'user' && $entity
    ->getType() == 'name' && Drupal::config('name.settings')
    ->get('user_preferred') == '') {
    \Drupal::configFactory()
      ->getEditable('name.settings')
      ->set('user_preferred', $entity
      ->getName())
      ->save();
  }
}