diff --git a/tide_core.module b/tide_core.module index 603f84e4a..2e7175c4d 100644 --- a/tide_core.module +++ b/tide_core.module @@ -13,6 +13,7 @@ use Drupal\user\Entity\Role; use Drupal\views\ViewExecutable; use Drupal\workflows\Entity\Workflow; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Render\Markup; /** * Implements hook_views_data_alter(). @@ -189,3 +190,24 @@ function tide_core_entity_bundle_create($entity_type_id, $bundle) { } } } + +/** + * Implements hook_preprocess_HOOK(). + */ +function tide_core_preprocess_status_messages(&$variables) { + if (isset($variables['message_list']['error']) && !empty($variables['message_list']['error'])) { + foreach ($variables['message_list']['error'] as &$error_message) { + if ($error_message instanceof Markup) { + $message = $error_message->__toString(); + // We want to ensure that the error message to be altered under + // node edit context. + preg_match('/entity:node\/(\d+)/', $message, $matches); + // Checking that the error message comes from field_paragraph_link based + // on a node context. + if (strpos($message, 'Validation error on collapsed paragraph field_paragraph_link') !== FALSE && (isset($matches[1]) && is_numeric($matches[1]))) { + $error_message = t('A link in Related links field on this page is broken. Please update or remove the link and retry.'); + } + } + } + } +}