You are here

public static function CountryList::preCreate in Country, State and City Fields 8

When a new entity instance is added, set the user_id entity reference to the current user as the creator of the instance.

Overrides EntityBase::preCreate

File

src/Entity/CountryList.php, line 74

Class

CountryList
Defines the countrylist entity.

Namespace

Drupal\country_state_city\Entity

Code

public static function preCreate(EntityStorageInterface $storage_controller, array &$values) {
  parent::preCreate($storage_controller, $values);
  $values += [
    'user_id' => \Drupal::currentUser()
      ->id(),
  ];
}