protected function AjaxController::getOldInboxThreads in Private Message 8
Same name and namespace in other branches
- 8.2 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 245
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);
if (count($thread_info['threads'])) {
$oldest_timestamp = FALSE;
$view_builder = $this->entityManager
->getViewBuilder('private_message_thread');
$threads = [];
foreach ($thread_info['threads'] as $thread) {
if ($thread
->access('view', $this->currentUser)) {
if ($thread_info['next_exists']) {
$oldest_timestamp = $thread
->get('updated')->value;
}
$threads[] = $view_builder
->view($thread, 'inbox');
}
}
$response
->addCommand(new PrivateMessageInboxInsertThreadsCommand($this->renderer
->renderRoot($threads), $oldest_timestamp));
}
else {
$response
->addCommand(new PrivateMessageInboxInsertThreadsCommand('', FALSE));
}
}
}