avatars_gravatar.install in Avatar Kit 8
Install, update and uninstall functions for Gravatar module.
File
avatars_gravatar/avatars_gravatar.installView source
<?php
/**
* @file
* Install, update and uninstall functions for Gravatar module.
*/
/**
* Migrate plugins with old plugin IDs to new plugin IDs and settings.
*/
function avatars_gravatar_update_8001() {
$plugin_ids = [
// Old plugin ID => 'type' in plugin settings.
'gravatar_identicon' => 'identicon',
'gravatar_monsterid' => 'monsterid',
'gravatar_wavatar' => 'wavatar',
'gravatar_retro' => 'retro',
];
$config_factory = \Drupal::configFactory();
foreach ($config_factory
->listAll('avatars.generator.') as $config_id) {
$config = $config_factory
->getEditable($config_id);
$old_plugin_id = $config
->get('plugin');
if ($old_plugin_id && isset($plugin_ids[$old_plugin_id])) {
$config
->set('plugin', 'gravatar_generator')
->set('provider', 'avatars_gravatar')
->set('settings', [
'type' => $plugin_ids[$old_plugin_id],
])
->save();
}
}
}
/**
* Implements hook_update_dependencies().
*/
function avatars_gravatar_update_dependencies() {
$dependencies['avatars_gravatar'][8001] = [
'avatars' => 8001,
];
return $dependencies;
}
Functions
Name | Description |
---|---|
avatars_gravatar_update_8001 | Migrate plugins with old plugin IDs to new plugin IDs and settings. |
avatars_gravatar_update_dependencies | Implements hook_update_dependencies(). |