public function DemoUser::scrambleData in Open Social 8.8
Same name and namespace in other branches
- 8.9 modules/custom/social_demo/src/DemoUser.php \Drupal\social_demo\DemoUser::scrambleData()
- 8.7 modules/custom/social_demo/src/DemoUser.php \Drupal\social_demo\DemoUser::scrambleData()
- 10.3.x modules/custom/social_demo/src/DemoUser.php \Drupal\social_demo\DemoUser::scrambleData()
- 10.0.x modules/custom/social_demo/src/DemoUser.php \Drupal\social_demo\DemoUser::scrambleData()
- 10.1.x modules/custom/social_demo/src/DemoUser.php \Drupal\social_demo\DemoUser::scrambleData()
- 10.2.x modules/custom/social_demo/src/DemoUser.php \Drupal\social_demo\DemoUser::scrambleData()
Scramble it.
Parameters
array $data: The data array to scramble.
int|null $max: How many items to generate.
Overrides DemoContent::scrambleData
1 call to DemoUser::scrambleData()
- DemoUser::createContent in modules/
custom/ social_demo/ src/ DemoUser.php - Creates content.
File
- modules/
custom/ social_demo/ src/ DemoUser.php, line 224
Class
- DemoUser
- Class DemoUser.
Namespace
Drupal\social_demoCode
public function scrambleData(array $data, $max = NULL) {
$new_data = [];
for ($i = 0; $i < $max; $i++) {
// Get a random item from the array.
$old_uuid = array_rand($data);
$item = $data[$old_uuid];
$uuid = 'ScrambledDemo_' . time() . '_' . $i;
$item['uuid'] = $uuid;
$item['name'] = $uuid;
$item['first_name'] = 'First';
$item['last_name'] = 'Last Name';
$item['self_introduction'] = $uuid;
$item['mail'] = $uuid . '@example.com';
$item['created'] = '-' . random_int(1, 2 * 365) . ' day|' . random_int(0, 23) . ':' . random_int(0, 59);
$new_data[$uuid] = $item;
}
return $new_data;
}