Elgg  Version 6.0
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
ElggEntity Class Reference
Inheritance diagram for ElggEntity:
ElggData Elgg\Collections\CollectionItemInterface ElggGroup ElggObject ElggSite ElggUser ElggAdminNotice ElggComment ElggFile ElggPlugin ElggUpgrade ElggWidget ElggIcon ElggTempFile

Public Member Functions

 __construct (stdClass $row=null)
 Create a new entity. More...
 
 __clone ()
 Clone an entity. More...
 
 __set ($name, $value)
 Set an attribute or metadata value for this entity. More...
 
 getOriginalAttributes ()
 Get the original values of attribute(s) that have been modified since the entity was persisted. More...
 
 __get ($name)
 Get an attribute or metadata value. More...
 
 getDisplayName ()
 Get the entity's display name. More...
 
 setDisplayName (string $display_name)
 Sets the title or name of this entity. More...
 
 getMetadata (string $name)
 Return the value of a piece of metadata. More...
 
 getAllMetadata ()
 Get all entity metadata. More...
 
 setMetadata (string $name, $value, string $value_type= '', bool $multiple=false)
 Set metadata on this entity. More...
 
 deleteMetadata (string $name=null)
 Deletes all metadata on this object (metadata.entity_guid = $this->guid). More...
 
 getVolatileData (string $name)
 Get a piece of volatile (non-persisted) data on this entity. More...
 
 setVolatileData (string $name, $value)
 Set a piece of volatile (non-persisted) data on this entity. More...
 
 addRelationship (int $guid_two, string $relationship)
 Add a relationship between this and another entity. More...
 
 hasRelationship (int $guid_two, string $relationship)
 Check if this entity has a relationship with another entity. More...
 
 getRelationship (int $guid_two, string $relationship)
 Return the relationship if this entity has a relationship with another entity. More...
 
 getEntitiesFromRelationship (array $options=[])
 Gets an array of entities with a relationship to this entity. More...
 
 countEntitiesFromRelationship (string $relationship, bool $inverse_relationship=false)
 Gets the number of entities from a specific relationship type. More...
 
 removeRelationship (int $guid_two, string $relationship)
 Remove a relationship. More...
 
 removeAllRelationships (string $relationship= '', bool $inverse_relationship=false)
 Remove all relationships to or from this entity. More...
 
 removeAllRelatedRiverItems ()
 Removes all river items related to this entity. More...
 
 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...
 
 countComments ()
 Count the number of comments attached to this entity. More...
 
 getOwnedAccessCollections (array $options=[])
 Returns the ACLs owned by the entity. More...
 
 getOwnedAccessCollection (string $subtype)
 Returns the first ACL owned by the entity with a given subtype. More...
 
 hasAccess (int $user_guid=0)
 Check if the given user has access to this entity. More...
 
 canEdit (int $user_guid=0)
 Can a user edit this entity? More...
 
 canDelete (int $user_guid=0)
 Can a user delete this entity? More...
 
 canWriteToContainer (int $user_guid=0, string $type= '', string $subtype= '')
 Can a user add an entity to this container. More...
 
 canComment (int $user_guid=0)
 Can a user comment on an entity? More...
 
 canAnnotate (int $user_guid=0, string $annotation_name= '')
 Can a user annotate an entity? More...
 
 getGUID ()
 Returns the guid. More...
 
 getType ()
 Returns the entity type. More...
 
 setSubtype (string $subtype)
 Set the subtype of the entity. More...
 
 getSubtype ()
 Get the entity subtype. More...
 
 getOwnerGUID ()
 Get the guid of the entity's owner. More...
 
 getOwnerEntity ()
 Gets the that owns this entity. More...
 
 setContainerGUID (int $container_guid)
 Set the container for this object. More...
 
 getContainerGUID ()
 Gets the container GUID for this entity. More...
 
 getContainerEntity ()
 Get the container entity for this object. More...
 
 getTimeUpdated ()
 Returns the UNIX epoch time that this entity was last updated. More...
 
 getURL ()
 Gets the URL for this entity. More...
 
 save ()
 
 disable (string $reason= '', bool $recursive=true)
 Disable this entity. More...
 
 enable (bool $recursive=true)
 Enable the entity. More...
 
 isEnabled ()
 Is this entity enabled? More...
 
 delete (bool $recursive=true, bool $persistent=null)
 Deletes the entity. More...
 
 restore (bool $recursive=true)
 Restore the entity. More...
 
 isDeleted ()
 Is the entity marked as deleted. More...
 
 toObject (array $params=[])
 Export an entity. More...
 
 setLatLong (float $lat, float $long)
 Set latitude and longitude metadata tags for a given entity. More...
 
 getLatitude ()
 Return the entity's latitude. More...
 
 getLongitude ()
 Return the entity's longitude. More...
 
 getSystemLogID ()
 {} More...
 
 getObjectFromID (int $id)
 For a given ID, return the object associated with it. More...
 
 deleteAccessCollectionMemberships ()
 Remove the membership of all access collections for this entity (if the entity is a user) More...
 
 deleteOwnedAccessCollections ()
 Remove all access collections owned by this entity. More...
 
 updateLastAction (int $posted=null)
 Update the last_action column in the entities table. More...
 
 updateTimeDeleted (int $deleted=null)
 Update the time_deleted column in the entities table. More...
 
 disableCaching ()
 Disable runtime caching for entity. More...
 
 enableCaching ()
 Enable runtime caching for entity. More...
 
 isCacheable ()
 Is entity cacheable in the runtime cache. More...
 
 cache ()
 Cache the entity in a session cache. More...
 
 invalidateCache ()
 Invalidate cache for entity. More...
 
 hasCapability (string $capability)
 Checks a specific capability is enabled for the entity type/subtype. More...
 
