Skip to content

Commit

Permalink
Add a warning if a webform is on the page.
Browse files Browse the repository at this point in the history
  • Loading branch information
kepol committed Jan 31, 2025
1 parent 7c9f6d4 commit 4cbd423
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions quant.module
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()) {
$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. <a href="https://docs.quantcdn.io/integrations/drupal">See the documentation for your options</a>.'));
return;
}
}
}
}
}

0 comments on commit 4cbd423

Please sign in to comment.