Elgg  Version 4.3
Seeding.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Traits;
4 
15 use Faker\Factory;
17 
24 trait Seeding {
25 
26  use GroupHelpers;
27  use TimeHelpers;
28 
34  protected $MAX_ATTEMPTS = 10;
35 
39  protected $faker;
40 
48  public function faker($locale = 'en_US') {
49  if (!isset($this->faker)) {
50  $this->faker = Factory::create($locale);
51  }
52 
53  $this->faker->addProvider(new LocalImage($this->faker));
54 
55  return $this->faker;
56  }
57 
63  public function getDomain() {
64  return elgg_get_site_entity()->getDomain();
65  }
66 
72  public function getEmailDomain() {
73  $email = elgg_get_site_entity()->email;
74  if (!$email) {
75  $email = "noreply@{$this->getDomain()}";
76  }
77 
78  list(, $domain) = explode('@', $email);
79 
80  if (sizeof(explode('.', $domain)) <= 1) {
81  $domain = 'example.net';
82  }
83 
84  return $domain;
85  }
86 
92  public function getRandomSubtype() {
93  return substr(sha1(microtime() . rand()), 0, 25);
94  }
95 
107  public function createUser(array $attributes = [], array $metadata = [], array $options = []): \ElggUser {
108 
109  $create = function () use ($attributes, $metadata, $options) {
110  $metadata['__faker'] = true;
111 
112  if (empty($metadata['password'])) {
113  $metadata['password'] = elgg_generate_password();
114  }
115 
116  if (empty($metadata['name'])) {
117  $metadata['name'] = $this->faker()->name;
118  }
119 
120  if (empty($metadata['username'])) {
121  $metadata['username'] = $this->getRandomUsername($metadata['name']);
122  }
123 
124  if (empty($metadata['email'])) {
125  $metadata['email'] = $this->getRandomEmail($metadata['username']);
126  }
127 
128  if (empty($attributes['subtype'])) {
129  $attributes['subtype'] = 'user';
130  }
131 
132  $user = false;
133 
134  try {
136  'username' => elgg_extract('username', $metadata),
137  'password' => elgg_extract('password', $metadata),
138  'name' => elgg_extract('name', $metadata),
139  'email' => elgg_extract('email', $metadata),
140  'subtype' => elgg_extract('subtype', $attributes),
141  ]);
142 
143  // make sure we have a cleanly loaded user entity
144  $user = get_user($user->guid);
145 
146  if (!isset($attributes['time_created'])) {
147  $attributes['time_created'] = $this->getRandomCreationTimestamp();
148  }
149  if (!empty($attributes['time_created'])) {
150  $user->time_created = $attributes['time_created'];
151  }
152 
153  if (isset($metadata['admin'])) {
154  if ($metadata['admin']) {
155  $user->makeAdmin();
156  } else {
157  $user->removeAdmin();
158  }
159  }
160 
161  if (isset($metadata['banned'])) {
162  if ($metadata['banned']) {
163  $user->ban('Banned by seeder');
164  } else {
165  $user->unban();
166  }
167  }
168 
169  if (!isset($metadata['validated'])) {
170  $metadata['validated'] = $this->faker()->boolean(80);
171  }
172  $user->setValidationStatus((bool) $metadata['validated'], 'seeder');
173 
174  if (!$user->isValidated()) {
175  $user->disable('seeder invalidation');
176  }
177 
178  unset($metadata['username']);
179  unset($metadata['password']);
180  unset($metadata['name']);
181  unset($metadata['email']);
182  unset($metadata['banned']);
183  unset($metadata['admin']);
184  unset($metadata['validated']);
185 
186  $user->setNotificationSetting('email', false);
187  $user->setNotificationSetting('site', true);
188 
189  $profile_fields = elgg_extract('profile_fields', $options, []);
190  /* @var $user \ElggUser */
191  $user = $this->populateMetadata($user, $profile_fields, $metadata);
192 
193  $user->save();
194 
195  $this->log("Created new user {$user->getDisplayName()} [guid: {$user->guid}]");
196 
197  return $user;
198  } catch (RegistrationException $e) {
199  if ($user && $user->guid) {
200  $user->delete();
201  }
202 
203  $attr_log = print_r($attributes, true);
204  $this->log("User creation failed with message {$e->getMessage()} [attributes: $attr_log]");
205 
206  return false;
207  }
208  };
209 
210  return elgg_call(ELGG_IGNORE_ACCESS | ELGG_SHOW_DISABLED_ENTITIES, function() use ($create) {
211  $user = false;
212  $attempts = 0;
213  while (!$user instanceof \ElggUser && $attempts < $this->MAX_ATTEMPTS) {
214  $attempts++;
215 
216  try {
217  $user = $create();
218  } catch (\Exception $ex) {
219  // try again
220  }
221  }
222 
223  if (!$user instanceof \ElggUser) {
224  throw new MaxAttemptsException("Unable to create a user after {$attempts} seeding attempts");
225  }
226 
227  return $user;
228  });
229  }
230 
241  public function createGroup(array $attributes = [], array $metadata = [], array $options = []): \ElggGroup {
242 
243  $create = function () use ($attributes, $metadata, $options) {
244 
245  $properties = array_merge($metadata, $attributes);
246 
247  $properties['__faker'] = true;
248 
249  if (!isset($properties['time_created'])) {
250  $properties['time_created'] = $this->getRandomCreationTimestamp();
251  }
252 
253  if (!isset($properties['access_id'])) {
254  $properties['access_id'] = ACCESS_PUBLIC;
255  }
256 
257  if (!isset($properties['content_access_mode'])) {
258  $properties['content_access_mode'] = \ElggGroup::CONTENT_ACCESS_MODE_UNRESTRICTED;
259  }
260 
261  if (!isset($properties['membership'])) {
262  $properties['membership'] = ACCESS_PUBLIC;
263  }
264 
265  if (empty($properties['name'])) {
266  $properties['name'] = $this->faker()->sentence();
267  }
268 
269  if (empty($properties['description'])) {
270  $properties['description'] = $this->faker()->text($this->faker()->numberBetween(500, 1000));
271  }
272 
273  if (!isset($properties['owner_guid'])) {
274  $user = _elgg_services()->session->getLoggedInUser();
275  if (!$user) {
276  $user = $this->getRandomUser();
277  }
278 
279  if (!$user) {
280  return false;
281  }
282 
283  $properties['owner_guid'] = $user->guid;
284  }
285 
286  if (!elgg_entity_exists($properties['owner_guid'])) {
287  return false;
288  }
289 
290  if (!isset($properties['container_guid'])) {
291  $properties['container_guid'] = $properties['owner_guid'];
292  }
293 
294  if (!elgg_entity_exists($properties['container_guid'])) {
295  return false;
296  }
297 
298  if (empty($properties['subtype'])) {
299  $properties['subtype'] = 'group';
300  }
301 
302  $tool_options = elgg_extract('group_tool_options', $options, []);
303  /* @var $tool_options Collection|Tool[] */
304 
305  foreach ($tool_options as $group_option) {
306  $prop_name = $group_option->mapMetadataName();
307  $prop_value = $group_option->mapMetadataValue();
308  $properties[$prop_name] = $prop_value;
309  }
310 
311  if ($this->faker()->boolean(20)) {
312  $properties['featured_group'] = 'yes';
313  }
314 
315  $group = new \ElggGroup();
316  foreach ($properties as $name => $value) {
317  switch ($name) {
318  case 'type':
319  break;
320  case 'subtype':
321  $group->setSubtype($value);
322  break;
323  default:
324  $group->$name = $value;
325  break;
326  }
327  }
328 
329  $profile_fields = elgg_extract('profile_fields', $options, []);
330  $group = $this->populateMetadata($group, $profile_fields, $properties);
331 
332  if (!$group->save()) {
333  return false;
334  }
335 
336  if ($group->access_id === ACCESS_PRIVATE) {
337  $acl = $group->getOwnedAccessCollection('group_acl');
338  if ($acl instanceof \ElggAccessCollection) {
339  $group->access_id = $acl->id;
340  $group->save();
341  }
342  }
343 
344  $group->join(get_entity($properties['owner_guid']));
345 
347  'view' => 'river/group/create',
348  'action_type' => 'create',
349  'subject_guid' => $properties['owner_guid'],
350  'object_guid' => $group->guid,
351  'target_guid' => $properties['container_guid'],
352  'posted' => $group->time_created,
353  ]);
354 
355  $this->log("Created new group {$group->getDisplayName()} [guid: {$group->guid}]");
356 
357  return $group;
358  };
359 
360  return elgg_call(ELGG_IGNORE_ACCESS, function() use ($create) {
361  $group = false;
362  $attempts = 0;
363  while (!$group instanceof \ElggGroup && $attempts < $this->MAX_ATTEMPTS) {
364  $attempts++;
365 
366  $group = $create();
367  }
368 
369  if (!$group instanceof \ElggGroup) {
370  throw new MaxAttemptsException("Unable to create a group after {$attempts} seeding attempts");
371  }
372 
373  return $group;
374  });
375  }
376 
387  public function createObject(array $attributes = [], array $metadata = [], array $options = []): \ElggObject {
388 
389  $create = function () use ($attributes, $metadata, $options) {
390 
391  $properties = array_merge($metadata, $attributes);
392 
393  $properties['__faker'] = true;
394 
395  if (!isset($properties['time_created'])) {
396  $properties['time_created'] = $this->getRandomCreationTimestamp();
397  }
398 
399  if (empty($properties['title'])) {
400  $properties['title'] = $this->faker()->sentence();
401  }
402 
403  if (empty($properties['description'])) {
404  $properties['description'] = $this->faker()->text($this->faker()->numberBetween(500, 1000));
405  }
406 
407  if (empty($properties['subtype'])) {
408  $properties['subtype'] = $this->getRandomSubtype();
409  }
410 
411  if (empty($properties['tags'])) {
412  $properties['tags'] = $this->faker()->words(10);
413  }
414 
415  if (!isset($properties['owner_guid'])) {
416  $user = _elgg_services()->session->getLoggedInUser();
417  if (!$user) {
418  $user = $this->getRandomUser();
419  }
420 
421  if (!$user) {
422  return false;
423  }
424 
425  $properties['owner_guid'] = $user->guid;
426  }
427 
428  if (!elgg_entity_exists($properties['owner_guid'])) {
429  return false;
430  }
431 
432  if (!isset($properties['container_guid'])) {
433  $properties['container_guid'] = $properties['owner_guid'];
434  }
435 
436  if (!elgg_entity_exists($properties['container_guid'])) {
437  return false;
438  }
439 
440  if (!isset($properties['access_id'])) {
441  $properties['access_id'] = ACCESS_PUBLIC;
442  }
443 
444  $class = elgg_get_entity_class('object', $properties['subtype']);
445  if ($class && class_exists($class)) {
446  $object = new $class();
447  } else {
448  $object = new \ElggObject();
449  }
450 
451  foreach ($properties as $name => $value) {
452  switch ($name) {
453  case 'type':
454  break;
455  case 'subtype':
456  $object->setSubtype($value);
457  break;
458  default:
459  $object->$name = $value;
460  break;
461  }
462  }
463 
464  $profile_fields = elgg_extract('profile_fields', $options, []);
465  $object = $this->populateMetadata($object, $profile_fields, $properties);
466 
467  if (elgg_extract('save', $options, true)) {
468  if (!$object->save()) {
469  return false;
470  }
471  }
472 
473  $type_str = elgg_echo("item:object:{$object->getSubtype()}");
474 
475  $this->log("Created new item in {$type_str} {$object->getDisplayName()} [guid: {$object->guid}]");
476 
477  return $object;
478  };
479 
480  return elgg_call(ELGG_IGNORE_ACCESS, function() use ($create) {
481  $object = false;
482  $attempts = 0;
483  while (!$object instanceof \ElggObject && $attempts < $this->MAX_ATTEMPTS) {
484  $attempts++;
485 
486  $object = $create();
487  }
488 
489  if (!$object instanceof \ElggObject) {
490  throw new MaxAttemptsException("Unable to create an object after {$attempts} seeding attempts");
491  }
492 
493  return $object;
494  });
495  }
496 
505  public function createSite(array $attributes = [], array $metadata = []): \ElggSite {
506  // We don't want to create more than one site
507  return elgg_get_site_entity();
508  }
509 
518  public function getRandomUser(array $exclude = [], bool $allow_create = true) {
519 
520  $exclude[] = 0;
521 
522  // make sure the random user isn't disabled
523  $users = elgg_call(ELGG_HIDE_DISABLED_ENTITIES, function() use ($exclude) {
524  return elgg_get_entities([
525  'types' => 'user',
526  'metadata_names' => ['__faker'],
527  'limit' => 1,
528  'wheres' => [
529  function(QueryBuilder $qb, $main_alias) use ($exclude) {
530  return $qb->compare("{$main_alias}.guid", 'NOT IN', $exclude, ELGG_VALUE_INTEGER);
531  }
532  ],
533  'order_by' => new OrderByClause('RAND()', null),
534  ]);
535  });
536 
537  if (!empty($users)) {
538  return $users[0];
539  }
540 
541  if ($allow_create) {
542  $profile_fields_config = _elgg_services()->fields->get('user', 'user');
543  $profile_fields = [];
544  foreach ($profile_fields_config as $field) {
545  $profile_fields[$field['name']] = $field['#type'];
546  }
547  return $this->createUser([], [
548  'validated' => true,
549  ], [
550  'profile_fields' => $profile_fields,
551  ]);
552  }
553 
554  return false;
555  }
556 
565  public function getRandomGroup(array $exclude = [], bool $allow_create = true) {
566 
567  $exclude[] = 0;
568 
569  $groups = elgg_get_entities([
570  'types' => 'group',
571  'metadata_names' => ['__faker'],
572  'limit' => 1,
573  'wheres' => [
574  function(QueryBuilder $qb, $main_alias) use ($exclude) {
575  return $qb->compare("{$main_alias}.guid", 'NOT IN', $exclude, ELGG_VALUE_INTEGER);
576  }
577  ],
578  'order_by' => new OrderByClause('RAND()', null),
579  ]);
580 
581  if (!empty($groups)) {
582  return $groups[0];
583  }
584 
585  if ($allow_create) {
586  $profile_fields_config = _elgg_services()->fields->get('group', 'group');
587  $profile_fields = [];
588  foreach ($profile_fields_config as $field) {
589  $profile_fields[$field['name']] = $field['#type'];
590  }
591 
592  return $this->createGroup([
593  'access_id' => $this->getRandomGroupVisibility(),
594  ], [
595  'content_access_mode' => $this->getRandomGroupContentAccessMode(),
596  'membership' => $this->getRandomGroupMembership(),
597  ], [
598  'profile_fields' => $profile_fields,
599  'group_tool_options' => _elgg_services()->group_tools->all(),
600  ]);
601  }
602 
603  return false;
604  }
605 
614  public function getRandomAccessId(\ElggUser $user = null, \ElggEntity $container = null) {
615 
616  $params = [
617  'container_guid' => $container ? $container->guid : null,
618  ];
619 
620  $access_array = elgg_get_write_access_array($user->guid, false, $params);
621 
622  return array_rand($access_array, 1);
623  }
624 
632  public function getRandomUsername($name = null) {
633 
634  $make = function($name = null) {
635  if (!$name) {
636  return elgg_strtolower($this->faker()->firstName . '.' . $this->faker()->lastName);
637  }
638 
639  return implode('.', preg_split('/\W/', $name));
640  };
641 
642  $validate = function($username) {
643  try {
644  _elgg_services()->accounts->assertValidUsername($username, true);
645  return true;
646  } catch (RegistrationException $e) {
647  return false;
648  }
649  };
650 
651  $username = $make($name);
652  while (!$validate($username)) {
653  $username = $make();
654  }
655 
656  return $username;
657  }
658 
666  public function getRandomEmail($base = null) {
667 
668  $make = function($base = null) {
669  $base = $this->getRandomUsername($base);
670  return $base . '@' . $this->getEmailDomain();
671  };
672 
673  $validate = function($email) {
674  try {
675  _elgg_services()->accounts->assertValidEmail($email, true);
676  return true;
677  } catch (RegistrationException $e) {
678  return false;
679  }
680  };
681 
682  $email = $make($base);
683  while (!$validate($email)) {
684  $email = $make();
685  }
686 
687  return $email;
688  }
689 
699  public function populateMetadata(\ElggEntity $entity, array $fields = [], array $metadata = []): \ElggEntity {
700 
701  foreach ($fields as $name => $type) {
702  if (isset($metadata[$name])) {
703  continue;
704  }
705 
706  switch ($name) {
707  case 'phone' :
708  case 'mobile' :
709  $metadata[$name] = $this->faker()->phoneNumber;
710  break;
711 
712  default :
713  switch ($type) {
714  case 'plaintext' :
715  case 'longtext' :
716  $metadata[$name] = $this->faker()->text($this->faker()->numberBetween(500, 1000));
717  break;
718 
719  case 'text' :
720  $metadata[$name] = $this->faker()->sentence;
721  break;
722 
723  case 'tags' :
724  $metadata[$name] = $this->faker()->words(10);
725  break;
726 
727  case 'url' :
728  $metadata[$name] = $this->faker()->url;
729  break;
730 
731  case 'email' :
732  $metadata[$name] = $this->faker()->email;
733  break;
734 
735  case 'number' :
736  $metadata[$name] = $this->faker()->randomNumber();
737  break;
738 
739  case 'date' :
740  $metadata[$name] = $this->faker()->unixTime;
741  break;
742 
743  case 'password' :
745  break;
746 
747  case 'location' :
748  $metadata[$name] = $this->faker()->address;
749  $metadata['geo:lat'] = $this->faker()->latitude;
750  $metadata['geo:long'] = $this->faker()->longitude;
751  break;
752 
753  default :
754  $metadata[$name] = '';
755  break;
756  }
757 
758  break;
759  }
760  }
761 
762  foreach ($metadata as $key => $value) {
763  if (array_key_exists($key, $fields) && $entity instanceof \ElggUser) {
764  $entity->setProfileData($key, $value, $this->getRandomAccessId($entity));
765  } else {
766  $entity->$key = $value;
767  }
768  }
769 
770  return $entity;
771  }
772 
780  public function createIcon(\ElggEntity $entity): bool {
781 
782  $icon_location = $this->faker()->image();
783  if (empty($icon_location)) {
784  return false;
785  }
786 
787  $result = $entity->saveIconFromLocalFile($icon_location);
788 
789  if ($result && $entity instanceof \ElggUser) {
790  $since = $this->create_since;
791  $this->setCreateSince($entity->time_created);
792 
794  'view' => 'river/user/default/profileiconupdate',
795  'action_type' => 'update',
796  'subject_guid' => $entity->guid,
797  'object_guid' => $entity->guid,
798  'posted' => $this->getRandomCreationTimestamp(),
799  ]);
800 
801  $this->create_since = $since;
802  }
803 
804  return $result;
805  }
806 
815  public function createComments(\ElggEntity $entity, $limit = null): int {
816 
817  return elgg_call(ELGG_IGNORE_ACCESS, function() use ($entity, $limit) {
818  $tries = 0;
819  $success = 0;
820 
821  if ($limit === null) {
822  $limit = $this->faker()->numberBetween(1, 20);
823  }
824 
825  $since = $this->create_since;
826  $this->setCreateSince($entity->time_created);
827 
828  while ($tries < $limit) {
829  $comment = new \ElggComment();
830  $comment->owner_guid = $this->getRandomUser()->guid ? : $entity->owner_guid;
831  $comment->container_guid = $entity->guid;
832  $comment->description = $this->faker()->paragraph;
833  $comment->time_created = $this->getRandomCreationTimestamp();
834 
835  $tries++;
836  if ($comment->save()) {
837  $success++;
838  }
839  }
840 
841  $this->create_since = $since;
842 
843  return $success;
844  });
845  }
846 
855  public function createLikes(\ElggEntity $entity, $limit = null): int {
856 
857  return elgg_call(ELGG_IGNORE_ACCESS, function() use ($entity, $limit) {
858  $success = 0;
859 
860  if ($limit === null) {
861  $limit = $this->faker()->numberBetween(1, 20);
862  }
863 
864  while ($success < $limit) {
865  if ($entity->annotate('likes', true, $entity->access_id, $this->getRandomUser()->guid)) {
866  $success++;
867  }
868  }
869 
870  return $success;
871  });
872  }
873 
883  public function log($msg, $level = LogLevel::NOTICE): void {
884  elgg_log($msg, $level);
885  }
886 }
elgg_call(int $flags, Closure $closure)
Calls a callable autowiring the arguments using public DI services and applying logic based on flags...
Definition: elgglib.php:592
Provide images from a local folder for seeding.
Definition: LocalImage.php:10
getRandomGroupVisibility()
Returns random visibility value.
$params
Saves global plugin settings.
Definition: save.php:13
get_user($guid)
Get a user object from a GUID.
Definition: users.php:20
Thrown when the seeding has exceeded the max attempts for trying to create an .
if(!$entity) if(!$entity->canComment()) $comment
Definition: save.php:42
Elgg registration action.
if(empty($user_guids)) $users
Definition: ban.php:12
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
elgg_generate_password()
Generate a random 12 character clear text password.
Definition: users.php:91
getRandomGroupContentAccessMode()
Returns random content access mode value.
getRandomUsername($name=null)
Generates a unique available and valid username.
Definition: Seeding.php:632
getRandomSubtype()
Returns random unique subtype.
Definition: Seeding.php:92
const ELGG_VALUE_INTEGER
Value types.
Definition: constants.php:126
elgg_register_user(array $params=[])
Registers a user.
Definition: users.php:111
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
Definition: LICENSE.txt:215
trait TimeHelpers
Trait to add time helpers.
Definition: TimeHelpers.php:13
createUser(array $attributes=[], array $metadata=[], array $options=[])
Create a new fake user.
Definition: Seeding.php:107
getRandomCreationTimestamp()
Get a random timestamp between a lower and upper time.
Definition: TimeHelpers.php:54
$email
Definition: change_email.php:7
createLikes(\ElggEntity $entity, $limit=null)
Create likes.
Definition: Seeding.php:855
Database abstraction query builder.
$username
Definition: delete.php:23
elgg_entity_exists($guid)
Does an entity exist?
Definition: entities.php:89
$type
Definition: delete.php:21
Could not register a new user for whatever reason.
if($pagination &&($position== 'after'||$position== 'both')) $limit
Definition: list.php:108
elgg_create_river_item(array $options=[])
Elgg river.
Definition: river.php:27
elgg_strtolower()
Wrapper function for mb_strtolower().
Definition: mb_wrapper.php:154
elgg_echo($message_key, array $args=[], $language="")
Elgg language module Functions to manage language and translations.
Definition: languages.php:18
$options
Elgg admin footer.
Definition: footer.php:6
$value
Definition: generic.php:51
$class
Definition: summary.php:44
elgg_get_write_access_array(int $user_guid=0, bool $flush=false, array $input_params=[])
Returns an array of access permissions that the user is allowed to save content with.
Definition: access.php:129
getDomain()
Get site domain.
Definition: Seeding.php:63
const ELGG_HIDE_DISABLED_ENTITIES
Definition: constants.php:149
const ELGG_IGNORE_ACCESS
elgg_call() flags
Definition: constants.php:146
if(!$entity instanceof\ElggUser) $fields
Definition: profile.php:14
const ACCESS_PRIVATE
Definition: constants.php:12
trait GroupHelpers
Group helpers for seeding.
$entity
Definition: reset.php:8
const ELGG_SHOW_DISABLED_ENTITIES
Definition: constants.php:148
elgg_get_entities(array $options=[])
Fetches/counts entities or performs a calculation on their properties.
Definition: entities.php:545
const CONTENT_ACCESS_MODE_UNRESTRICTED
Definition: ElggGroup.php:15
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.
Definition: elgglib.php:399
elgg_get_entity_class($type, $subtype)
Return the class name registered as a constructor for an entity of a given type and subtype...
Definition: entities.php:20
getRandomUser(array $exclude=[], bool $allow_create=true)
Returns random fake user.
Definition: Seeding.php:518
$user
Definition: ban.php:7
compare($x, $comparison, $y=null, $type=null, $case_sensitive=null)
Build value comparison clause.
$container
Definition: delete.php:23
createComments(\ElggEntity $entity, $limit=null)
Create comments/replies.
Definition: Seeding.php:815
elgg_get_site_entity()
Get the current site entity.
Definition: entities.php:99
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:547
if(elgg_extract('required', $vars)) if(elgg_extract('disabled', $vars)) $field
Definition: field.php:37
createIcon(\ElggEntity $entity)
Create an icon for an entity.
Definition: Seeding.php:780
Extends QueryBuilder with ORDER BY clauses.
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
Definition: summary.php:44
log($level, $message, array $context=[])
Log a message.
Definition: Loggable.php:58
if($email instanceof\Elgg\Email) $object
Definition: body.php:24
getRandomEmail($base=null)
Generate a random valid email.
Definition: Seeding.php:666
setCreateSince($since= 'now')
Set a time for entities to be created after.
Definition: TimeHelpers.php:33
$metadata
Output annotation metadata.
Definition: metadata.php:9
$domain
Definition: layout.php:32
createSite(array $attributes=[], array $metadata=[])
Create a new fake site.
Definition: Seeding.php:505
annotate($name, $value, $access_id=ACCESS_PRIVATE, $owner_guid=0, $value_type="")
Adds an annotation to an entity.
Definition: ElggEntity.php:909
_elgg_services()
Get the global service provider.
Definition: elgglib.php:638
const ACCESS_PUBLIC
Definition: constants.php:14
faker($locale= 'en_US')
Returns an instance of faker.
Definition: Seeding.php:48
getRandomAccessId(\ElggUser $user=null,\ElggEntity $container=null)
Get random access id.
Definition: Seeding.php:614
$qb
Definition: queue.php:11
$attributes
Elgg AJAX loader.
Definition: ajax_loader.php:10
getRandomGroupMembership()
Returns random membership mode.
getEmailDomain()
Get valid domain for emails.
Definition: Seeding.php:72
createObject(array $attributes=[], array $metadata=[], array $options=[])
Create a new fake object.
Definition: Seeding.php:387
getRandomGroup(array $exclude=[], bool $allow_create=true)
Returns random fake group.
Definition: Seeding.php:565
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:69
createGroup(array $attributes=[], array $metadata=[], array $options=[])
Create a new fake group.
Definition: Seeding.php:241
saveIconFromLocalFile($filename, $type= 'icon', array $coords=[])
Saves icons using a local file as the source.
populateMetadata(\ElggEntity $entity, array $fields=[], array $metadata=[])
Set random metadata.
Definition: Seeding.php:699