public function OpignoMessageThreadController::redirectToNewThread in Opigno messaging 3.x
Create the new thread with the given user and redirect to its page.
Parameters
int $uid: The user ID to create message thread with.
Return value
\Symfony\Component\HttpFoundation\RedirectResponse|null The redirect response.
1 string reference to 'OpignoMessageThreadController::redirectToNewThread'
File
- src/
Controller/ OpignoMessageThreadController.php, line 213
Class
- OpignoMessageThreadController
- The Opigno messaging controller.
Namespace
Drupal\opigno_messaging\ControllerCode
public function redirectToNewThread(int $uid) : ?RedirectResponse {
$members = [
(int) $this->currentUser
->id(),
$uid,
];
$thread = $this->messageService
->getThreadForMembers($members);
if (!$thread instanceof PrivateMessageThreadInterface) {
return NULL;
}
// Prepare the url to the created thread.
$url = Url::fromRoute('entity.private_message_thread.canonical', [
'private_message_thread' => $thread
->id(),
])
->toString();
return new RedirectResponse($url);
}