Elgg  Version master
Functions | Variables
Seeding.php File Reference

Go to the source code of this file.

Functions

 Elgg\Traits::faker (string $locale='en_US')
 Returns an instance of faker. More...
 
 Elgg\Traits::getDomain ()
 Get site domain. More...
 
 Elgg\Traits::getEmailDomain ()
 Get valid domain for emails. More...
 
 Elgg\Traits::getRandomSubtype ()
 Returns random unique subtype. More...
 
 Elgg\Traits::createUser (array $properties=[], array $options=[])
 Create a new fake user. More...
 
 Elgg\Traits::createGroup (array $properties=[], array $options=[])
 Create a new fake group. More...
 
 Elgg\Traits::createObject (array $properties=[], array $options=[])
 Create a new fake object. More...
 
 Elgg\Traits::createSite (array $properties=[])
 Create a new fake site. More...
 
 Elgg\Traits::getRandomUser (array $exclude=[], bool $allow_create=true)
 Returns random fake user. More...
 
 Elgg\Traits::getRandomGroup (array $exclude=[], bool $allow_create=true)
 Returns random fake group. More...
 
 Elgg\Traits::getRandomAccessId (?\ElggUser $user=null, ?\ElggEntity $container=null)
 Get random access id. More...
 
 Elgg\Traits::getRandomUsername ($name=null)
 Generates a unique available and valid username. More...
 
 Elgg\Traits::getRandomEmail ($base=null)
 Generate a random valid email. More...
 
 Elgg\Traits::populateMetadata (\ElggEntity $entity, array $fields=[], array $metadata=[])
 Set random metadata. More...
 
 Elgg\Traits::createIcon (\ElggEntity $entity)
 Create an icon for an entity. More...
 
 Elgg\Traits::createComments (\ElggEntity $entity, $limit=null)
 Create comments/replies. More...
 
 Elgg\Traits::createLikes (\ElggEntity $entity, $limit=null)
 Create likes. More...
 
 Elgg\Traits::log ($msg, $level=LogLevel::NOTICE)
 Log a message. More...
 

Variables

trait Elgg\Traits::Seeding
 Seeding trait Can be used to easily create new random users, groups and objects in the database. More...
 
 Elgg\Traits::$MAX_ATTEMPTS = 10
 
 Elgg\Traits::$faker
 

Function Documentation

◆ createComments()

Elgg\Traits\createComments ( \ElggEntity  $entity,
  $limit = null 
)

Create comments/replies.

Parameters
\ElggEntity$entityEntity to comment on
int$limitNumber of comments to create
Returns
int Number of generated comments

Definition at line 814 of file Seeding.php.

◆ createGroup()

Elgg\Traits\createGroup ( array  $properties = [],
array  $options = [] 
)

Create a new fake group.

Parameters
array$propertiesEntity attributes/metadata
array$optionsAdditional options
Returns
\ElggGroup
Exceptions
MaxAttemptsException

Definition at line 240 of file Seeding.php.

◆ createIcon()

Elgg\Traits\createIcon ( \ElggEntity  $entity)

Create an icon for an entity.

Parameters
\ElggEntity$entityEntity
Returns
bool

Definition at line 779 of file Seeding.php.

◆ createLikes()

Elgg\Traits\createLikes ( \ElggEntity  $entity,
  $limit = null 
)

Create likes.

Parameters
\ElggEntity$entityEntity to like
int$limitNumber of likes to create
Returns
int

Definition at line 859 of file Seeding.php.

◆ createObject()

Elgg\Traits\createObject ( array  $properties = [],
array  $options = [] 
)

Create a new fake object.

Parameters
array$propertiesEntity attributes/metadata
array$optionsAdditional options
Returns
\ElggObject
Exceptions
MaxAttemptsException

Definition at line 382 of file Seeding.php.

◆ createSite()

Elgg\Traits\createSite ( array  $properties = [])

