public function MetatagDefaults::overwriteTags in Metatag 8
Overwrite the current tags with new values.
File
- src/
Entity/ MetatagDefaults.php, line 114
Class
- MetatagDefaults
- Defines the Metatag defaults entity.
Namespace
Drupal\metatag\EntityCode
public function overwriteTags(array $new_tags = []) {
if (!empty($new_tags)) {
// Get the existing tags.
$combined_tags = $this
->get('tags');
// Loop over the new tags, adding them to the existing tags.
foreach ($new_tags as $tag_name => $data) {
$combined_tags[$tag_name] = $data;
}
// Save the combination of the existing tags + the new tags.
$this
->set('tags', $combined_tags);
}
}