- Public Member Functions inherited from ElggData
 __isset ($name)
 Test if property is set either as an attribute or metadata. More...
 
 __unset ($name)
 Unset a property from metadata or attribute. More...
 
 getURL ()
 Get a URL for this object. More...
 
 save ()
 Save this data to the appropriate database table. More...
 
 delete ()
 Delete this data. More...
 
 getTimeCreated ()
 Returns the UNIX epoch time that this entity was created. More...
 
 toObject (array $params=[])
 Get a plain old object copy for public consumption. More...
 
 getSystemLogID ()
 Return an identification for the object for storage in the system log. More...
 
 getType ()
 Return the type of the object - eg. More...
 
 getSubtype ()
 Return a subtype. More...
 
 getObjectFromID (int $id)
 For a given ID, return the object associated with it. More...
 
 rewind ()
 Iterator interface. More...
 
 current ()
 Iterator interface. More...
 
 key ()
 Iterator interface. More...
 
 next ()
 Iterator interface. More...
 
 valid ()
 Iterator interface. More...
 
 offsetSet ($offset, $value)
 Array access interface. More...
 
 offsetGet ($offset)
 Array access interface. More...
 
 offsetUnset ($offset)
 Array access interface. More...
 
 offsetExists ($offset)
 Array access interface. More...
 
 getID ()
 {Get unique item identifier within a collection.
Returns
string|int
} More...
 
 getPriority ()
 {Get priority (weight) of the item within a collection.
Returns
int
} More...
 
 __serialize ()
 Called during serialization. More...
 
 __unserialize (array $data)
 Called during unserialization. More...
 

Public Attributes

const PRIMARY_ATTR_NAMES
 

Protected Member Functions

 initializeAttributes ()
 Initialize the attributes array. More...
 
 setTempMetadata (string $name, $value, bool $multiple=false)
 Set temp metadata on this entity. More...
 
 create ()
 Create a new entry in the entities table. More...
 
 update ()
 Update the entity in the database. More...
 
 load (stdClass $row)
 Loads attributes from the entities table into the object. More...
 
 persistentDelete (bool $recursive=true)
 Permanently delete the entity from the database. More...
 
 trash (bool $recursive=true)
 Move the entity to the trash. More...
 
 prepareObject (\Elgg\Export\Entity $object)
 Prepare an object copy for toObject() More...
 