Create a new fake site.

Parameters
array$propertiesEntity attributes/metadata
Returns
\ElggSite

Definition at line 508 of file Seeding.php.

◆ createUser()

Elgg\Traits\createUser ( array  $properties = [],
array  $options = [] 
)

Create a new fake user.

Parameters
array$propertiesEntity attributes/metadata
array$optionsSeeding options
Returns
\ElggUser
Exceptions
MaxAttemptsException

Definition at line 105 of file Seeding.php.

◆ faker()

Elgg\Traits\faker ( string  $locale = 'en_US')

Returns an instance of faker.

Parameters
string$localeLocale
Returns
\Faker\Generator

Definition at line 48 of file Seeding.php.

◆ getDomain()

Elgg\Traits\getDomain ( )

Get site domain.

Returns
string

Definition at line 63 of file Seeding.php.

◆ getEmailDomain()

Elgg\Traits\getEmailDomain ( )

Get valid domain for emails.

Returns
string

Definition at line 72 of file Seeding.php.

◆ getRandomAccessId()

Elgg\Traits\getRandomAccessId ( ?\ElggUser  $user = null,
?\ElggEntity  $container = null 
)

Get random access id.

Parameters
null | \ElggUser$userUser
null | \ElggEntity$containerContainer
Returns
int

Definition at line 617 of file Seeding.php.

◆ getRandomEmail()

Elgg\Traits\getRandomEmail (   $base = null)

Generate a random valid email.

Parameters
string$baseEmail username part
Returns
string

Definition at line 666 of file Seeding.php.

◆ getRandomGroup()

Elgg\Traits\getRandomGroup ( array  $exclude = [],
bool  $allow_create = true 
)

Returns random fake group.

Parameters
int[]$excludeGUIDs to exclude
bool$allow_createIf no existing random group could be found create a new group (default: true)
Returns
\ElggGroup|false

Definition at line 569 of file Seeding.php.

◆ getRandomSubtype()

Elgg\Traits\getRandomSubtype ( )

Returns random unique subtype.

Returns
bool|string

Definition at line 92 of file Seeding.php.

◆ getRandomUser()

Elgg\Traits\getRandomUser ( array  $exclude = [],
bool  $allow_create = true 
)

Returns random fake user.

Parameters
int[]$excludeGUIDs to exclude
bool$allow_createIf no existing random user could be found create a new user (default: true)
Returns
\ElggUser|false

Definition at line 521 of file Seeding.php.

◆ getRandomUsername()

Elgg\Traits\getRandomUsername (   $name = null)

Generates a unique available and valid username.

Parameters
string$nameDisplay name or other prefix to use as basis
Returns
string

Definition at line 632 of file Seeding.php.

◆ log()

Elgg\Traits\log (   $msg,
  $level = LogLevel::NOTICE 
)

Log a message.

Parameters
string$msgMessage to log
string$levelMessage level
Returns
void

Definition at line 890 of file Seeding.php.

◆ populateMetadata()

Elgg\Traits\populateMetadata ( \ElggEntity  $entity,
array  $fields = [],
array  $metadata = [] 
)

Set random metadata.

Parameters
\ElggEntity$entityEntity
array$fieldsAn array of profile fields in $name => $input_type format
array$metadataOther metadata $name => $value pairs to set
Returns
\ElggEntity

Definition at line 699 of file Seeding.php.

Variable Documentation

◆ $faker

Elgg::Traits\$faker
protected

Definition at line 39 of file Seeding.php.

◆ $MAX_ATTEMPTS

Elgg::Traits\$MAX_ATTEMPTS = 10
protected

Definition at line 34 of file Seeding.php.

◆ Seeding

trait Elgg::Traits\Seeding
Initial value:
{
trait GroupHelpers
Group helpers for seeding.

Seeding trait Can be used to easily create new random users, groups and objects in the database.

Definition at line 24 of file Seeding.php.