20 $count_members =
function (
$group) {
23 'relationship' =>
'member',
24 'relationship_guid' =>
$group->getGUID(),
25 'inverse_relationship' =>
true,
26 'metadata_names' =>
'__faker',
32 $profile_fields_config =
_elgg_services()->fields->get(
'group',
'group');
34 foreach ($profile_fields_config as
$field) {
35 $profile_fields[$field[
'name']] = $field[
'#type'];
38 while ($this->
getCount() < $this->limit) {
45 'profile_fields' => $profile_fields,
57 if ($count_members(
$group) > 1) {
62 $members_limit = $this->
faker()->numberBetween(1, 5);
64 $members_exclude = [];
66 while ($count_members(
$group) - 1 < $members_limit) {
72 $members_exclude[] = $member->guid;
74 if (
$group->join($member)) {
75 $this->
log(
"User {$member->getDisplayName()} [guid: {$member->guid}] joined group {$group->getDisplayName()} [guid: {$group->guid}]");
78 if (!
$group->isPublicMembership()) {
81 $members_exclude[] = $invitee->guid;
82 if (!
$group->isMember($invitee)) {
83 $group->addRelationship($invitee->guid,
'invited');
84 $this->
log(
"User {$invitee->getDisplayName()} [guid: {$invitee->guid}] was invited to {$group->getDisplayName()} [guid: {$group->guid}]");
90 $members_exclude[] = $requestor->guid;
91 if (!
$group->hasRelationship($requestor->guid,
'invited')
92 && !
$group->isMember($requestor)
94 $requestor->addRelationship(
$group->guid,
'membership_request');
95 $this->
log(
"User {$invitee->getDisplayName()} [guid: {$invitee->guid}] requested to join {$group->getDisplayName()} [guid: {$group->guid}]");
112 'metadata_name' =>
'__faker',
115 'batch_inc_offset' =>
false,
119 foreach ($groups as
$group) {
120 if ($group->delete(
true,
true)) {
121 $this->
log(
"Deleted group {$group->guid}");
123 $this->
log(
"Failed to delete group {$group->guid}");
124 $groups->reportFailure();
if(!elgg_get_config('trash_enabled')) $group
getRandomGroupVisibility()
Returns random visibility value.
faker(string $locale= 'en_US')
Returns an instance of faker.
Thrown when the seeding has exceeded the max attempts for trying to create an .
getRandomGroupContentAccessMode()
Returns random content access mode value.
createGroup(array $properties=[])
Create a new fake group.
elgg_get_entities(array $options=[])
Fetches/counts entities or performs a calculation on their properties.
advance(int $step=1)
Advance progressbar.
elgg_count_entities(array $options=[])
Returns a count of entities.
getRandomUser(array $exclude=[], bool $allow_create=true)
Returns random fake user.
createIcon(\ElggEntity $entity)
Create an icon for an entity.
log($level, $message, array $context=[])
Log a message.
_elgg_services()
Get the global service provider.
getCount()
Get the count of the seeded entities.
getRandomGroupMembership()
Returns random membership mode.