function schema_metatag_update_8101 in Schema.org Metatag 8
Same name and namespace in other branches
- 8.2 schema_metatag.install \schema_metatag_update_8101()
Rename aggregate_rating tags.
The "MODULE_aggregate_rating" meta tag is renamed to "MODULE_rating".
File
- ./
schema_metatag.install, line 20 - Update scripts for the Schema Metatag module.
Code
function schema_metatag_update_8101() {
/* @var $configs Drupal\metatag\Entity\MetatagDefaults */
$configs = MetatagDefaults::loadMultiple();
foreach ($configs as $config) {
$changed = FALSE;
$tags = $config
->get('tags');
foreach ($tags as $tag_name => $tag) {
if (strpos($tag_name, '_aggregate_rating') !== FALSE) {
$new_name = str_replace('_aggregate_rating', '_rating', $tag_name);
$tags[$new_name] = $tags[$tag_name];
unset($tags[$tag_name]);
$changed = TRUE;
}
}
if ($changed) {
$config
->set("tags", $tags);
$config
->save();
}
}
}