function eu_cookie_compliance_install in EU Cookie Compliance (GDPR Compliance) 8
Same name and namespace in other branches
- 5 eu_cookie_compliance.install \eu_cookie_compliance_install()
- 6 eu_cookie_compliance.install \eu_cookie_compliance_install()
- 7.2 eu_cookie_compliance.install \eu_cookie_compliance_install()
- 7 eu_cookie_compliance.install \eu_cookie_compliance_install()
- 2.0.x eu_cookie_compliance.install \eu_cookie_compliance_install()
Implements hook_install().
File
- ./
eu_cookie_compliance.install, line 80 - Update scripts for the EU Cookie Compliance module.
Code
function eu_cookie_compliance_install() {
module_load_include('module', 'eu_cookie_compliance', 'eu_cookie_compliance');
$roles = Role::loadMultiple();
$permission = 'display eu cookie compliance popup';
foreach ($roles as $rid => $role) {
user_role_grant_permissions($rid, [
$permission,
]);
}
if (Settings::get('eu_cookie_compliance_validate_filter_format', TRUE)) {
// Allow individual installations to opt out of the filter format validation
// behaviour.
$all_filter_formats = filter_formats(\Drupal::currentUser());
$default_filter_format = filter_fallback_format();
if (count($all_filter_formats)) {
// Determine the best default text format to use.
$default_filter_format = filter_default_format();
$full_html_format = FilterFormat::load('full_html');
if (($default_filter_format === 'restricted_html' || $default_filter_format === 'plain_text') && $full_html_format !== NULL && $full_html_format
->get('status')) {
$default_filter_format = 'full_html';
}
}
}
// We can't be sure "Restricted HTML" exists.
// Initialize rich text editors with a text format that actually exists.
// https://www.drupal.org/project/eu_cookie_compliance/issues/2979440 .
$config = \Drupal::configFactory()
->getEditable('eu_cookie_compliance.settings');
if (!$config
->get('uuid')) {
$config
->set('uuid', \Drupal::service('uuid')
->generate());
}
$config
->set('popup_agreed.format', $default_filter_format)
->set('popup_info.format', $default_filter_format)
->set('mobile_popup_info.format', $default_filter_format)
->set('withdraw_message.format', $default_filter_format)
->save();
eu_cookie_compliance_module_set_weight();
}