You are here

public function RoleProcessor::revert in Configuration Management 7.3

Overrides AbstractProcessor::revert

File

src/Processors/RoleProcessor.php, line 56

Class

RoleProcessor

Namespace

Configuration\Processors

Code

public function revert(Configuration $configuration, $properties = array()) {
  $roles_ids = array(
    'anonymous_user' => DRUPAL_ANONYMOUS_RID,
    'authenticated_user' => DRUPAL_AUTHENTICATED_RID,
  );
  foreach (role_export_roles() as $role) {
    if ($role->rid > 2) {
      $roles_ids[$role->machine_name] = $role->rid;
    }
  }
  $converted = array();
  foreach ($properties as $property) {
    $array = $configuration
      ->getValue($property);
    foreach ($array as $key => $value) {
      switch ($this
        ->getName()) {
        case 'RoleKeyId2Name':
          $converted[$roles_ids[$key]] = $value;
          break;
        case 'RoleValueId2Name':
          $converted[$key] = $roles_ids[$value];
          break;
        case 'RoleAllId2Name':
          $converted[$roles_ids[$key]] = $roles_ids[$value];
          break;
      }
    }
    $configuration
      ->setValue($property, $converted);
  }
}