public function PhotosRearrangeController::ajaxRearrange in Album Photos 8.4
Same name and namespace in other branches
- 8.5 src/Controller/PhotosRearrangeController.php \Drupal\photos\Controller\PhotosRearrangeController::ajaxRearrange()
- 6.0.x src/Controller/PhotosRearrangeController.php \Drupal\photos\Controller\PhotosRearrangeController::ajaxRearrange()
Ajax callback to save new image order.
1 string reference to 'PhotosRearrangeController::ajaxRearrange'
File
- src/
Controller/ PhotosRearrangeController.php, line 294
Class
- PhotosRearrangeController
- Re-arrange view controller.
Namespace
Drupal\photos\ControllerCode
public function ajaxRearrange() {
// @todo convert to CommandInterface class?
$post_nid = $this->requestStack
->getCurrentRequest()->request
->get('pid');
$post_uid = $this->requestStack
->getCurrentRequest()->request
->get('uid');
$post_type = $this->requestStack
->getCurrentRequest()->request
->get('type');
$post_order = $this->requestStack
->getCurrentRequest()->request
->get('order');
$nid = $post_nid ?: 0;
$uid = $post_uid ?: 0;
$type = $post_type ?: 0;
$new_order = $post_order ?: [];
$message = '';
if (!empty($new_order) && is_array($new_order)) {
if ($type == 'images') {
if ($nid) {
$message = $this
->editSortSave($new_order, $nid, $type);
}
}
elseif ($type == 'albums') {
if ($uid) {
// Save sort order for albums.
$message = $this
->editSortAlbumsSave($new_order, $uid);
}
}
}
if ($nid) {
// Clear album page cache.
Cache::invalidateTags([
'node:' . $nid,
'photos:album:' . $nid,
]);
}
// Build plain text response.
$response = new Response();
$response->headers
->set('Content-Type', 'text/plain');
$response
->setContent($message);
return $response;
}