18 $count_friends =
function (
$user) {
21 'relationship' =>
'friend',
22 'relationship_guid' =>
$user->guid,
23 'inverse_relationship' =>
false,
24 'metadata_names' =>
'__faker',
32 $profile_fields_config =
_elgg_services()->fields->get(
'user',
'user');
34 foreach ($profile_fields_config as
$field) {
35 $profile_fields[$field[
'name']] = $field[
'#type'];
38 while ($this->
getCount() < $this->limit) {
41 'profile_fields' => $profile_fields,
53 $exclude[] =
$user->guid;
57 if ($count_friends(
$user)) {
63 $this->
log(
"Created new friend collection for user {$user->getDisplayName()} [collection_id: {$collection->id}]");
66 $friends_limit = $this->
faker()->numberBetween(5, 10);
68 $friends_exclude = [
$user->guid];
69 while ($count_friends(
$user) < $friends_limit) {
75 $friends_exclude[] = $friend->guid;
77 if (
$user->addFriend($friend->guid,
true)) {
78 $this->
log(
"User {$user->getDisplayName()} [guid: {$user->guid}] friended user {$friend->getDisplayName()} [guid: {$friend->guid}]");
80 if ($collection instanceof \ElggAccessCollection && $this->
faker()->
boolean()) {
81 $collection->addMember($friend->guid);
85 $since = $this->create_since;
90 'view' =>
'river/relationship/friend/create',
91 'action_type' =>
'friend',
92 'subject_guid' =>
$user->guid,
93 'object_guid' => $friend->guid,
96 foreach ($river as
$item) {
98 $update->set(
'posted', $update->param($this->getRandomCreationTimestamp(),
ELGG_VALUE_TIMESTAMP))
99 ->where($update->compare(
'id',
'=', $item->id,
ELGG_VALUE_ID));
104 $this->create_since = $since;
120 'metadata_name' =>
'__faker',
123 'batch_inc_offset' =>
false,
128 if ($user->delete()) {
129 $this->
log(
"Deleted user {$user->guid}");
131 $this->
log(
"Failed to delete user {$user->guid}");
faker(string $locale= 'en_US')
Returns an instance of faker.
if(empty($user_guids)) $users
static table($table, $alias=null)
{}
createUser(array $properties=[])
Create a new fake user.
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.
elgg_get_river(array $options=[])
Get river items.
createIcon(\ElggEntity $entity)
Create an icon for an entity.
const ELGG_VALUE_TIMESTAMP
log($level, $message, array $context=[])
Log a message.
setCreateSince($since= 'now')
Set a time for entities to be created after.
_elgg_services()
Get the global service provider.
elgg_create_access_collection(string $name, int $owner_guid=0, string $subtype=null)
Creates a new access collection.
getCount()
Get the count of the seeded entities.