You are here

public function GoogleAnalyticsCounterCustomFieldGenerator::gacChangeConfigToNull in Google Analytics Counter 8.3

Creates the gac_type_{content_type} configuration on installation or update.

Overrides GoogleAnalyticsCounterCustomFieldGeneratorInterface::gacChangeConfigToNull

File

src/GoogleAnalyticsCounterCustomFieldGenerator.php, line 239

Class

GoogleAnalyticsCounterCustomFieldGenerator
Defines the Google Analytics Counter custom field generator.

Namespace

Drupal\google_analytics_counter

Code

public function gacChangeConfigToNull() {
  $config_factory = \Drupal::configFactory();
  $content_types = \Drupal::service('entity.manager')
    ->getStorage('node_type')
    ->loadMultiple();
  foreach ($content_types as $machine_name => $content_type) {
    $config_factory
      ->getEditable('google_analytics_counter.settings')
      ->set("general_settings.gac_type_{$machine_name}", NULL)
      ->save();
  }
}