You are here

public function VocabularyProcessor::apply in Configuration Management 7.3

Overrides AbstractProcessor::apply

File

src/Processors/VocabularyProcessor.php, line 22

Class

VocabularyProcessor

Namespace

Configuration\Processors

Code

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