You are here

public function VocabularyProcessor::revert in Configuration Management 7.3

Overrides AbstractProcessor::revert

File

src/Processors/VocabularyProcessor.php, line 52

Class

VocabularyProcessor

Namespace

Configuration\Processors

Code

public function revert(Configuration $configuration, $properties = array()) {
  $vocabulary_vids = array();
  $vocabularies = taxonomy_get_vocabularies();
  foreach ($vocabularies as $vocabulary) {
    $vocabulary_vids[$vocabulary->machine_name] = $vocabulary->vid;
  }
  $converted = array();
  foreach ($properties as $property) {
    $array = $configuration
      ->getValue($property);
    foreach ($array as $key => $value) {
      switch ($this
        ->getName()) {
        case 'VocabularyKeyId2Name':
          $converted[$Vocabularys_ids[$key]] = $value;
          break;
        case 'VocabularyValueId2Name':
          $converted[$key] = $Vocabularys_ids[$value];
          break;
        case 'VocabularyAllId2Name':
          $converted[$Vocabularys_ids[$key]] = $Vocabularys_ids[$value];
          break;
      }
    }
    $configuration
      ->setValue($property, $converted);
  }
}