public function GoogleAnalyticsCounterCustomFieldGenerator::gacPreAddField in Google Analytics Counter 8.3
Prepares to add the custom field and saves the configuration.
Parameters
$type:
$key:
$value:
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
\Drupal\Core\Entity\EntityStorageException
Overrides GoogleAnalyticsCounterCustomFieldGeneratorInterface::gacPreAddField
File
- src/
GoogleAnalyticsCounterCustomFieldGenerator.php, line 95
Class
- GoogleAnalyticsCounterCustomFieldGenerator
- Defines the Google Analytics Counter custom field generator.
Namespace
Drupal\google_analytics_counterCode
public function gacPreAddField($type, $key, $value) {
$config_factory = \Drupal::configFactory();
// Add the field.
$this
->gacAddField($type);
// Update the gac_type_{content_type} configuration.
$config_factory
->getEditable('google_analytics_counter.settings')
->set("general_settings.{$key}", $value)
->save();
}