class VocabularyProcessor in Configuration Management 7.3
Hierarchy
- class \Configuration\Processors\AbstractProcessor implements ProcessorInterface
- class \Configuration\Processors\VocabularyProcessor
Expanded class hierarchy of VocabularyProcessor
File
- src/
Processors/ VocabularyProcessor.php, line 7
Namespace
Configuration\ProcessorsView source
class VocabularyProcessor extends AbstractProcessor {
public static function availableProcessors() {
return array(
// Converts the keys of an array from Vocabulary Ids to Vocabulary machine names.
'VocabularyKeyId2Name',
// Converts the values of an array from Vocabulary Ids to Vocabulary machine names.
'VocabularyValueId2Name',
// Converts the keys and the values of an array from Vocabulary Ids to Vocabulary machine names.
'VocabularyAllId2Name',
);
}
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);
}
}
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);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AbstractProcessor:: |
protected | property | ||
AbstractProcessor:: |
protected | property | ||
AbstractProcessor:: |
public | function | ||
AbstractProcessor:: |
public static | function | ||
AbstractProcessor:: |
public | function | ||
VocabularyProcessor:: |
public | function |
Overrides AbstractProcessor:: |
|
VocabularyProcessor:: |
public static | function |
Overrides AbstractProcessor:: |
|
VocabularyProcessor:: |
public | function |
Overrides AbstractProcessor:: |