- Protected Member Functions inherited from ElggData
 initializeAttributes ()
 Initialize the attributes array. More...
 
 getDatabase ()
 Provides a pointer to the database object. More...
 

Protected Attributes

const INTEGER_ATTR_NAMES
 
 $temp_metadata = []
 
 $temp_annotations = []
 
 $volatile = []
 
 $orig_attributes = []
 
 $_is_cacheable = true
 
 $_cached_metadata
 
- Protected Attributes inherited from ElggData
 $attributes = []
 
 $valid = false
 

Detailed Description

Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 48 of file ElggEntity.php.

Constructor & Destructor Documentation

ElggEntity::__construct ( stdClass  $row = null)

Create a new entity.

Plugin developers should only use the constructor to create a new entity. To retrieve entities, use get_entity() and the elgg_get_entities* functions.

If no arguments are passed, it creates a new entity. If a database result is passed as a instance, it instantiates that entity.

Parameters
stdClass$rowDatabase row result. Default is null to create a new object.
Exceptions
IOExceptionIf cannot load remaining data from db

Definition at line 140 of file ElggEntity.php.

Member Function Documentation

ElggEntity::__clone ( )

Clone an entity.

Resets the guid so that the entity can be saved as a distinct entity from the original. Creation time will be set when this new entity is saved. The owner and container guids come from the original entity. The clone method copies metadata but does not copy annotations.

Returns
void

Definition at line 183 of file ElggEntity.php.

ElggEntity::__get (   $name)

Get an attribute or metadata value.

If the name matches an attribute, the attribute is returned. If metadata does not exist with that name, a null is returned.

This only returns an array if there are multiple values for a particular $name key.

Parameters
string$nameName of the attribute or metadata
Returns
mixed

Definition at line 311 of file ElggEntity.php.

ElggEntity::__set (   $name,
  $value 
)

Set an attribute or metadata value for this entity.

Anything that is not an attribute is saved as metadata.

Be advised that metadata values are cast to integer or string. You can save booleans, but they will be stored and returned as integers.

Parameters
string$nameName of the attribute or metadata
mixed$valueThe value to be set
Returns
void
Exceptions

Definition at line 236 of file ElggEntity.php.

ElggEntity::addRelationship ( int  $guid_two,
string  $relationship 
)

Add a relationship between this and another entity.

Read the relationship like "This entity is a $relationship of $guid_two."

Parameters
int$guid_twoGUID of the target entity of the relationship
string$relationshipThe type of relationship
Returns
bool
Exceptions

Definition at line 552 of file ElggEntity.php.

ElggEntity::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 743 of file ElggEntity.php.

ElggEntity::cache ( )

Cache the entity in a session cache.

Returns
void

Definition at line 1907 of file ElggEntity.php.

ElggEntity::canAnnotate ( int  $user_guid = 0,
string  $annotation_name = '' 
)

Can a user annotate an entity?

Can be overridden by registering for the event [permissions_check:annotate:<name>, <entity type>="">] or [permissions_check:annotate, <entity type>="">]. The events are called in that order.

If you want logged out users to annotate an object, do not call canAnnotate(). It's easier than using the event.

Parameters
int$user_guidUser guid (default is logged in user)
string$annotation_nameThe name of the annotation (default is unspecified)
Returns
bool

Definition at line 995 of file ElggEntity.php.

ElggEntity::canComment ( int  $user_guid = 0)

Can a user comment on an entity?

Can be overridden by registering for the 'permissions_check:comment', '<entity type>="">' event.

Parameters
int$user_guidUser guid (default is logged in user)
Returns
bool

Definition at line 977 of file ElggEntity.php.

ElggEntity::canDelete ( int  $user_guid = 0)

Can a user delete this entity?

Can be overridden by registering for the permissions_check:delete event.

Parameters
int$user_guidThe user GUID, optionally (default: logged in user)
Returns
bool Whether this entity is deletable by the given user.
Since
1.11

Definition at line 946 of file ElggEntity.php.

ElggEntity::canEdit ( int  $user_guid = 0)

Can a user edit this entity?

Can be overridden by registering for the permissions_check event.

