PHP Class Elgg\Database\SubtypeTable

Since: 1.10.0
Show file Open project: elgg/elgg Class Usage Examples

Protected Properties

Property Type Description
$cache stdClass[] | null
$db Elgg\Database

Public Methods

Method Description
__construct ( Database $db ) Constructor
add ( string $type, string $subtype, string $class = "" ) : integer Register \ElggEntities with a certain type and subtype to be loaded as a specific class.
getClass ( string $type, string $subtype ) : string | null Return the class name for a registered type and subtype.
getClassFromId ( integer $subtype_id ) : string | null Returns the class name for a subtype id.
getId ( string $type, string $subtype ) : integer Return the id for a given subtype.
getSubtype ( integer $subtype_id ) : string | false Gets the denormalized string for a given subtype ID.
remove ( string $type, string $subtype ) : boolean Removes a registered \ElggEntity type, subtype, and classname.
retrieveFromCache ( string $type, string $subtype ) : stdClass | null Retrieve subtype from the cache.
setCachedValues ( array $values ) : void Set the cached values from the boot data
update ( string $type, string $subtype, string $class = '' ) : boolean Update a registered \ElggEntity type, subtype, and class name

Protected Methods

Method Description
getPopulatedCache ( ) : array Get a populated cache object
invalidateCache ( ) : void Empty the cache. Also invalidates the boot cache and memcache

Method Details

__construct() public method

Constructor
public __construct ( Database $db )
$db Elgg\Database Elgg database

add() public method

By default entities are loaded as one of the 4 parent objects: site, user, object, or group. If you subclass any of these you can register the classname with add_subtype() so it will be loaded as that class automatically when retrieved from the database with {@link get_entity()}.
See also: update_subtype()
See also: remove_subtype()
See also: get_entity()
public add ( string $type, string $subtype, string $class = "" ) : integer
$type string The type you're subtyping (site, user, object, or group)
$subtype string The subtype
$class string Optional class name for the object
return integer

getClass() public method

Entities can be registered to always be loaded as a certain class with add_subtype() or update_subtype(). This function returns the class name if found and null if not.
See also: get_subtype_from_id()
See also: get_subtype_class_from_id()
public getClass ( string $type, string $subtype ) : string | null
$type string The type
$subtype string The subtype
return string | null a class name or null

getClassFromId() public method

Returns the class name for a subtype id.
See also: get_subtype_class()
See also: get_subtype_from_id()
public getClassFromId ( integer $subtype_id ) : string | null
$subtype_id integer The subtype id
return string | null

getId() public method

\ElggEntity objects have a type and a subtype. Subtypes are defined upon creation and cannot be changed. Plugin authors generally don't need to use this function unless writing their own SQL queries. Use {@link \ElggEntity::getSubtype()} to return the string subtype.
See also: get_subtype_from_id()
public getId ( string $type, string $subtype ) : integer
$type string Type
$subtype string Subtype
return integer Subtype ID

getPopulatedCache() protected method

Get a populated cache object
protected getPopulatedCache ( ) : array
return array

getSubtype() public method

Gets the denormalized string for a given subtype ID.
See also: get_subtype_id()
public getSubtype ( integer $subtype_id ) : string | false
$subtype_id integer Subtype ID from database
return string | false Subtype name, false if subtype not found

invalidateCache() protected method

Empty the cache. Also invalidates the boot cache and memcache
protected invalidateCache ( ) : void
return void

remove() public method

Removes a registered \ElggEntity type, subtype, and classname.
See also: add_subtype()
See also: update_subtype()
public remove ( string $type, string $subtype ) : boolean
$type string Type
$subtype string Subtype
return boolean

retrieveFromCache() public method

Retrieve subtype from the cache.
public retrieveFromCache ( string $type, string $subtype ) : stdClass | null
$type string
$subtype string
return stdClass | null

setCachedValues() public method

Set the cached values from the boot data
public setCachedValues ( array $values ) : void
$values array Values from boot data
return void

update() public method

Update a registered \ElggEntity type, subtype, and class name
public update ( string $type, string $subtype, string $class = '' ) : boolean
$type string Type
$subtype string Subtype
$class string Class name to use when loading this entity
return boolean

Property Details

$cache protected property

protected stdClass[]|null $cache
return stdClass[] | null

$db protected property

protected Database,Elgg $db
return Elgg\Database