Methods summary
protected
|
#
initializeAttributes( )
Initialize the attributes array.
Initialize the attributes array.
This is vital to distinguish between metadata and base parameters.
Overrides
|
public
|
#
__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 or private settings.
Note
metadata will have its owner and access id set when the entity is saved and it
will be the same as that of the entity.
|
public
mixed
|
#
get( string $name )
Return the value of a property.
Return the value of a property.
If $name is defined in $this->attributes that value is returned, otherwise
it will pull from the entity's metadata.
Q: Why are we not using __get overload here? A: Because overload operators
cause problems during subclassing, so we put the code here and create overloads
in subclasses.
Parameters
Returns
mixed Returns the value of a given value, or null.
Warning
Subtype is returned as an id rather than the subtype string. Use getSubtype() to
get the subtype string.
|
public
boolean
|
#
set( string $name, mixed $value )
Sets the value of a property.
Sets the value of a property.
If $name is defined in $this->attributes that value is set, otherwise it
is saved as metadata.
Parameters
- $name
string $name Name
- $value
mixed $value Value
Returns
boolean
Warning
Metadata set this way will inherit the entity's owner and access ID. If you want
to set metadata with a different owner, use create_metadata().
It is important that your class populates $this->attributes with keys for all
base attributes, anything not in their gets set as METADATA. Q: Why are we not
using __set overload here? A: Because overload operators cause problems during
subclassing, so we put the code here and create overloads in subclasses.
|
public
mixed
|
#
getMetaData( string $name )
Return the value of a piece of metadata.
Return the value of a piece of metadata.
Parameters
Returns
mixed The value, or NULL if not found.
|
public
|
#
__unset( string $name )
Unset a property from metadata or attribute.
Unset a property from metadata or attribute.
Parameters
- $name
string $name The name of the attribute or metadata.
Warning
If you use this to unset an attribute, you must save the object!
|
public
boolean
|
#
setMetaData( string $name, mixed $value, string $value_type = null, boolean $multiple = false )
Set a piece of metadata.
Plugin authors should use the magic methods or create_metadata().
Parameters
- $name
string $name Name of the metadata
- $value
mixed $value Value of the metadata (doesn't support assoc arrays)
- $value_type
string $value_type Types supported: integer and string. Will auto-identify if not set
- $multiple
boolean $multiple Allow multiple values for a single name (doesn't support assoc arrays)
Returns
boolean
Warning
The metadata will inherit the parent entity's owner and access ID. If you want
to write metadata with a different owner, use create_metadata().
|
public
boolean
|
#
deleteMetadata( null|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.
Deletes all metadata on this object (metadata.entity_guid = $this->guid).
If you pass a name, only metadata matching that name will be deleted.
Parameters
- $name
null|string $name The name of the metadata to remove.
Returns
boolean
Since
1.8
Warning
Calling this with no $name will clear all metadata on the entity.
|
public
boolean
|
#
deleteOwnedMetadata( null|string $name = null )
Deletes all metadata owned by this object (metadata.owner_guid =
$this->guid). If you pass a name, only metadata matching that name will be
deleted.
Deletes all metadata owned by this object (metadata.owner_guid =
$this->guid). If you pass a name, only metadata matching that name will be
deleted.
Parameters
- $name
null|string $name The name of metadata to delete.
Returns
boolean
Since
1.8
|
public
boolean
|
#
disableMetadata( string $name = '' )
Disables metadata for this entity, optionally based on name.
Disables metadata for this entity, optionally based on name.
Parameters
- $name
string $name An options name of metadata to disable.
Returns
boolean
Since
1.8
|
public
boolean
|
#
enableMetadata( string $name = '' )
Enables metadata for this entity, optionally based on name.
Enables metadata for this entity, optionally based on name.
Parameters
- $name
string $name An options name of metadata to enable.
Returns
boolean
Since
1.8
Warning
Before calling this, you must use access_show_hidden_entities()
|
public
mixed
|
#
getVolatileData( string $name )
Get a piece of volatile (non-persisted) data on this entity.
Get a piece of volatile (non-persisted) data on this entity.
Parameters
- $name
string $name The name of the volatile data
Returns
mixed The value or NULL if not found.
|
public
|
#
setVolatileData( string $name, mixed $value )
Set a piece of volatile (non-persisted) data on this entity
Set a piece of volatile (non-persisted) data on this entity
Parameters
- $name
string $name Name
- $value
mixed $value Value
|
public
true
|
#
deleteRelationships( )
Remove all relationships to and from this entity.
Remove all relationships to and from this entity.
Returns
true
See
|
public
boolean
|
#
addRelationship( integer $guid, string $relationship )
Add a relationship between this an another entity.
Add a relationship between this an another entity.
Parameters
- $guid
integer $guid Entity to link to.
- $relationship
string $relationship The type of relationship.
Returns
boolean
See
Tip
Read the relationship like "$guid is a $relationship of this entity."
|
public
boolean
|
#
removeRelationship( integer $guid, str $relationship )
Remove a relationship
Parameters
- $guid
integer $guid GUID of the entity to make a relationship with
- $relationship
str $relationship Name of relationship
Returns
boolean
See
|
public
boolean
|
#
setPrivateSetting( string $name, mixed $value )
Adds a private setting to this entity.
Adds a private setting to this entity.
Private settings are similar to metadata but will not be searched and there
are fewer helper functions for them.
Parameters
- $name
string $name Name of private setting
- $value
mixed $value Value of private setting
Returns
boolean
|
public
mixed
|
#
getPrivateSetting( string $name )
Returns a private setting value
Returns a private setting value
Parameters
- $name
string $name Name of the private setting
Returns
mixed
|
public
boolean
|
#
removePrivateSetting( string $name )
Removes private setting
Parameters
- $name
string $name Name of the private setting
Returns
boolean
|
public
boolean
|
#
deleteAnnotations( null|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.
Deletes all annotations on this object (annotations.entity_guid =
$this->guid). If you pass a name, only annotations matching that name will be
deleted.
Parameters
- $name
null|string $name The annotations name to remove.
Returns
boolean
Since
1.8
Warning
Calling this with no or empty arguments will clear all annotations on the
entity.
|
public
boolean
|
#
deleteOwnedAnnotations( null|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.
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
- $name
null|string $name The name of annotations to delete.
Returns
boolean
Since
1.8
|
public
boolean
|
#
disableAnnotations( string $name = '' )
Disables annotations for this entity, optionally based on name.
Disables annotations for this entity, optionally based on name.
Parameters
- $name
string $name An options name of annotations to disable.
Returns
boolean
Since
1.8
|
public
boolean
|
#
enableAnnotations( string $name = '' )
Enables annotations for this entity, optionally based on name.
Enables annotations for this entity, optionally based on name.
Parameters
- $name
string $name An options name of annotations to enable.
Returns
boolean
Since
1.8
Warning
Before calling this, you must use access_show_hidden_entities()
|
public
boolean
|
#
annotate( string $name, mixed $value, integer $access_id = ACCESS_PRIVATE, integer $owner_id = 0, string $vartype = "" )
Adds an annotation to an entity.
Adds an annotation to an entity.
Parameters
- $name
string $name Annotation name
- $value
mixed $value Annotation value
- $access_id
integer $access_id Access ID
- $owner_id
integer $owner_id GUID of the annotation owner
- $vartype
string $vartype The type of annotation value
Returns
boolean
Warning
By default, annotations are private.
Annotating an unsaved entity more than once with the same name will only save
the last annotation.
|
public
array
|
#
getAnnotations( string $name, integer $limit = 50, integer $offset = 0, string $order = "asc" )
Returns an array of annotations.
Returns an array of annotations.
Parameters
- $name
string $name Annotation name
- $limit
integer $limit Limit
- $offset
integer $offset Offset
- $order
string $order Order by time: asc or desc
Returns
array
|
public
integer
|
#
countAnnotations( string $name = "" )
Count annotations.
Parameters
- $name
string $name The type of annotation.
Returns
integer
|
public
integer
|
#
getAnnotationsAvg( string $name )
Get the average of an integer type annotation.
Get the average of an integer type annotation.
Parameters
- $name
string $name Annotation name
Returns
integer
|
public
integer
|
#
getAnnotationsSum( string $name )
Get the sum of integer type annotations of a given name.
Get the sum of integer type annotations of a given name.
Parameters
- $name
string $name Annotation name
Returns
integer
|
public
integer
|
#
getAnnotationsMin( string $name )
Get the minimum of integer type annotations of given name.
Get the minimum of integer type annotations of given name.
Parameters
- $name
string $name Annotation name
Returns
integer
|
public
integer
|
#
getAnnotationsMax( string $name )
Get the maximum of integer type annotations of a given name.
Get the maximum of integer type annotations of a given name.
Parameters
- $name
string $name Annotation name
Returns
integer
|
public
array|false
|
#
getEntitiesFromRelationship( string $relationship, boolean $inverse = false, integer $limit = 50, integer $offset = 0 )
Gets an array of entities with a relationship to this entity.
Gets an array of entities with a relationship to this entity.
Parameters
- $relationship
string $relationship Relationship type (eg "friends")
- $inverse
boolean $inverse Is this an inverse relationship?
- $limit
integer $limit Number of elements to return
- $offset
integer $offset Indexing offset
Returns
array|false An array of entities or false on failure
|
public
integer|false
|
#
countEntitiesFromRelationship( string $relationship, boolean $inverse_relationship = FALSE )
Gets the number of of entities from a specific relationship type
Gets the number of of entities from a specific relationship type
Parameters
- $relationship
string $relationship Relationship type (eg "friends")
- $inverse_relationship
boolean $inverse_relationship Invert relationship
Returns
integer|false The number of entities or false on failure
|
public
boolean
|
#
canEdit( integer $user_guid = 0 )
Can a user edit this entity.
Can a user edit this entity.
Parameters
- $user_guid
integer $user_guid The user GUID, optionally (default: logged in user)
Returns
boolean
|
public
boolean
|
#
canEditMetadata( ElggMetadata $metadata = null, integer $user_guid = 0 )
Can a user edit metadata on this entity
Can a user edit metadata on this entity
Parameters
- $metadata
ElggMetadata
$metadata The piece of metadata to specifically check
- $user_guid
integer $user_guid The user GUID, optionally (default: logged in user)
Returns
boolean
|
public
boolean
|
#
canWriteToContainer( integer $user_guid = 0, string $type = 'all', string $subtype = 'all' )
Can a user add an entity to this container
Can a user add an entity to this container
Parameters
- $user_guid
integer $user_guid The user.
- $type
string $type The type of entity we're looking to write
- $subtype
string $subtype The subtype of the entity we're looking to write
Returns
boolean
|
public
boolean
|
#
canAnnotate( integer $user_guid = 0, string $annotation_name = '' )
Can a user annotate an entity?
Can a user annotate an entity?
Parameters
- $user_guid
integer $user_guid User guid (default is logged in user)
- $annotation_name
string $annotation_name The name of the annotation (default is unspecified)
Returns
boolean
Tip
Can be overridden by registering for the permissions_check:annotate, <entity
type> plugin hook.
If you want logged out users to annotate an object, do not call canAnnotate().
It's easier than using the plugin hook.
|
public
integer
|
#
getAccessID( )
Returns the access_id.
Returns
integer The access ID
|
public
integer|null
|
#
getGUID( )
Returns the guid.
Returns
integer|null GUID
|
public
string
|
#
getType( )
Returns the entity type
Returns
string Entity type
|
public
string
|
#
getSubtype( )
Returns the entity subtype string
Returns the entity subtype string
Returns
string The entity subtype
Note
This returns a string. If you want the id, use ElggEntity::subtype.
|
public
integer
|
#
getOwnerGUID( )
Get the guid of the entity's owner.
Get the guid of the entity's owner.
Returns
integer The owner GUID
|
public
ElggEntity
|
#
getOwnerEntity( )
Gets the ElggEntity that owns this entity.
Gets the ElggEntity that owns this entity.
Returns
|
public
boolean
|
#
setContainerGUID( integer $container_guid )
Set the container for this object.
Set the container for this object.
Parameters
- $container_guid
integer $container_guid The ID of the container.
Returns
boolean
|
public
integer
|
#
getContainerGUID( )
Gets the container GUID for this entity.
Gets the container GUID for this entity.
Returns
integer
|
public
ElggEntity
|
#
getContainerEntity( )
Get the container entity for this object.
Get the container entity for this object.
Returns
Since
1.8.0
|
public
integer
|
#
getTimeUpdated( )
Returns the UNIX epoch time that this entity was last updated
Returns the UNIX epoch time that this entity was last updated
Returns
integer UNIX epoch time
|
public
string
|
#
getURL( )
Returns the URL for this entity
Returns the URL for this entity
Returns
string The URL
See
|
public
string
|
#
setURL( string $url )
Overrides the URL returned by getURL()
Overrides the URL returned by getURL()
Parameters
- $url
string $url The new item URL
Returns
string The URL
Warning
This override exists only for the life of the object.
|
public
string
|
#
getIconURL( string $size = 'medium' )
Get the URL for this entity's icon
Get the URL for this entity's icon
Plugins can register for the 'entity:icon:url', <type> plugin hook to
customize the icon for an entity.
Parameters
- $size
string $size Size of the icon: tiny, small, medium, large
Returns
string The URL
Since
1.8.0
|
public
boolean
|
#
isFullyLoaded( )
Tests to see whether the object has been fully loaded.
Tests to see whether the object has been fully loaded.
Returns
boolean
|
public
boolean|integer
|
#
save( )
Save an entity.
Returns
boolean|integer
Throws
|
protected
boolean
|
#
load( mixed $guid )
Loads attributes from the entities table into the object.
Loads attributes from the entities table into the object.
Parameters
- $guid
mixed $guid GUID of entity or stdClass object from entities table
Returns
boolean
|
public
boolean
|
#
disable( string $reason = "", boolean $recursive = true )
Disable this entity.
Disabled entities are not returned by getter functions. To enable an entity,
use enable_entity().
Recursively disabling an entity will disable all entities owned or contained
by the parent entity.
Parameters
- $reason
string $reason Optional reason
- $recursive
boolean $recursive Recursively disable all contained entities?
Returns
boolean
See
|
public
boolean
|
#
enable( )
Enable an entity
Returns
boolean
See
enable_entity()
access_show_hiden_entities()
Warning
Disabled entities can't be loaded unless access_show_hidden_entities(true) has been called.
|
public
boolean
|
#
isEnabled( )
Is this entity enabled?
Returns
boolean
|
public
boolean
|
#
delete( boolean $recursive = true )
Delete this entity.
Parameters
- $recursive
boolean $recursive Whether to delete all the entities contained by this entity
Returns
boolean
|
public
string
|
#
getLocation( )
Gets the 'location' metadata for the entity
Gets the 'location' metadata for the entity
Returns
string The location
Implementation of
|
public
boolean
|
#
setLocation( string $location )
Sets the 'location' metadata for the entity
Sets the 'location' metadata for the entity
Parameters
- $location
string $location String representation of the location
Returns
boolean
Implementation of
|
public
boolean
|
#
setLatLong( float $lat, float $long )
Set latitude and longitude metadata tags for a given entity.
Set latitude and longitude metadata tags for a given entity.
Parameters
- $lat
float $lat Latitude
- $long
float $long Longitude
Returns
boolean
Implementation of
|
public
float
|
#
getLatitude( )
Return the entity's latitude.
Return the entity's latitude.
Returns
float
Implementation of
|
public
float
|
#
getLongitude( )
Return the entity's longitude
Return the entity's longitude
Returns
float
Implementation of
|
public
true
|
#
setCalendarTimeAndDuration( integer $hour = NULL, integer $minute = NULL, integer $second = NULL, integer $day = NULL, integer $month = NULL, integer $year = NULL, integer $duration = NULL )
Set the time and duration of an object
Set the time and duration of an object
Parameters
- $hour
integer $hour If ommitted, now is assumed.
- $minute
integer $minute If ommitted, now is assumed.
- $second
integer $second If ommitted, now is assumed.
- $day
integer $day If ommitted, now is assumed.
- $month
integer $month If ommitted, now is assumed.
- $year
integer $year If ommitted, now is assumed.
- $duration
integer $duration Duration of event, remainder of the day is assumed.
Returns
true
Implementation of
|
public
integer
|
#
getCalendarStartTime( )
Returns the start timestamp.
Returns the start timestamp.
Returns
integer
Implementation of
|
public
integer
|
#
getCalendarEndTime( )
Returns the end timestamp.
Returns the end timestamp.
Returns
integer
Implementation of
|
public
array
|
#
getExportableValues( )
Returns an array of fields which can be exported.
Returns an array of fields which can be exported.
Returns
array
|
public
array
|
#
export( )
Export this class into an array of ODD Elements containing all necessary
fields. Override if you wish to return more information than can be found in
$this->attributes (shouldn't happen)
Export this class into an array of ODD Elements containing all necessary
fields. Override if you wish to return more information than can be found in
$this->attributes (shouldn't happen)
Returns
array
|
public
true
|
#
import( ODD $data )
Import data from an parsed ODD xml data array.
Import data from an parsed ODD xml data array.
Parameters
Returns
true
Throws
Implementation of
|
public
integer
|
#
getSystemLogID( )
Return an identification for the object for storage in the system log. This
id must be an integer.
Return an identification for the object for storage in the system log. This
id must be an integer.
Returns
integer
|
public
integer
|
#
getObjectFromID( integer $id )
For a given ID, return the object associated with it. This is used by the
river functionality primarily.
For a given ID, return the object associated with it. This is used by the
river functionality primarily.
This is useful for checking access permissions etc on objects.
Parameters
Returns
integer GUID
|
public
array
|
#
getTags( array $tag_names = NULL )
Returns tags for this entity.
Returns tags for this entity.
Parameters
- $tag_names
array $tag_names Optionally restrict by tag metadata names.
Returns
array
Warning
Tags must be registered by elgg_register_tag_metadata_name().
|