20 $count_friends =
function (
$user) {
23 'relationship' =>
'friend',
24 'relationship_guid' =>
$user->guid,
25 'inverse_relationship' =>
false,
26 'metadata_names' =>
'__faker',
34 $profile_fields_config =
_elgg_services()->fields->get(
'user',
'user');
36 foreach ($profile_fields_config as
$field) {
37 $profile_fields[$field[
'name']] = $field[
'#type'];
40 while ($this->
getCount() < $this->limit) {
43 'profile_fields' => $profile_fields,
52 $exclude[] =
$user->guid;
56 if ($count_friends(
$user)) {
62 $this->
log(
"Created new friend collection for user {$user->getDisplayName()} [collection_id: {$collection->id}]");
65 $friends_limit = $this->
faker()->numberBetween(5, 10);
67 $friends_exclude = [
$user->guid];
68 while ($count_friends(
$user) < $friends_limit) {
74 $friends_exclude[] = $friend->guid;
76 if (
$user->addFriend($friend->guid,
true)) {
77 $this->
log(
"User {$user->getDisplayName()} [guid: {$user->guid}] friended user {$friend->getDisplayName()} [guid: {$friend->guid}]");
79 if ($collection instanceof \ElggAccessCollection && $this->
faker()->
boolean()) {
80 $collection->addMember($friend->guid);
84 $since = $this->create_since;
89 'view' =>
'river/relationship/friend/create',
90 'action_type' =>
'friend',
91 'subject_guid' =>
$user->guid,
92 'object_guid' => $friend->guid,
95 foreach ($river as
$item) {
97 $update->set(
'posted', $update->param($this->getRandomCreationTimestamp(),
ELGG_VALUE_TIMESTAMP))
98 ->where($update->compare(
'id',
'=', $item->id,
ELGG_VALUE_ID));
103 $this->create_since = $since;
118 'metadata_name' =>
'__faker',
121 'batch_inc_offset' =>
false,
126 if ($user->delete(
true,
true)) {
127 $this->
log(
"Deleted user {$user->guid}");
129 $this->
log(
"Failed to delete user {$user->guid}");
static table(string $table)
Returns a QueryBuilder for updating data in a given table.
faker(string $locale= 'en_US')
Returns an instance of faker.
Thrown when the seeding has exceeded the max attempts for trying to create an .
if(empty($user_guids)) $users
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.