You are here

public function PrivateMessageController::privateMessagePage in Private Message 8

Same name and namespace in other branches
  1. 8.2 src/Controller/PrivateMessageController.php \Drupal\private_message\Controller\PrivateMessageController::privateMessagePage()

The Private message page.

Overrides PrivateMessageControllerInterface::privateMessagePage

1 string reference to 'PrivateMessageController::privateMessagePage'
private_message.routing.yml in ./private_message.routing.yml
private_message.routing.yml

File

src/Controller/PrivateMessageController.php, line 99

Class

PrivateMessageController
Private message page controller. Returns render arrays for the page.

Namespace

Drupal\private_message\Controller

Code

public function privateMessagePage() {
  $this->privateMessageService
    ->updateLastCheckTime();
  $user = $this->userManager
    ->load($this->currentUser
    ->id());
  $private_message_thread = $this->privateMessageService
    ->getFirstThreadForUser($user);
  if ($private_message_thread) {
    $view_builder = $this->entityManager
      ->getViewBuilder('private_message_thread');

    // No wrapper is provided, as the full view mode of the entity already
    // provides the #private-message-page wrapper.
    $page = $view_builder
      ->view($private_message_thread);
  }
  else {
    $page = [
      '#prefix' => '<div id="private-message-page">',
      '#suffix' => '</div>',
      'no_threads' => [
        '#prefix' => '<p>',
        '#suffix' => '</p>',
        '#markup' => $this
          ->t('You do not have any messages'),
      ],
    ];
  }
  return $page;
}