You are here

class FormContactMessageFormAlter in General Data Protection Regulation Compliance 8

Hook hook_form_contact_message_form_alter().

Hierarchy

Expanded class hierarchy of FormContactMessageFormAlter

1 file declares its use of FormContactMessageFormAlter
gdpr_compliance.module in ./gdpr_compliance.module
Contains Hooks.

File

src/Hook/FormContactMessageFormAlter.php, line 11

Namespace

Drupal\gdpr_compliance\Hook
View source
class FormContactMessageFormAlter {

  /**
   * Hook.
   */
  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);
    }
  }

}

Members