Parameters
int$user_guidThe user GUID, optionally (default: logged in user)
Returns
bool Whether this entity is editable by the given user.

Definition at line 932 of file ElggEntity.php.

ElggEntity::canWriteToContainer ( int  $user_guid = 0,
string  $type = '',
string  $subtype = '' 
)

Can a user add an entity to this container.

Parameters
int$user_guidThe GUID of the user creating the entity (0 for logged in user).
string$typeThe type of entity we're looking to write
string$subtypeThe subtype of the entity we're looking to write
Returns
bool
Exceptions

Definition at line 960 of file ElggEntity.php.

ElggEntity::countAnnotations ( string  $name = '')

Count annotations.

Parameters
string$nameThe type of annotation.
Returns
int

Definition at line 805 of file ElggEntity.php.

ElggEntity::countComments ( )

Count the number of comments attached to this entity.

Returns
int Number of comments
Since
1.8.0

Definition at line 859 of file ElggEntity.php.

ElggEntity::countEntitiesFromRelationship ( string  $relationship,
bool  $inverse_relationship = false 
)

Gets the number of entities from a specific relationship type.

Parameters
string$relationshipRelationship type (eg "friends")
bool$inverse_relationshipInvert relationship
Returns
int

Definition at line 607 of file ElggEntity.php.

ElggEntity::create ( )
protected

Create a new entry in the entities table.

Saves the base information in the entities table for the entity. Saving the type-specific information is handled in the calling class method.

Returns
int|false The new entity's GUID or false if prevented by an event handler
Exceptions

Definition at line 1150 of file ElggEntity.php.

ElggEntity::delete ( bool  $recursive = true,
bool  $persistent = null 
)

Deletes the entity.

Removes the entity and its metadata, annotations, relationships, river entries, and private data.

Optionally can remove entities contained and owned by this entity.

Warning
If deleting recursively, this bypasses ownership of items contained by the entity. That means that if the container_guid = $this->guid, the item will be deleted regardless of who owns it.
Parameters
bool$recursiveIf true (default) then all entities which are owned or contained by $this will also be deleted.
bool | null$persistentpersistently delete the entity (default: check the 'restorable' capability)
Returns
bool

Definition at line 1557 of file ElggEntity.php.

ElggEntity::deleteAccessCollectionMemberships ( )

Remove the membership of all access collections for this entity (if the entity is a user)

Returns
bool
Since
1.11

Definition at line 1773 of file ElggEntity.php.

ElggEntity::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$nameAn optional name of annotations to remove.
Returns
bool
Since
1.8

Definition at line 666 of file ElggEntity.php.

ElggEntity::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 496 of file ElggEntity.php.

ElggEntity::deleteOwnedAccessCollections ( )

Remove all access collections owned by this entity.

Returns
bool
Since
1.11

Definition at line 1804 of file ElggEntity.php.

ElggEntity::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$nameAn optional name of annotations to delete.
Returns
bool
Since
1.8

Definition at line 693 of file ElggEntity.php.

ElggEntity::disable ( string  $reason = '',
bool  $recursive = true 
)

Disable this entity.

Disabled entities are not returned by getter functions. To enable an entity, use ElggEntity::enable().Recursivelydisablinganentitywilldisableallentitiesownedorcontainedbytheparententity.@noteInternal:Disablinganentitysetsthe'enabled'columnto'no'.@paramstring$reasonOptionalreason@parambool$recursiveRecursivelydisableallcontainedentities?@returnbool@see\ElggEntity::enable()

Definition at line 1404 of file ElggEntity.php.

ElggEntity::disableCaching ( )

Disable runtime caching for entity.

Returns
void

Definition at line 1866 of file ElggEntity.php.

ElggEntity::enable ( bool  $recursive = true)

Enable the entity.

Parameters
bool$recursiveRecursively enable all entities disabled with the entity?
Returns
bool

Definition at line 1486 of file ElggEntity.php.

ElggEntity::enableCaching ( )

Enable runtime caching for entity.

Returns
void

Definition at line 1879 of file ElggEntity.php.

ElggEntity::getAllMetadata ( )

Get all entity metadata.

