You are here

public function AjaxController::ajaxCallback in Private Message 8

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

Create AJAX responses for JavaScript requests.

Parameters

string $op: The type of data to build for the response.

Return value

\Drupal\Core\Ajax\AjaxResponse The ajax response

Overrides AjaxControllerInterface::ajaxCallback

1 string reference to 'AjaxController::ajaxCallback'
private_message.routing.yml in ./private_message.routing.yml
private_message.routing.yml

File

src/Controller/AjaxController.php, line 115

Class

AjaxController
Controller to handle Ajax requests.

Namespace

Drupal\private_message\Controller

Code

public function ajaxCallback($op) {
  $response = new AjaxResponse();
  if ($this->currentUser
    ->hasPermission('use private messaging system')) {
    switch ($op) {
      case 'get_new_messages':
        $this
          ->getNewPrivateMessages($response);
        break;
      case 'get_old_messages':
        $this
          ->getOldPrivateMessages($response);
        break;
      case 'get_old_inbox_threads':
        $this
          ->getOldInboxThreads($response);
        break;
      case 'get_new_inbox_threads':
        $this
          ->getNewInboxThreads($response);
        break;
      case 'validate_private_message_member_username':
        $this
          ->validatePrivateMessageMemberUsername($response);
        break;
      case 'get_new_unread_thread_count':
        $this
          ->getNewUnreadThreadCount($response);
        break;
      case 'load_thread':
        $this
          ->loadThread($response);
        break;
    }
  }
  return $response;
}