You are here

public static function PhotosUpload::finishedMovingImageFiles in Album Photos 8.4

Finished batch operation moving image files.

File

src/PhotosUpload.php, line 333

Class

PhotosUpload
Functions to help with uploading images to albums.

Namespace

Drupal\photos

Code

public static function finishedMovingImageFiles($success, $results, $operations) {

  // Clear node and album page cache.
  Cache::invalidateTags([
    'node:' . $results['nid'],
    'photos:album:' . $results['nid'],
  ]);

  // Update count.
  PhotosAlbum::setCount('user_image', $results['uid']);
  PhotosAlbum::setCount('node_album', $results['nid']);
  if ($success) {
    if ($results['copy']) {
      $message = \Drupal::translation()
        ->formatPlural($results['images_processed'], 'One image copied to selected album.', '@count images copied to selected album.');
    }
    else {
      $message = \Drupal::translation()
        ->formatPlural($results['images_processed'], 'One image moved to selected album.', '@count images moved to selected album.');
    }
  }
  else {
    $message = t('Finished with an error.');
  }
  \Drupal::messenger()
    ->addMessage($message);
}