Elgg  Version 6.1
Functions | Variables
Elgg\Traits\Entity Namespace Reference

Functions

 deleteAnnotations (string $name=null)
 Deletes all annotations on this object (annotations.entity_guid = $this->guid). More...
 
 deleteOwnedAnnotations (string $name=null)
 Deletes all annotations owned by this object (annotations.owner_guid = $this->guid). More...
 
 annotate ($name, $value, $access_id=ACCESS_PRIVATE, $owner_guid=0, $value_type= '')
 Adds an annotation to an entity. More...
 
 getAnnotations (array $options=[])
 Gets an array of annotations. More...
 
 countAnnotations (string $name= '')
 Count annotations. More...
 
 getAnnotationsAvg (string $name)
 Get the average of an integer type annotation. More...
 
 getAnnotationsSum (string $name)
 Get the sum of integer type annotations of a given name. More...
 
 getAnnotationsMin (string $name)
 Get the minimum of integer type annotations of given name. More...
 
 getAnnotationsMax (string $name)
 Get the maximum of integer type annotations of a given name. More...
 
 getMetadata (string $name)
 Return the value of a piece of metadata. More...
 
 getAllMetadata ()
 Get all entity metadata. More...
 
 setMetadata (string $name, mixed $value, string $value_type= '', bool $multiple=false)
 Set metadata on this entity. More...
 
 setTempMetadata (string $name, mixed $value, bool $multiple=false)
 Set temp metadata on this entity. More...
 
 deleteMetadata (string $name=null)
 Deletes all metadata on this object (metadata.entity_guid = $this->guid). More...
 
 setProfileData (string $profile_field_name, $value, int $access_id=ACCESS_PRIVATE)
 Store profile data. More...
 
 getProfileData (string $profile_field_name)
 Get profile data. More...
 
 getAllProfileAnnotations ()
 Returns all profile annotations. More...
 
 deleteProfileData (string $profile_field_name)
 Remove profile data. More...
 

Variables

trait Annotations
 Bundle all annotations related functions for an . More...
 
trait Metadata
 Bundle all metadata related functions for an . More...
 
trait ProfileData
 Adds methods to save profile data to an ElggEntity. More...
 

Function Documentation

Elgg\Traits\Entity\annotate (   $name,
  $value,
  $access_id = ACCESS_PRIVATE,
  $owner_guid = 0,
  $value_type = '' 
)

Adds an annotation to an entity.

Warning
By default, annotations are private.
Annotating an unsaved entity more than once with the same name will only save the last annotation.
Parameters
string$nameAnnotation name
mixed$valueAnnotation value
int$access_idAccess ID
int$owner_guidGUID of the annotation owner
string$value_typeThe type of annotation value
Returns
bool|int Returns int if an annotation is saved

Definition at line 106 of file Annotations.php.

Elgg\Traits\Entity\countAnnotations ( string  $name = '')

Count annotations.

Parameters
string$nameThe type of annotation.
Returns
int

Definition at line 168 of file Annotations.php.

Elgg\Traits\Entity\deleteAnnotations ( string  $name = null)

Deletes all annotations on this object (annotations.entity_guid = $this->guid).

If you pass a name, only annotations matching that name will be deleted.

Warning
Calling this with no or empty arguments will clear all annotations on the entity.
Parameters
string | null$nameAn optional name of annotations to remove.
Returns
bool
Since
1.8

Definition at line 31 of file Annotations.php.

Elgg\Traits\Entity\deleteMetadata ( string  $name = null)

Deletes all metadata on this object (metadata.entity_guid = $this->guid).

If you pass a name, only metadata matching that name will be deleted.

Warning
Calling this with no $name will clear all metadata on the entity.
Parameters
null | string$nameThe name of the metadata to remove.
Returns
bool
Since
1.8

Definition at line 198 of file Metadata.php.

Elgg\Traits\Entity\deleteOwnedAnnotations ( string  $name = null)

Deletes all annotations owned by this object (annotations.owner_guid = $this->guid).

If you pass a name, only annotations matching that name will be deleted.

Parameters
string | null$nameAn optional name of annotations to delete.
Returns
bool
Since
1.8

Definition at line 58 of file Annotations.php.

Elgg\Traits\Entity\deleteProfileData ( string  $profile_field_name)