Returns
array

Definition at line 356 of file ElggEntity.php.

ElggEntity::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 782 of file ElggEntity.php.

ElggEntity::getAnnotationsAvg ( string  $name)

Get the average of an integer type annotation.

Parameters
string$nameAnnotation name
Returns
int

Definition at line 816 of file ElggEntity.php.

ElggEntity::getAnnotationsMax ( string  $name)

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

Parameters
string$nameAnnotation name
Returns
int

Definition at line 849 of file ElggEntity.php.

ElggEntity::getAnnotationsMin ( string  $name)

Get the minimum of integer type annotations of given name.

Parameters
string$nameAnnotation name
Returns
int

Definition at line 838 of file ElggEntity.php.

ElggEntity::getAnnotationsSum ( string  $name)

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

Parameters
string$nameAnnotation name
Returns
int

Definition at line 827 of file ElggEntity.php.

ElggEntity::getContainerEntity ( )

Get the container entity for this object.

Returns
|null
Since
1.8.0

Definition at line 1088 of file ElggEntity.php.

ElggEntity::getContainerGUID ( )

Gets the container GUID for this entity.

Returns
int

Definition at line 1078 of file ElggEntity.php.

ElggEntity::getDisplayName ( )

Get the entity's display name.

Returns
string The title or name of this entity.
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 324 of file ElggEntity.php.

ElggEntity::getEntitiesFromRelationship ( array  $options = [])

Gets an array of entities with a relationship to this entity.

Parameters
array$optionsOptions array. See elgg_get_entities() for a list of options. 'relationship_guid' is set to this entity
Returns
[]|int|mixed
See also
elgg_get_entities()

Definition at line 594 of file ElggEntity.php.

ElggEntity::getGUID ( )

Returns the guid.

Returns
int|null GUID

Definition at line 1004 of file ElggEntity.php.

ElggEntity::getLatitude ( )

Return the entity's latitude.

Returns
float

Definition at line 1731 of file ElggEntity.php.

ElggEntity::getLongitude ( )

Return the entity's longitude.

Returns
float

Definition at line 1740 of file ElggEntity.php.

ElggEntity::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 346 of file ElggEntity.php.

ElggEntity::getObjectFromID ( int  $id)

For a given ID, return the object associated with it.

This is used by the system log. It can be called on any Loggable object.

Parameters
int$idGUID
Returns
|null

Definition at line 1763 of file ElggEntity.php.

ElggEntity::getOriginalAttributes ( )

Get the original values of attribute(s) that have been modified since the entity was persisted.

Returns
array

Definition at line 294 of file ElggEntity.php.

ElggEntity::getOwnedAccessCollection ( string  $subtype)

Returns the first ACL owned by the entity with a given subtype.

Parameters
string$subtypesubtype of the ACL
Returns
|null
Exceptions

Definition at line 899 of file ElggEntity.php.

ElggEntity::getOwnedAccessCollections ( array  $options = [])

Returns the ACLs owned by the entity.

Parameters
array$optionsadditional options to get the access collections with
Returns
[]
See also
elgg_get_access_collections()
Since
3.0

Definition at line 884 of file ElggEntity.php.

ElggEntity::getOwnerEntity ( )

Gets the that owns this entity.

Returns
|null

Definition at line 1058 of file ElggEntity.php.

ElggEntity::getOwnerGUID ( )

Get the guid of the entity's owner.

Returns
int The owner GUID

Definition at line 1049 of file ElggEntity.php.

ElggEntity::getRelationship ( int  $guid_two,
string  $relationship 
)

Return the relationship if this entity has a relationship with another entity.

Parameters
int$guid_twoGUID of the target entity of the relationship
string$relationshipThe type of relationship
Returns
|null
Since
4.3

Definition at line 580 of file ElggEntity.php.

ElggEntity::getSubtype ( )

Get the entity subtype.

Returns
string The entity subtype
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1040 of file ElggEntity.php.

ElggEntity::getSystemLogID ( )

{}

Definition at line 1751 of file ElggEntity.php.

ElggEntity::getTimeUpdated ( )

Returns the UNIX epoch time that this entity was last updated.

