You are here

public function MetatagDefaults::revert in Metatag 8

Reverts an entity to its default values.

File

src/Entity/MetatagDefaults.php, line 101

Class

MetatagDefaults
Defines the Metatag defaults entity.

Namespace

Drupal\metatag\Entity

Code

public function revert() {
  $default_install_path = drupal_get_path('module', 'metatag') . '/' . InstallStorage::CONFIG_INSTALL_DIRECTORY;
  $storage = new FileStorage($default_install_path, StorageInterface::DEFAULT_COLLECTION);
  $default_config_data = $storage
    ->read('metatag.metatag_defaults.' . $this
    ->id());
  if ($default_config_data) {
    $this
      ->set('tags', $default_config_data['tags']);
    $this
      ->save();
  }
}