public function RoleProcessor::apply in Configuration Management 7.3
Overrides AbstractProcessor::apply
File
- src/
Processors/ RoleProcessor.php, line 22
Class
Namespace
Configuration\ProcessorsCode
public function apply(Configuration $configuration, $properties = array()) {
$roles_names = array(
DRUPAL_ANONYMOUS_RID => 'anonymous_user',
DRUPAL_AUTHENTICATED_RID => 'authenticated_user',
);
foreach (role_export_roles() as $role) {
if ($role->rid > 2) {
$roles_names[$role->rid] = $role->machine_name;
}
}
$converted = array();
foreach ($properties as $property) {
$array = $configuration
->getValue($property);
foreach ($array as $key => $value) {
switch ($this
->getName()) {
case 'RoleKeyId2Name':
$converted[$roles_names[$key]] = $value;
break;
case 'RoleValueId2Name':
$converted[$key] = $roles_names[$value];
break;
case 'RoleAllId2Name':
$converted[$roles_names[$key]] = $roles_names[$value];
break;
}
}
$configuration
->setValue($property, $converted);
}
}