private function OpignoMessageThreadController::prepareThreadFormResponse in Opigno messaging 3.x
Prepare the AJAX response to display the thread add/edit form.
Parameters
int $tid: The thread ID to get the form for. If 0 is given, creation form will be rendered.
Return value
\Drupal\Core\Ajax\AjaxResponse The response object.
Throws
\Drupal\Core\Form\EnforcedResponseException
\Drupal\Core\Form\FormAjaxException
2 calls to OpignoMessageThreadController::prepareThreadFormResponse()
- OpignoMessageThreadController::getEditThreadForm in src/
Controller/ OpignoMessageThreadController.php - Get the private messages thread edit form.
- OpignoMessageThreadController::getThreadForm in src/
Controller/ OpignoMessageThreadController.php - Get the private messages thread create form.
File
- src/
Controller/ OpignoMessageThreadController.php, line 118
Class
- OpignoMessageThreadController
- The Opigno messaging controller.
Namespace
Drupal\opigno_messaging\ControllerCode
private function prepareThreadFormResponse(int $tid = 0) : AjaxResponse {
$response = new AjaxResponse();
$form_state = new FormState();
$form_state
->addBuildInfo('args', [
$tid,
]);
$form = $this->formBuilder
->buildForm(OpignoPrivateMessageThreadForm::class, $form_state);
$build = [
'#theme' => 'opigno_messaging_modal',
'#title' => $tid ? $this
->t('Edit discussion') : $this
->t('New discussion'),
'#body' => $form,
];
$response
->addCommand(new RemoveCommand('.modal-ajax'));
$response
->addCommand(new AppendCommand('body', $build));
$response
->addCommand(new InvokeCommand('.modal-ajax', 'modal', [
'show',
]));
return $response;
}