FormContactMessageFormAlter.php in General Data Protection Regulation Compliance 8
File
src/Hook/FormContactMessageFormAlter.php
View source
<?php
namespace Drupal\gdpr_compliance\Hook;
use Drupal\Core\Form\FormStateInterface;
use Drupal\gdpr_compliance\Utility\FormWarning;
class FormContactMessageFormAlter {
public static function hook(&$form, FormStateInterface $form_state, $form_id) {
$display = FALSE;
$config = \Drupal::config('gdpr_compliance.settings');
if ($config
->get('contact_message-mode') == 'all') {
$display = TRUE;
}
elseif ($config
->get('contact_message-mode') == 'custom') {
$bundles = $config
->get('contact_message-bundles');
$formkey = substr($form_id, 16, -5);
if (isset($bundles[$formkey]) && $bundles[$formkey]) {
$display = TRUE;
}
}
if ($display) {
FormWarning::addWarning($form);
}
}
}