17 private $visibility = [
23 private $content_access_modes = [
28 private $membership = [
38 $count_groups =
function () {
41 'metadata_names' =>
'__faker',
46 $count_members =
function ($group) {
49 'relationship' =>
'member',
50 'relationship_guid' => $group->getGUID(),
51 'inverse_relationship' =>
true,
52 'metadata_names' =>
'__faker',
73 $exclude[] = $group->guid;
75 if ($count_members($group) > 1) {
80 $members_limit = $this->faker->numberBetween(5, 10);
82 $members_exclude = [];
84 while ($count_members($group) - 1 < $members_limit) {
94 $members_exclude[] = $member->guid;
96 if ($group->join($member)) {
97 $this->
log(
"User $member->name [guid: $member->guid] joined group $group->name [guid: $group->guid]");
100 if (!$group->isPublicMembership()) {
103 $members_exclude[] = $invitee->guid;
106 $this->
log(
"User $invitee->name [guid: $invitee->guid] was invited to $group->name [guid: $group->guid]");
112 $members_exclude[] = $requestor->guid;
117 $this->
log(
"User $invitee->name [guid: $invitee->guid] requested to join $group->name [guid: $group->guid]");
134 'metadata_names' =>
'__faker',
141 $groups->setIncrementOffset(
false);
143 foreach ($groups as $group) {
144 if ($group->delete()) {
145 $this->
log(
"Deleted group $group->guid");
147 $this->
log(
"Failed to delete group $group->guid");
157 $key = array_rand($this->visibility, 1);
159 return $this->visibility[
$key];
167 $key = array_rand($this->content_access_modes, 1);
169 return $this->content_access_modes[
$key];
177 $key = array_rand($this->membership, 1);
179 return $this->membership[
$key];
getRandomGroup(array $exclude=[])
Returns random fake group.
add_entity_relationship($guid_one, $relationship, $guid_two)
Create a relationship between two entities.
getRandomUser(array $exclude=[])
Returns random fake user.
createGroup(array $attributes=[], array $metadata=[])
Create a new faker group.
log($msg, $level= 'NOTICE')
Log a message.
getRandomVisibility()
Returns random visibility value.
const CONTENT_ACCESS_MODE_UNRESTRICTED
check_entity_relationship($guid_one, $relationship, $guid_two)
Check if a relationship exists between two entities.
const CONTENT_ACCESS_MODE_MEMBERS_ONLY
getRandomContentAccessMode()
Returns random content access mode value.
getRandomMembership()
Returns random membership mode.
elgg_get_entities_from_relationship($options)
Return entities matching a given query joining against a relationship.
createUser(array $attributes=[], array $metadata=[])
Create a new faker user.