public function PhotosEditController::setAlbumCover in Album Photos 8.4
Same name and namespace in other branches
- 8.5 src/Controller/PhotosEditController.php \Drupal\photos\Controller\PhotosEditController::setAlbumCover()
- 6.0.x src/Controller/PhotosEditController.php \Drupal\photos\Controller\PhotosEditController::setAlbumCover()
Set album cover.
1 string reference to 'PhotosEditController::setAlbumCover'
File
- src/
Controller/ PhotosEditController.php, line 320
Class
- PhotosEditController
- Edit images and image details.
Namespace
Drupal\photos\ControllerCode
public function setAlbumCover($node, $file) {
$nid = $node
->id();
$pid = $this->connection
->query('SELECT pid FROM {photos_image} WHERE fid = :fid', [
':fid' => $file,
])
->fetchField();
if ($pid == $nid) {
$album = new PhotosAlbum($pid);
$album
->setCover($file);
$get_destination = $this->requestStack
->getCurrentRequest()->query
->get('destination');
$goto = $get_destination ?: 'photos/album/' . $nid;
$goto = Url::fromUri('base:' . $goto)
->toString();
return new RedirectResponse($goto);
}
else {
throw new NotFoundHttpException();
}
}