diff --git a/quant.module b/quant.module index f827a82..961e0ca 100644 --- a/quant.module +++ b/quant.module @@ -6,6 +6,7 @@ */ use Drupal\Core\Access\AccessResult; +use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; @@ -520,3 +521,26 @@ function quant_preprocess_views_view(array &$variables) { } } + +/** + * Implements hook_node_view(). + */ +function quant_node_view(array &$build, EntityInterface $node, EntityViewDisplayInterface $display, $view_mode) { + + // If there are any webforms in layout_builder, add warning for admins. + if ($node->hasField('layout_builder__layout') && !$node->get('layout_builder__layout')->isEmpty() && \Drupal::currentUser()->hasRole('administrator')) { + $sections = $node->get('layout_builder__layout')->getSections(); + + foreach ($sections as $section) { + $components = $section->getComponents(); + + foreach ($components as $component) { + $configuration = $component->get('configuration'); + if (isset($configuration['webform_id'])) { + \Drupal::messenger()->addWarning(t('Forms need special handling for a static website. See the documentation for your options.')); + return; + } + } + } + } +}