You are here

function photos_user_insert in Album Photos 8.4

Same name and namespace in other branches
  1. 8.5 photos.module \photos_user_insert()
  2. 7.3 photos.module \photos_user_insert()
  3. 6.0.x photos.module \photos_user_insert()

Implements hook_user_insert().

File

./photos.module, line 880
Implementation of photos.module.

Code

function photos_user_insert(UserInterface $account) {
  $db = \Drupal::database();
  $values = [
    [
      'cid' => $account
        ->id(),
      'changed' => 0,
      'type' => 'user_album',
      'value' => 0,
    ],
    [
      'cid' => $account
        ->id(),
      'changed' => 0,
      'type' => 'user_image',
      'value' => 0,
    ],
  ];
  $query = $db
    ->insert('photos_count')
    ->fields([
    'cid',
    'changed',
    'type',
    'value',
  ]);
  foreach ($values as $record) {
    $query
      ->values($record);
  }
  $query
    ->execute();
}