19 $count_friends =
function (
$user) {
22 'relationship' =>
'friend',
23 'relationship_guid' =>
$user->guid,
24 'inverse_relationship' =>
false,
25 'metadata_names' =>
'__faker',
33 $profile_fields_config =
_elgg_services()->fields->get(
'user',
'user');
35 foreach ($profile_fields_config as
$field) {
36 $profile_fields[$field[
'name']] = $field[
'#type'];
39 while ($this->
getCount() < $this->limit) {
42 'profile_fields' => $profile_fields,
51 $exclude[] =
$user->guid;
55 if ($count_friends(
$user)) {
61 $this->
log(
"Created new friend collection for user {$user->getDisplayName()} [collection_id: {$collection->id}]");
64 $friends_limit = $this->
faker()->numberBetween(5, 10);
66 $friends_exclude = [
$user->guid];
67 while ($count_friends(
$user) < $friends_limit) {
73 $friends_exclude[] = $friend->guid;
75 if (
$user->addFriend($friend->guid,
true)) {
76 $this->
log(
"User {$user->getDisplayName()} [guid: {$user->guid}] friended user {$friend->getDisplayName()} [guid: {$friend->guid}]");
78 if ($collection instanceof \ElggAccessCollection && $this->
faker()->
boolean()) {
79 $collection->addMember($friend->guid);
83 $since = $this->create_since;
88 'view' =>
'river/relationship/friend/create',
89 'action_type' =>
'friend',
90 'subject_guid' =>
$user->guid,
91 'object_guid' => $friend->guid,
94 foreach ($river as
$item) {
96 $update->set(
'posted', $update->param($this->getRandomCreationTimestamp(),
ELGG_VALUE_TIMESTAMP))
97 ->where($update->compare(
'id',
'=', $item->id,
ELGG_VALUE_ID));
102 $this->create_since = $since;
117 'metadata_name' =>
'__faker',
120 'batch_inc_offset' =>
false,
125 if ($user->delete()) {
126 $this->
log(
"Deleted user {$user->guid}");
128 $this->
log(
"Failed to delete user {$user->guid}");
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
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.