Loading config/install/cookiebot.settings.yml +1 −1 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ cookiebot_cbid: "" cookiebot_block_cookies: true cookiebot_iab_enabled: false cookiebot_show_declaration: false cookiebot_show_declaration_node_path: "" cookiebot_show_declaration_node: "" exclude_paths: "" exclude_admin_theme: false exclude_uid_1: false Loading config/schema/cookiebot.schema.yml +3 −3 Original line number Diff line number Diff line Loading @@ -16,9 +16,9 @@ cookiebot.settings: cookiebot_show_declaration: type: boolean label: "Show the Cookiebot cookie declaration." cookiebot_show_declaration_node_path: type: label label: "Show the full cookie declaration on the node page with the given title." cookiebot_show_declaration_node: type: string label: "Show the full cookie declaration on the node page with the given node ID." exclude_paths: type: string label: "Exclude paths." Loading cookiebot.install +14 −0 Original line number Diff line number Diff line Loading @@ -26,3 +26,17 @@ function cookiebot_update_8002() { $config->clear('cookiebot_show_declaration_node_id'); $config->save(); } /** * Update configuration keys and migrate declaration_node_path to language-agnostic declaration_node. */ function cookiebot_update_8003() { $config = \Drupal::configFactory()->getEditable('cookiebot.settings'); $declaration_node_path = $config->get('cookiebot_show_declaration_node_path'); $path = \Drupal::service('path_alias.manager')->getPathByAlias($declaration_node_path); preg_match('/node\/(\d+)/', $path, $matches); $node = \Drupal::entityTypeManager()->getStorage('node')->load($matches[1]); $config->set('cookiebot_show_declaration_node', $node->id()); $config->clear('cookiebot_show_declaration_node_path'); $config->save(); } cookiebot.module +2 −5 Original line number Diff line number Diff line Loading @@ -161,12 +161,9 @@ function cookiebot_node_view_alter(array &$build) { return; } $declaration_node_path = $config->get('cookiebot_show_declaration_node_path'); $declaration_node = $config->get('cookiebot_show_declaration_node'); $current_nid = \Drupal::routeMatch()->getRawParameter('node'); $current_alias = \Drupal::service('path_alias.manager')->getAliasByPath('/node/' . $current_nid); // Print full cookies declaration from Cookiebot. if ($current_alias === $declaration_node_path) { if ($current_nid === $declaration_node) { $culture = $config->get('cookiebot_drupal_culture'); $cookiebot_culture = $culture ? \Drupal::languageManager()->getCurrentLanguage()->getId() : NULL; if ($cookiebot_culture) { Loading src/Form/CookiebotForm.php +5 −6 Original line number Diff line number Diff line Loading @@ -173,17 +173,16 @@ class CookiebotForm extends ConfigFormBase { ]; $declaration_node = ''; $alias = $this->aliasManager->getPathByAlias($config->get('cookiebot_show_declaration_node_path')); if (preg_match('/node\/(\d+)/', $alias, $matches)) { $declaration_node = $this->entityTypeManager->getStorage('node')->load($matches[1]); if ($config->get('cookiebot_show_declaration_node') !== NULL) { $declaration_node = $this->entityTypeManager->getStorage('node')->load($config->get('cookiebot_show_declaration_node')); } $description = $this->t('Show the full cookie declaration on the node page with the given title.'); $description = $this->t('Show the full cookie declaration on the node page with the given node ID.'); $description .= '<br />'; $description .= $this->t("Note that custom templates and modules like Panels and Display Suite can prevent the declaration from showing up. You can always place our block or manually place Cookiebot's declaration script found in their manager if your input filters allow it."); $form['cookiebot_declaration']['cookiebot_show_declaration_node_path'] = [ $form['cookiebot_declaration']['cookiebot_show_declaration_node'] = [ '#type' => 'entity_autocomplete', '#target_type' => 'node', '#title' => $this->t('Node page title'), Loading Loading @@ -273,7 +272,7 @@ class CookiebotForm extends ConfigFormBase { ->set('cookiebot_iab_enabled', $form_state->getValue('cookiebot_iab_enabled')) ->set('cookiebot_drupal_culture', $form_state->getValue('cookiebot_drupal_culture')) ->set('cookiebot_show_declaration', $form_state->getValue('cookiebot_show_declaration')) ->set('cookiebot_show_declaration_node_path', $this->aliasManager->getAliasByPath('/node/' . $form_state->getValue('cookiebot_show_declaration_node_path'))) ->set('cookiebot_show_declaration_node', $form_state->getValue('cookiebot_show_declaration_node')) ->set('exclude_paths', $form_state->getValue('exclude_paths')) ->set('exclude_admin_theme', $form_state->getValue('exclude_admin_theme')) ->set('exclude_uid_1', $form_state->getValue('exclude_uid_1')) Loading Loading
config/install/cookiebot.settings.yml +1 −1 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ cookiebot_cbid: "" cookiebot_block_cookies: true cookiebot_iab_enabled: false cookiebot_show_declaration: false cookiebot_show_declaration_node_path: "" cookiebot_show_declaration_node: "" exclude_paths: "" exclude_admin_theme: false exclude_uid_1: false Loading
config/schema/cookiebot.schema.yml +3 −3 Original line number Diff line number Diff line Loading @@ -16,9 +16,9 @@ cookiebot.settings: cookiebot_show_declaration: type: boolean label: "Show the Cookiebot cookie declaration." cookiebot_show_declaration_node_path: type: label label: "Show the full cookie declaration on the node page with the given title." cookiebot_show_declaration_node: type: string label: "Show the full cookie declaration on the node page with the given node ID." exclude_paths: type: string label: "Exclude paths." Loading
cookiebot.install +14 −0 Original line number Diff line number Diff line Loading @@ -26,3 +26,17 @@ function cookiebot_update_8002() { $config->clear('cookiebot_show_declaration_node_id'); $config->save(); } /** * Update configuration keys and migrate declaration_node_path to language-agnostic declaration_node. */ function cookiebot_update_8003() { $config = \Drupal::configFactory()->getEditable('cookiebot.settings'); $declaration_node_path = $config->get('cookiebot_show_declaration_node_path'); $path = \Drupal::service('path_alias.manager')->getPathByAlias($declaration_node_path); preg_match('/node\/(\d+)/', $path, $matches); $node = \Drupal::entityTypeManager()->getStorage('node')->load($matches[1]); $config->set('cookiebot_show_declaration_node', $node->id()); $config->clear('cookiebot_show_declaration_node_path'); $config->save(); }
cookiebot.module +2 −5 Original line number Diff line number Diff line Loading @@ -161,12 +161,9 @@ function cookiebot_node_view_alter(array &$build) { return; } $declaration_node_path = $config->get('cookiebot_show_declaration_node_path'); $declaration_node = $config->get('cookiebot_show_declaration_node'); $current_nid = \Drupal::routeMatch()->getRawParameter('node'); $current_alias = \Drupal::service('path_alias.manager')->getAliasByPath('/node/' . $current_nid); // Print full cookies declaration from Cookiebot. if ($current_alias === $declaration_node_path) { if ($current_nid === $declaration_node) { $culture = $config->get('cookiebot_drupal_culture'); $cookiebot_culture = $culture ? \Drupal::languageManager()->getCurrentLanguage()->getId() : NULL; if ($cookiebot_culture) { Loading
src/Form/CookiebotForm.php +5 −6 Original line number Diff line number Diff line Loading @@ -173,17 +173,16 @@ class CookiebotForm extends ConfigFormBase { ]; $declaration_node = ''; $alias = $this->aliasManager->getPathByAlias($config->get('cookiebot_show_declaration_node_path')); if (preg_match('/node\/(\d+)/', $alias, $matches)) { $declaration_node = $this->entityTypeManager->getStorage('node')->load($matches[1]); if ($config->get('cookiebot_show_declaration_node') !== NULL) { $declaration_node = $this->entityTypeManager->getStorage('node')->load($config->get('cookiebot_show_declaration_node')); } $description = $this->t('Show the full cookie declaration on the node page with the given title.'); $description = $this->t('Show the full cookie declaration on the node page with the given node ID.'); $description .= '<br />'; $description .= $this->t("Note that custom templates and modules like Panels and Display Suite can prevent the declaration from showing up. You can always place our block or manually place Cookiebot's declaration script found in their manager if your input filters allow it."); $form['cookiebot_declaration']['cookiebot_show_declaration_node_path'] = [ $form['cookiebot_declaration']['cookiebot_show_declaration_node'] = [ '#type' => 'entity_autocomplete', '#target_type' => 'node', '#title' => $this->t('Node page title'), Loading Loading @@ -273,7 +272,7 @@ class CookiebotForm extends ConfigFormBase { ->set('cookiebot_iab_enabled', $form_state->getValue('cookiebot_iab_enabled')) ->set('cookiebot_drupal_culture', $form_state->getValue('cookiebot_drupal_culture')) ->set('cookiebot_show_declaration', $form_state->getValue('cookiebot_show_declaration')) ->set('cookiebot_show_declaration_node_path', $this->aliasManager->getAliasByPath('/node/' . $form_state->getValue('cookiebot_show_declaration_node_path'))) ->set('cookiebot_show_declaration_node', $form_state->getValue('cookiebot_show_declaration_node')) ->set('exclude_paths', $form_state->getValue('exclude_paths')) ->set('exclude_admin_theme', $form_state->getValue('exclude_admin_theme')) ->set('exclude_uid_1', $form_state->getValue('exclude_uid_1')) Loading