You are here

function eu_cookie_compliance_update_8111 in EU Cookie Compliance (GDPR Compliance) 8

Adding config variable for the popup info template.

File

./eu_cookie_compliance.install, line 346
Update scripts for the EU Cookie Compliance module.

Code

function eu_cookie_compliance_update_8111() {
  $popup_info_template = \Drupal::configFactory()
    ->get('eu_cookie_compliance.settings')
    ->get('popup_info_template');
  if ($popup_info_template === NULL) {
    $method = \Drupal::configFactory()
      ->get('eu_cookie_compliance.settings')
      ->get('method');

    // Set popup_info_template value to 'new' if method is not 'consent by
    // default'.
    $popup_info_template = $method === 'default' ? 'legacy' : 'new';
    \Drupal::configFactory()
      ->getEditable('eu_cookie_compliance.settings')
      ->set('popup_info_template', $popup_info_template)
      ->save();
  }
}