public function DemoContent::scrambleData in Open Social 8.9
Same name and namespace in other branches
- 8.7 modules/custom/social_demo/src/DemoContent.php \Drupal\social_demo\DemoContent::scrambleData()
- 8.8 modules/custom/social_demo/src/DemoContent.php \Drupal\social_demo\DemoContent::scrambleData()
- 10.3.x modules/custom/social_demo/src/DemoContent.php \Drupal\social_demo\DemoContent::scrambleData()
- 10.0.x modules/custom/social_demo/src/DemoContent.php \Drupal\social_demo\DemoContent::scrambleData()
- 10.1.x modules/custom/social_demo/src/DemoContent.php \Drupal\social_demo\DemoContent::scrambleData()
- 10.2.x modules/custom/social_demo/src/DemoContent.php \Drupal\social_demo\DemoContent::scrambleData()
Scramble it.
Parameters
array $data: The data array to scramble.
int|null $max: How many items to generate.
Overrides DemoContentInterface::scrambleData
5 calls to DemoContent::scrambleData()
- DemoComment::createContent in modules/
custom/ social_demo/ src/ DemoComment.php - Creates content.
- DemoEntity::createContent in modules/
custom/ social_demo/ src/ DemoEntity.php - Creates content.
- DemoGroup::createContent in modules/
custom/ social_demo/ src/ DemoGroup.php - Creates content.
- DemoSystem::createContent in modules/
custom/ social_demo/ src/ DemoSystem.php - Creates content.
- DemoTaxonomyTerm::createContent in modules/
custom/ social_demo/ src/ DemoTaxonomyTerm.php - Creates content.
2 methods override DemoContent::scrambleData()
- DemoNode::scrambleData in modules/
custom/ social_demo/ src/ DemoNode.php - Scramble it.
- DemoUser::scrambleData in modules/
custom/ social_demo/ src/ DemoUser.php - Scramble it.
File
- modules/
custom/ social_demo/ src/ DemoContent.php, line 291
Class
- DemoContent
- Class DemoContent.
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;
$new_data[$uuid] = $item;
}
return $new_data;
}