Returns
int UNIX epoch time

Definition at line 1097 of file ElggEntity.php.

ElggEntity::getType ( )

Returns the entity type.

Returns
string The entity type
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1013 of file ElggEntity.php.

ElggEntity::getURL ( )

Gets the URL for this entity.

Plugins can register for the 'entity:url', '<type>' event to customize the url for an entity.

Returns
string The URL of the entity
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1109 of file ElggEntity.php.

ElggEntity::getVolatileData ( string  $name)

Get a piece of volatile (non-persisted) data on this entity.

Parameters
string$nameThe name of the volatile data
Returns
mixed The value or null if not found.

Definition at line 525 of file ElggEntity.php.

ElggEntity::hasAccess ( int  $user_guid = 0)

Check if the given user has access to this entity.

Parameters
int$user_guidthe GUID of the user to check access for (default: logged in user_guid)
Returns
bool
Since
4.3

Definition at line 919 of file ElggEntity.php.

ElggEntity::hasCapability ( string  $capability)

Checks a specific capability is enabled for the entity type/subtype.

Parameters
string$capabilitycapability to check
Returns
bool
Since
4.1
Examples:
/root/Elgg/engine/lib/views.php.

Definition at line 1938 of file ElggEntity.php.

ElggEntity::hasRelationship ( int  $guid_two,
string  $relationship 
)

Check if this entity has a relationship with another entity.

Read the relationship like "This entity is a $relationship of $guid_two."

Parameters
int$guid_twoGUID of the target entity of the relationship
string$relationshipThe type of relationship
Returns
bool
Since
4.3

Definition at line 567 of file ElggEntity.php.

ElggEntity::initializeAttributes ( )
protected

Initialize the attributes array.

This is vital to distinguish between metadata and base parameters.

Returns
void

Definition at line 155 of file ElggEntity.php.

ElggEntity::invalidateCache ( )

Invalidate cache for entity.

Returns
void

Definition at line 1921 of file ElggEntity.php.

ElggEntity::isCacheable ( )

Is entity cacheable in the runtime cache.

Returns
bool

Definition at line 1889 of file ElggEntity.php.

ElggEntity::isDeleted ( )

Is the entity marked as deleted.

Returns
bool

Definition at line 1674 of file ElggEntity.php.

ElggEntity::isEnabled ( )

Is this entity enabled?

Returns
boolean Whether this entity is enabled.

Definition at line 1536 of file ElggEntity.php.

ElggEntity::load ( stdClass  $row)
protected

Loads attributes from the entities table into the object.

Parameters
stdClass$rowObject of properties from database row(s)
Returns
bool

Definition at line 1360 of file ElggEntity.php.

ElggEntity::persistentDelete ( bool  $recursive = true)
protected

Permanently delete the entity from the database.

Parameters
bool$recursiveIf true (default) then all entities which are owned or contained by $this will also be deleted.
Returns
bool
Since
6.0

Definition at line 1590 of file ElggEntity.php.

ElggEntity::prepareObject ( \Elgg\Export\Entity  $object)
protected

Prepare an object copy for toObject()

Parameters
\Elgg\Export\Entity$objectObject representation of the entity
Returns

Definition at line 1700 of file ElggEntity.php.

ElggEntity::removeAllRelatedRiverItems ( )

Removes all river items related to this entity.

Returns
void

Definition at line 649 of file ElggEntity.php.

ElggEntity::removeAllRelationships ( string  $relationship = '',
bool  $inverse_relationship = false 
)

Remove all relationships to or from this entity.

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

Warning
Calling this with no $relationship will clear all relationships with this entity.
Parameters
string | null$relationship(optional) The name of the relationship to remove
bool$inverse_relationship(optional) Inverse the relationship
Returns
bool
Since
4.3

Definition at line 640 of file ElggEntity.php.

ElggEntity::removeRelationship ( int  $guid_two,
string  $relationship 
)

Remove a relationship.

Parameters
int$guid_twoGUID of the target entity of the relationship
string$relationshipThe type of relationship
Returns
bool

Definition at line 623 of file ElggEntity.php.

