You are here

function photos_user_insert in Album Photos 8.5

Same name and namespace in other branches
  1. 8.4 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 644
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();
}