protected function AjaxController::getOldInboxThreads in Private Message 8.2
Same name and namespace in other branches
- 8 src/Controller/AjaxController.php \Drupal\private_message\Controller\AjaxController::getOldInboxThreads()
Creates and Ajax Command containing old threads for the inbox.
Parameters
Drupal\Core\Ajax\AjaxResponse $response: The response to which any commands should be attached.
1 call to AjaxController::getOldInboxThreads()
- AjaxController::ajaxCallback in src/
Controller/ AjaxController.php - Create AJAX responses for JavaScript requests.
File
- src/
Controller/ AjaxController.php, line 276
Class
- AjaxController
- Controller to handle Ajax requests.
Namespace
Drupal\private_message\ControllerCode
protected function getOldInboxThreads(AjaxResponse $response) {
$timestamp = $this->requestStack
->getCurrentRequest()
->get('timestamp');
$thread_count = $this->requestStack
->getCurrentRequest()
->get('count');
if (is_numeric($timestamp)) {
$thread_info = $this->privateMessageService
->getThreadsForUser($thread_count, $timestamp);
$has_next = FALSE;
if (count($thread_info['threads'])) {
$view_builder = $this->entityTypeManager
->getViewBuilder('private_message_thread');
$threads = [];
foreach ($thread_info['threads'] as $thread) {
if ($thread
->access('view', $this->currentUser)) {
$has_next = $thread_info['next_exists'];
$threads[] = $view_builder
->view($thread, 'inbox');
}
}
$response
->addCommand(new PrivateMessageInboxInsertThreadsCommand($this->renderer
->renderRoot($threads), $has_next));
}
else {
$response
->addCommand(new PrivateMessageInboxInsertThreadsCommand('', FALSE));
}
}
}