ElggEntity::restore ( bool  $recursive = true)

Restore the entity.

Parameters
bool$recursiveRecursively restores all entities trashed with the entity?
Returns
bool
Since
6.0

Definition at line 1619 of file ElggEntity.php.

ElggEntity::save ( )

Definition at line 1124 of file ElggEntity.php.

ElggEntity::setContainerGUID ( int  $container_guid)

Set the container for this object.

Parameters
int$container_guidThe ID of the container.
Returns
void

Definition at line 1069 of file ElggEntity.php.

ElggEntity::setDisplayName ( string  $display_name)

Sets the title or name of this entity.

Parameters
string$display_nameThe title or name of this entity.
Returns
void

Definition at line 335 of file ElggEntity.php.

ElggEntity::setLatLong ( float  $lat,
float  $long 
)

Set latitude and longitude metadata tags for a given entity.

Parameters
float$latLatitude
float$longLongitude
Returns
void

Definition at line 1721 of file ElggEntity.php.

ElggEntity::setMetadata ( string  $name,
  $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 383 of file ElggEntity.php.

ElggEntity::setSubtype ( string  $subtype)

Set the subtype of the entity.

Parameters
string$subtypethe new type
Returns
void
See also
self::initializeAttributes()

Definition at line 1026 of file ElggEntity.php.

ElggEntity::setTempMetadata ( string  $name,
  $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 464 of file ElggEntity.php.

ElggEntity::setVolatileData ( string  $name,
  $value 
)

Set a piece of volatile (non-persisted) data on this entity.

Parameters
string$nameName
mixed$valueValue
Returns
void

Definition at line 537 of file ElggEntity.php.

ElggEntity::toObject ( array  $params = [])

Export an entity.

Parameters
array$paramsParams to pass to the event
Returns

Definition at line 1685 of file ElggEntity.php.

ElggEntity::trash ( bool  $recursive = true)
protected

Move the entity to the trash.

Parameters
bool$recursiveIf true (default) then all entities which are owned or contained by $this will also be trashed.
Returns
bool
Since
6.0

Definition at line 1602 of file ElggEntity.php.

ElggEntity::update ( )
protected

Update the entity in the database.

Returns
bool Whether the update was successful.
Exceptions

Definition at line 1295 of file ElggEntity.php.

ElggEntity::updateLastAction ( int  $posted = null)

Update the last_action column in the entities table.

Warning
This is different to time_updated. Time_updated is automatically set, while last_action is only set when explicitly called.
Parameters
int$postedTimestamp of last action
Returns
int

Definition at line 1834 of file ElggEntity.php.

ElggEntity::updateTimeDeleted ( int  $deleted = null)

Update the time_deleted column in the entities table.

Parameters
int$deletedTimestamp of deletion
Returns
int

Definition at line 1851 of file ElggEntity.php.

Member Data Documentation

ElggEntity::$_cached_metadata
protected

Definition at line 124 of file ElggEntity.php.

ElggEntity::$_is_cacheable = true
protected

Definition at line 112 of file ElggEntity.php.

ElggEntity::$orig_attributes = []
protected

Definition at line 107 of file ElggEntity.php.

ElggEntity::$temp_annotations = []
protected

Definition at line 94 of file ElggEntity.php.

ElggEntity::$temp_metadata = []
protected

Definition at line 87 of file ElggEntity.php.

ElggEntity::$volatile = []
protected

Definition at line 101 of file ElggEntity.php.

const ElggEntity::INTEGER_ATTR_NAMES
protected
Initial value:
= [
'guid',
'owner_guid',
'container_guid',
'access_id',
'time_created',
'time_updated',
'last_action',
'time_deleted',
]

Definition at line 71 of file ElggEntity.php.

const ElggEntity::PRIMARY_ATTR_NAMES
Initial value:
= [
'guid',
'type',
'subtype',
'owner_guid',
'container_guid',
'access_id',
'time_created',
'time_updated',
'last_action',
'enabled',
'deleted',
'time_deleted',
]

Definition at line 53 of file ElggEntity.php.


The documentation for this class was generated from the following file: