You are here

function photos_photos_image_delete in Album Photos 8.5

Same name and namespace in other branches
  1. 6.0.x photos.module \photos_photos_image_delete()

Implements hook_ENTITY_TYPE_delete().

File

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

Code

function photos_photos_image_delete(PhotosImageInterface $photos_image) {

  /* @var \Drupal\photos\Entity\PhotosImage $photos_image */

  // @todo update counts.
  // If this entity is the album cover, clear it.
  $db = \Drupal::database();
  $db
    ->update('photos_album')
    ->fields([
    'cover_id' => 0,
  ])
    ->condition('album_id', $photos_image
    ->getAlbumId())
    ->condition('cover_id', $photos_image
    ->id())
    ->execute();
}