Elgg  Version 4.x
Namespaces | Functions | Variables
Elgg\Traits Namespace Reference

Namespaces

 Cli
 
 Database
 
 Debug
 
 Di
 
 Entity
 
 Notifications
 
 Seeding
 

Functions

 setCache (ElggCache $cache)
 Set cache. More...
 
 getCache ()
 Get cache. More...
 
 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 ($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 $attributes=[], array $metadata=[], array $options=[])
 Create a new fake user. More...
 
 createGroup (array $attributes=[], array $metadata=[], array $options=[])
 Create a new fake group. More...
 
 createObject (array $attributes=[], array $metadata=[], array $options=[])
 Create a new fake object. More...
 
 createSite (array $attributes=[], array $metadata=[])
 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...
 

Variables

trait Cacheable
 Utility trait for injecting cache. More...
 
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 809 of file Seeding.php.

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

Create a new fake group.

Parameters
array$attributesGroup entity attributes
array$metadataGroup entity metadata
array$optionsAdditional options
Returns
Exceptions
MaxAttemptsException

Definition at line 235 of file Seeding.php.

Elgg\Traits\createIcon ( \ElggEntity  $entity)

Create an icon for an entity.

Parameters
\ElggEntity$entityEntity
Returns
bool

Definition at line 774 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 849 of file Seeding.php.

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

Create a new fake object.

Parameters
array$attributesObject entity attributes
array$metadataObject entity metadata
array$optionsAdditional options
Returns
Exceptions
MaxAttemptsException

Definition at line 381 of file Seeding.php.

Elgg\Traits\createSite ( array  $attributes = [],
array  $metadata = [] 
)

Create a new fake site.

Parameters
array$attributesObject entity attributes
array$metadataObject entity metadata
Returns

Definition at line 499 of file Seeding.php.

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

Create a new fake user.

Parameters
array$attributesUser entity attributes
array$metadataUser entity metadata
array$optionsSeeding options
Returns
Exceptions
MaxAttemptsException

Definition at line 105 of file Seeding.php.

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

Returns an instance of faker.

Parameters
string$localeLocale
Returns

Definition at line 47 of file Seeding.php.

Elgg\Traits\getCache ( )

Get cache.

Returns
ElggCache

Definition at line 36 of file Cacheable.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 62 of file Seeding.php.

Elgg\Traits\getEmailDomain ( )

Get valid domain for emails.

Returns
string

Definition at line 71 of file Seeding.php.

Elgg\Traits\getLogger ( )

Returns logger.

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

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 608 of file Seeding.php.

Elgg\Traits\getRandomEmail (   $base = null)

Generate a random valid email.

Parameters
string$baseEmail username part
Returns
string

Definition at line 660 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 559 of file Seeding.php.

Elgg\Traits\getRandomSubtype ( )

Returns random unique subtype.

Returns
bool|string

Definition at line 91 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 512 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 626 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 877 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 80 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 693 of file Seeding.php.

Elgg\Traits\setCache ( ElggCache  $cache)

Set cache.

Parameters
ElggCache$cacheCache
Returns
void

Definition at line 27 of file Cacheable.php.

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

Set the current time.

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

Definition at line 41 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 38 of file Seeding.php.

Elgg::Traits\$MAX_ATTEMPTS = 10
protected

Definition at line 33 of file Seeding.php.

trait Elgg::Traits\Cacheable
Initial value:
{
protected $cache

Utility trait for injecting cache.

Definition at line 13 of file Cacheable.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 23 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.