Commit 6609b345 authored by New Zeal's avatar New Zeal

fix thread urls and redirect

parent bc395df3
......@@ -127,6 +127,32 @@ function message_thread_form_message_private_message_edit_form_alter(array &$for
$form['actions']['cancel'] = $link;
}
function message_thread_form_message_private_message_form_alter(array &$form, FormStateInterface $form_state) {
// Get the message thread id from the url
if (isset($_GET['destination'])) {
$parts = explode('/', $_GET['destination']);
$thread_id = array_pop($parts);
if (is_numeric($thread_id)) {
$params = array(
'message_thread' => $thread_id
);
$url = Url::fromRoute('entity.message_thread.canonical', $params);
$form_state->setRedirectUrl($url);
$link = [
'#type' => 'link',
'#url' => $url,
'#title' => t('Cancel')
];
$form['actions']['cancel'] = $link;
}
}
}
/*
* Implements hook_form_FORM_ID_alter().
*/
......
......@@ -48,9 +48,9 @@ use Drupal\user\UserInterface;
* "access" = "Drupal\message_thread\MessageThreadAccessControlHandler",
* },
* links = {
* "canonical" = "/message-thread/{message_thread}",
* "edit-form" = "/message-thread/{message_thread}/edit",
* "delete-form" = "/message-thread/{message_thread}/delete"
* "canonical" = "/message/thread/{message_thread}",
* "edit-form" = "/message/thread/{message_thread}/edit",
* "delete-form" = "/message/thread/{message_thread}/delete"
* },
* field_ui_base_route = "entity.message_thread_template.edit_form"
* )
......
......@@ -98,7 +98,7 @@ class MessageThreadRoutes implements ContainerInjectionInterface {
$route_collection->add('message_thread.' . $name, $route);
}
$route = (new Route('/message-thread/{message_thread}'))
$route = (new Route('/message/thread/{message_thread}'))
->setDefaults([
'_entity_view' => 'message_thread.full',
'_title_callback' => 'Drupal\message_thread\Controller\MessageThreadController::messageThreadTitle',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment