function google_analytics_counter_update_8006 in Google Analytics Counter 8.3
Issue #3009673: Add the Google Analytics Counter field to existing installations.
File
- ./
google_analytics_counter.install, line 201 - Update, and uninstall functions for the Google Analytics Counter module.
Code
function google_analytics_counter_update_8006() {
// Check if field storage exists.
$config = FieldStorageConfig::loadByName('node', 'field_google_analytics_counter');
if (isset($config)) {
return NULL;
}
// Obtain configuration from yaml files.
$config_path = 'modules/contrib/google_analytics_counter/config/optional';
$source = new FileStorage($config_path);
// Obtain the storage manager for field storage bases.
// Create the new field configuration from the yaml configuration and save.
\Drupal::entityTypeManager()
->getStorage('field_storage_config')
->create($source
->read('field.storage.node.field_google_analytics_counter'))
->save();
}