Elgg  Version master
Namespaces | Functions | Variables
Elgg\Traits Namespace Reference

Namespaces

 Cli
 
 Database
 
 Debug
 
 Di
 
 Entity
 
 Notifications
 
 Seeding
 

Functions

 setLogger (LoggerInterface $logger=null)
 Set (or remove) the logger. More...
 
 getLogger ()
 Returns logger. More...
 
 log ($level, $message, array $context=[])
 Log a message. More...
 
 logDeprecatedMessage (string $message, string $version)
 Sends a message about deprecated use of a function, view, etc. More...
 
 faker (string $locale= 'en_US')
 Returns an instance of faker. More...
 
 getDomain ()
 Get site domain. More...
 
 getEmailDomain ()
 Get valid domain for emails. More...
 
 getRandomSubtype ()
 Returns random unique subtype. More...
 
 createUser (array $properties=[], array $options=[])
 Create a new fake user. More...
 
 createGroup (array $properties=[], array $options=[])
 Create a new fake group. More...
 
 createObject (array $properties=[], array $options=[])
 Create a new fake object. More...
 
 createSite (array $properties=[])
 Create a new fake site. More...
 
 getRandomUser (array $exclude=[], bool $allow_create=true)
 Returns random fake user. More...
 
 getRandomGroup (array $exclude=[], bool $allow_create=true)
 Returns random fake group. More...
 
 getRandomAccessId (\ElggUser $user=null,\ElggEntity $container=null)
 Get random access id. More...
 
 getRandomUsername ($name=null)
 Generates a unique available and valid username. More...
 
 getRandomEmail ($base=null)
 Generate a random valid email. More...
 
 populateMetadata (\ElggEntity $entity, array $fields=[], array $metadata=[])
 Set random metadata. More...
 
 createIcon (\ElggEntity $entity)
 Create an icon for an entity. More...
 
 createComments (\ElggEntity $entity, $limit=null)
 Create comments/replies. More...
 
 createLikes (\ElggEntity $entity, $limit=null)
 Create likes. More...
 
 log ($msg, $level=LogLevel::NOTICE)
 Log a message. More...
 
 getCurrentTime ($modifier= '')
 Get the (cloned) time. More...
 
 setCurrentTime (\DateTime $time=null)
 Set the current time. More...
 
 resetCurrentTime ()
 Reset the current time Use after the time has been set with setCurrentTime and it no longer needs to be locked. More...
 

Variables

trait Loggable
 Enables adding a logger. More...
 
trait Seeding
 Seeding trait Can be used to easily create new random users, groups and objects in the database. More...
 
 $MAX_ATTEMPTS = 10
 
 $faker
 
trait TimeUsing
 Adds methods for setting the current time (for testing) More...
 

Function Documentation

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.

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

Create a new fake group.

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

Definition at line 240 of file Seeding.php.

Elgg\Traits\createIcon ( \ElggEntity  $entity)

Create an icon for an entity.

Parameters
\ElggEntity$entityEntity
Returns
bool

Definition at line 779 of file Seeding.php.

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.

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

Create a new fake object.

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

Definition at line 382 of file Seeding.php.

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

Create a new fake site.

Parameters
array$propertiesEntity attributes/metadata
Returns

Definition at line 508 of file Seeding.php.

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

Create a new fake user.

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

Definition at line 105 of file Seeding.php.

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

Returns an instance of faker.

Parameters
string$localeLocale
Returns

Definition at line 48 of file Seeding.php.

Elgg\Traits\getCurrentTime (   $modifier = '')

Get the (cloned) time.

If setCurrentTime() has not been set, this will return a new DateTime().

Parameters
string$modifierTime modifier
Returns
See also
modify

Definition at line 25 of file TimeUsing.php.

Elgg\Traits\getDomain ( )

Get site domain.

Returns
string

Definition at line 63 of file Seeding.php.

Elgg\Traits\getEmailDomain ( )

Get valid domain for emails.

Returns
string

Definition at line 72 of file Seeding.php.

Elgg\Traits\getLogger ( )

Returns logger.

Returns
LoggerInterface

Definition at line 37 of file Loggable.php.

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

Get random access id.

Parameters
\ElggUser$userUser
\ElggEntity$containerContainer
Returns
int

Definition at line 617 of file Seeding.php.

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.

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

Returns random fake group.

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

Definition at line 569 of file Seeding.php.

Elgg\Traits\getRandomSubtype ( )

Returns random unique subtype.

Returns
bool|string

Definition at line 92 of file Seeding.php.

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

Returns random fake user.

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

Definition at line 521 of file Seeding.php.

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.

Elgg\Traits\log (   $level,
  $message,
array  $context = [] 
)

Log a message.

Parameters
string$levelSeverity
mixed$messageMessage
array$contextContext
Returns
bool
Examples:
/root/Elgg/engine/lib/output.php.

Definition at line 58 of file Loggable.php.

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

Log a message.

Parameters
string$msgMessage to log
string$levelMessage level Note that 'ERROR' will terminate further code execution
Returns
void

Definition at line 891 of file Seeding.php.

Elgg\Traits\logDeprecatedMessage ( string  $message,
string  $version 
)

Sends a message about deprecated use of a function, view, etc.

Parameters
string$messageMessage to log
string$versionHuman-readable release version: 1.7, 1.8, ...
Returns
void

Definition at line 76 of file Loggable.php.

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

Definition at line 699 of file Seeding.php.

Elgg\Traits\resetCurrentTime ( )

Reset the current time Use after the time has been set with setCurrentTime and it no longer needs to be locked.

Returns
void
Since
4.3

Definition at line 54 of file TimeUsing.php.

Elgg\Traits\setCurrentTime ( \DateTime  $time = null)

Set the current time.

Parameters
\DateTime$timeCurrent time (empty for now)
Returns
void

Definition at line 42 of file TimeUsing.php.

Elgg\Traits\setLogger ( LoggerInterface  $logger = null)

Set (or remove) the logger.

Parameters
LoggerInterface$loggerLogger or null
Returns
void

Definition at line 28 of file Loggable.php.

Variable Documentation

Elgg::Traits\$faker
protected

Definition at line 39 of file Seeding.php.

Elgg::Traits\$MAX_ATTEMPTS = 10
protected

Definition at line 34 of file Seeding.php.

trait Elgg::Traits\Loggable
Initial value:
{
private $logger

Enables adding a logger.

Users should not assume $this->logger is set: use Loggable::getLogger()

Examples:
/root/Elgg/engine/classes/Elgg/FormsService.php.

Definition at line 14 of file Loggable.php.

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.

trait Elgg::Traits\TimeUsing
Initial value:
{
private $time
if(!$annotation instanceof ElggAnnotation) $time
Definition: time.php:20

Adds methods for setting the current time (for testing)

Definition at line 10 of file TimeUsing.php.