You are here

public static function Gauth::preCreate in Google Auth 8

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

Overrides EntityBase::preCreate

File

src/Entity/Gauth.php, line 480

Class

Gauth
Defines the Gauth entity.

Namespace

Drupal\gauth\Entity

Code

public static function preCreate(EntityStorageInterface $storage_controller, array &$values) {
  parent::preCreate($storage_controller, $values);
  if (!isset($values['uid']) || $values['uid'] == NULL) {
    $values += [
      'uid' => \Drupal::currentUser()
        ->id(),
    ];
  }
  $values['is_authenticated'] = FALSE;
}