You are here

function photos_node_insert in Album Photos 8.4

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

Implements hook_ENTITY_TYPE_insert().

File

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

Code

function photos_node_insert(NodeInterface $node) {
  if ($node
    ->getType() == 'photos') {
    $node_album = serialize($node->album);
    $db = \Drupal::database();
    $db
      ->insert('photos_album')
      ->fields([
      'pid' => $node
        ->id(),
      'data' => $node_album,
      'fid' => 0,
      'count' => 0,
    ])
      ->execute();
    PhotosAlbum::setCount('user_album', $node
      ->getOwnerId());
  }
}