You are here

function user_role_features_export_render in Features 7

Same name and namespace in other branches
  1. 6 includes/features.user.inc \user_role_features_export_render()
  2. 7.2 includes/features.user.inc \user_role_features_export_render()

Implements hook_features_export_render().

File

includes/features.user.inc, line 176

Code

function user_role_features_export_render($module, $data) {
  $code = array();
  $code[] = '  $roles = array();';
  $code[] = '';
  foreach ($data as $name) {
    if ($role = user_role_load_by_name($name)) {
      unset($role->rid);
      $role_identifier = features_var_export($name);
      $role_export = features_var_export($role, '  ');
      $code[] = "  // Exported role: {$name}.";
      $code[] = "  \$roles[{$role_identifier}] = {$role_export};";
      $code[] = "";
    }
  }
  $code[] = '  return $roles;';
  $code = implode("\n", $code);
  return array(
    'user_default_roles' => $code,
  );
}