Remove profile data.

Parameters
string$profile_field_namethe profile field name to remove
Returns
bool

Definition at line 134 of file ProfileData.php.

Elgg\Traits\Entity\getAllMetadata ( )

Get all entity metadata.

Returns
array

Definition at line 37 of file Metadata.php.

Elgg\Traits\Entity\getAllProfileAnnotations ( )
protected

Returns all profile annotations.

Returns
array

Definition at line 101 of file ProfileData.php.

Elgg\Traits\Entity\getAnnotations ( array  $options = [])

Gets an array of annotations.

To retrieve annotations on an unsaved entity, pass array('name' => [annotation name]) as the options array.

Parameters
array$optionsArray of options for elgg_get_annotations() except guid.
Returns
[]|mixed
See also
elgg_get_annotations()

Definition at line 145 of file Annotations.php.

Elgg\Traits\Entity\getAnnotationsAvg ( string  $name)

Get the average of an integer type annotation.

Parameters
string$nameAnnotation name
Returns
int

Definition at line 179 of file Annotations.php.

Elgg\Traits\Entity\getAnnotationsMax ( string  $name)

Get the maximum of integer type annotations of a given name.

Parameters
string$nameAnnotation name
Returns
int

Definition at line 212 of file Annotations.php.

Elgg\Traits\Entity\getAnnotationsMin ( string  $name)

Get the minimum of integer type annotations of given name.

Parameters
string$nameAnnotation name
Returns
int

Definition at line 201 of file Annotations.php.

Elgg\Traits\Entity\getAnnotationsSum ( string  $name)

Get the sum of integer type annotations of a given name.

Parameters
string$nameAnnotation name
Returns
int

Definition at line 190 of file Annotations.php.

Elgg\Traits\Entity\getMetadata ( string  $name)

Return the value of a piece of metadata.

Parameters
string$nameName
Returns
mixed The value, or null if not found.

Definition at line 27 of file Metadata.php.

Elgg\Traits\Entity\getProfileData ( string  $profile_field_name)

Get profile data.

Parameters
string$profile_field_nameprofile field name
Returns
null|mixed null if no profile data was found

Definition at line 58 of file ProfileData.php.

Elgg\Traits\Entity\setMetadata ( string  $name,
mixed  $value,
string  $value_type = '',
bool  $multiple = false 
)

Set metadata on this entity.

Plugin developers usually want to use the magic set method ($entity->name = 'value'). Use this method if you want to explicitly set the owner or access of the metadata. You cannot set the owner/access before the entity has been saved.

Parameters
string$nameName of the metadata
mixed$valueValue of the metadata (doesn't support assoc arrays)
string$value_type'text', 'integer', or '' for automatic detection
bool$multipleAllow multiple values for a single name. Does not support associative arrays.
Returns
bool

Definition at line 78 of file Metadata.php.

Elgg\Traits\Entity\setProfileData ( string  $profile_field_name,
  $value,
int  $access_id = ACCESS_PRIVATE 
)

Store profile data.

Parameters
string$profile_field_nameprofile field name
mixed$valueprofile data
int$access_idaccess of the profile data
Returns
void

Definition at line 27 of file ProfileData.php.

Elgg\Traits\Entity\setTempMetadata ( string  $name,
mixed  $value,
bool  $multiple = false 
)
protected

Set temp metadata on this entity.

Parameters
string$nameName of the metadata
mixed$valueValue of the metadata (doesn't support assoc arrays)
bool$multipleAllow multiple values for a single name. Does not support associative arrays.
Returns
bool

Definition at line 166 of file Metadata.php.

Variable Documentation

trait Elgg::Traits::Entity\Annotations
Initial value:
{
protected array $temp_annotations = []

Bundle all annotations related functions for an .

Since
6.1

Definition at line 10 of file Annotations.php.

trait Elgg::Traits::Entity\Metadata
Initial value:
{
protected array $temp_metadata = []

Bundle all metadata related functions for an .

Since
6.1

Definition at line 10 of file Metadata.php.

trait Elgg::Traits::Entity\ProfileData
Initial value:
{
protected $_profile_data = []

Adds methods to save profile data to an ElggEntity.

Data is stored in Annotations (and Metadata for BC reasons)

Since
3.1

Definition at line 11 of file ProfileData.php.