You are here

public static function FormNodeFormAlter::hook in General Data Protection Regulation Compliance 8

Hook.

1 call to FormNodeFormAlter::hook()
gdpr_compliance_form_node_form_alter in ./gdpr_compliance.module
Implements hook_form_TYPE_alter().

File

src/Hook/FormNodeFormAlter.php, line 16

Class

FormNodeFormAlter
Hook hook_form_node_alter().

Namespace

Drupal\gdpr_compliance\Hook

Code

public static function hook(&$form, FormStateInterface $form_state, $form_id) {
  $display = FALSE;
  $config = \Drupal::config('gdpr_compliance.settings');
  if ($config
    ->get('node-mode') == 'all') {
    $display = TRUE;
  }
  elseif ($config
    ->get('node-mode') == 'custom') {
    $bundles = $config
      ->get('node-bundles');
    $formkey = substr($form_id, 5, -5);
    if (isset($bundles[$formkey]) && $bundles[$formkey]) {
      $display = TRUE;
    }
  }
  if ($display) {
    FormWarning::addWarning($form);
  }
}