Commit bba47976 authored by New Zeal's avatar New Zeal

message history and small fixes

parent 81d328ec
...@@ -17,4 +17,9 @@ Add suitable breadcrumb for navigation ...@@ -17,4 +17,9 @@ Add suitable breadcrumb for navigation
Modify contextual dropdowns for proper access Modify contextual dropdowns for proper access
8.x-1.0-alpha7 8.x-1.0-alpha7
Remove reference to MessagePrivateAccessControlHandler which doesn't exist yet Remove reference to MessagePrivateAccessControlHandler which doesn't exist yet
\ No newline at end of file
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) { ...@@ -46,7 +46,6 @@ function message_thread_help($route_name, RouteMatchInterface $arg) {
function message_thread_form_alter(array &$form, FormStateInterface $form_state, $form_id) { 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 // 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 // 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(); $thread_templates = \Drupal::entityTypeManager()->getListBuilder('message_thread_template')->load();
foreach ($thread_templates as $name => $template) { foreach ($thread_templates as $name => $template) {
$settings = $template->getSettings(); $settings = $template->getSettings();
...@@ -113,9 +112,15 @@ function message_thread_submit_message(array &$form, FormStateInterface $form_st ...@@ -113,9 +112,15 @@ function message_thread_submit_message(array &$form, FormStateInterface $form_st
* *
* @param $variables * @param $variables
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException * @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) { function message_thread_preprocess_links(&$variables) {
if (!message_thread_is_message_route()) {
return;
}
if ($variables['theme_hook_original'] == 'links__dropbutton__operations') { if ($variables['theme_hook_original'] == 'links__dropbutton__operations') {
$account = \Drupal::currentUser(); $account = \Drupal::currentUser();
...@@ -143,6 +148,21 @@ function message_thread_preprocess_links(&$variables) { ...@@ -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(). * Implements hook_entity_extra_field_info().
*/ */
......
...@@ -33,7 +33,7 @@ class MessageThreadBreadcrumbs implements BreadcrumbBuilderInterface{ ...@@ -33,7 +33,7 @@ class MessageThreadBreadcrumbs implements BreadcrumbBuilderInterface{
$breadcrumb = new Breadcrumb(); $breadcrumb = new Breadcrumb();
$parameters = $route_match->getParameters()->all(); $parameters = $route_match->getParameters()->all();
$user = \Drupal::currentUser(); $user = \Drupal::currentUser();
if (!empty($parameters['message_thread'])) { if (!empty($parameters['message_thread']) && is_object($parameters['message_thread'])) {
$message_thread = $parameters['message_thread']; $message_thread = $parameters['message_thread'];
// Get the parent messages link // Get the parent messages link
...@@ -57,7 +57,6 @@ class MessageThreadBreadcrumbs implements BreadcrumbBuilderInterface{ ...@@ -57,7 +57,6 @@ class MessageThreadBreadcrumbs implements BreadcrumbBuilderInterface{
$message = $parameters['message']; $message = $parameters['message'];
if ($message->bundle()) { if ($message->bundle()) {
$message_thread = $this->messageThreadRelationship($message->id()); $message_thread = $this->messageThreadRelationship($message->id());
$thread_template = $message_thread->getTemplate(); $thread_template = $message_thread->getTemplate();
...@@ -71,7 +70,7 @@ class MessageThreadBreadcrumbs implements BreadcrumbBuilderInterface{ ...@@ -71,7 +70,7 @@ class MessageThreadBreadcrumbs implements BreadcrumbBuilderInterface{
$message_thread->get('field_thread_title')->getValue()[0]['value'], $message_thread->get('field_thread_title')->getValue()[0]['value'],
'entity.message_thread.canonical', [ 'entity.message_thread.canonical', [
'message_thread' => $message_thread->id() 'message_thread' => $message_thread->id()
] ]
)); ));
// Probably don't need the current message // Probably don't need the current message
// $label = isset( $message->get('field_message_private_subject')->getValue()[0]['value']) // $label = isset( $message->get('field_message_private_subject')->getValue()[0]['value'])
...@@ -88,7 +87,11 @@ class MessageThreadBreadcrumbs implements BreadcrumbBuilderInterface{ ...@@ -88,7 +87,11 @@ class MessageThreadBreadcrumbs implements BreadcrumbBuilderInterface{
} }
$contexts = [
'url'
];
$breadcrumb->addCacheContexts($contexts);
return $breadcrumb; 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