Commit bba47976 authored by New Zeal's avatar New Zeal

message history and small fixes

parent 81d328ec
......@@ -18,3 +18,8 @@ Modify contextual dropdowns for proper access
8.x-1.0-alpha7
Remove reference to MessagePrivateAccessControlHandler which doesn't exist yet
8.x-1.0-alpha8
Add route check on message_ui edit links
Add cache context to breadcrumbs
Add message history functionality
\ No newline at end of file
......@@ -46,7 +46,6 @@ function message_thread_help($route_name, RouteMatchInterface $arg) {
function message_thread_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
// When a message is created we need to ensure that the participants are included
// This is best done in the validation hook to ensure participants are not missed from submit functions
$thread_templates = \Drupal::entityTypeManager()->getListBuilder('message_thread_template')->load();
foreach ($thread_templates as $name => $template) {
$settings = $template->getSettings();
......@@ -113,9 +112,15 @@ function message_thread_submit_message(array &$form, FormStateInterface $form_st
*
* @param $variables
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
*
* todo should use this hook: message_ui_message_ui_views_contextual_links_info
*/
function message_thread_preprocess_links(&$variables) {
if (!message_thread_is_message_route()) {
return;
}
if ($variables['theme_hook_original'] == 'links__dropbutton__operations') {
$account = \Drupal::currentUser();
......@@ -143,6 +148,21 @@ function message_thread_preprocess_links(&$variables) {
}
}
/*
* Test if the current route is a message thread or message route
*/
function message_thread_is_message_route() {
$message = \Drupal::routeMatch()->getParameter('message');
if ($message) {
return TRUE;
}
$message_thread = \Drupal::routeMatch()->getParameter('message>_thread');
if ($message_thread) {
return TRUE;
}
return FALSE;
}
/**
* Implements hook_entity_extra_field_info().
*/
......
......@@ -33,7 +33,7 @@ class MessageThreadBreadcrumbs implements BreadcrumbBuilderInterface{
$breadcrumb = new Breadcrumb();
$parameters = $route_match->getParameters()->all();
$user = \Drupal::currentUser();
if (!empty($parameters['message_thread'])) {
if (!empty($parameters['message_thread']) && is_object($parameters['message_thread'])) {
$message_thread = $parameters['message_thread'];
// Get the parent messages link
......@@ -57,7 +57,6 @@ class MessageThreadBreadcrumbs implements BreadcrumbBuilderInterface{
$message = $parameters['message'];
if ($message->bundle()) {
$message_thread = $this->messageThreadRelationship($message->id());
$thread_template = $message_thread->getTemplate();
......@@ -88,7 +87,11 @@ class MessageThreadBreadcrumbs implements BreadcrumbBuilderInterface{
}
$contexts = [
'url'
];
$breadcrumb->addCacheContexts($contexts);
return $breadcrumb;
}
......
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