Elgg  Version 2.3
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Elgg\Database\SubtypeTable Class Reference

Public Member Functions

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

Protected Member Functions

 invalidateCache ()
 Empty the cache. More...
 
 getPopulatedCache ()
 Get a populated cache object. More...
 

Protected Attributes

 $cache = null
 
 $db
 

Detailed Description

Definition at line 15 of file SubtypeTable.php.

Constructor & Destructor Documentation

◆ __construct()

Elgg\Database\SubtypeTable::__construct ( Database  $db)

Constructor.

Parameters
Database$dbElgg database

Definition at line 32 of file SubtypeTable.php.

Member Function Documentation

◆ add()

Elgg\Database\SubtypeTable::add (   $type,
  $subtype,
  $class = "" 
)

Register \ElggEntities with a certain type and subtype to be loaded as a specific class.

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 get_entity().

Warning
This function cannot be used to change the class for a type-subtype pair. Use update_subtype() for that.
Parameters
string$typeThe type you're subtyping (site, user, object, or group)
string$subtypeThe subtype
string$classOptional class name for the object
Returns
int
See also
update_subtype()
remove_subtype()
get_entity()

Definition at line 174 of file SubtypeTable.php.

◆ getClass()

Elgg\Database\SubtypeTable::getClass (   $type,
  $subtype 
)

Return the class name for a registered type and subtype.

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.

Parameters
string$typeThe type
string$subtypeThe subtype
Returns
string|null a class name or null
See also
get_subtype_from_id()
get_subtype_class_from_id() @access private

Definition at line 128 of file SubtypeTable.php.

◆ getClassFromId()

Elgg\Database\SubtypeTable::getClassFromId (   $subtype_id)

Returns the class name for a subtype id.

Parameters
int$subtype_idThe subtype id
Returns
string|null
See also
get_subtype_class()
get_subtype_from_id() @access private

Definition at line 144 of file SubtypeTable.php.

◆ getId()

Elgg\Database\SubtypeTable::getId (   $type,
  $subtype 
)

Return the id for a given subtype.

\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 () to return the string subtype.

Definition at line 66 of file SubtypeTable.php.

◆ getPopulatedCache()

Elgg\Database\SubtypeTable::getPopulatedCache ( )
protected

Get a populated cache object.

Returns
array

Definition at line 283 of file SubtypeTable.php.

◆ getSubtype()

Elgg\Database\SubtypeTable::getSubtype (   $subtype_id)

Gets the denormalized string for a given subtype ID.

Parameters
int$subtype_idSubtype ID from database
Returns
string|false Subtype name, false if subtype not found
See also
get_subtype_id() @access private

Definition at line 84 of file SubtypeTable.php.

◆ invalidateCache()

Elgg\Database\SubtypeTable::invalidateCache ( )
protected

Empty the cache.

Also invalidates the boot cache and memcache

Returns
void

Definition at line 272 of file SubtypeTable.php.

◆ remove()

Elgg\Database\SubtypeTable::remove (   $type,
  $subtype 
)

Removes a registered \ElggEntity type, subtype, and classname.

Warning
You do not want to use this function. If you want to unregister a class for a subtype, use update_subtype(). Using this function will permanently orphan all the objects created with the specified subtype.
Parameters
string$typeType
string$subtypeSubtype
Returns
bool
See also
add_subtype()
update_subtype()

Definition at line 214 of file SubtypeTable.php.

◆ retrieveFromCache()

Elgg\Database\SubtypeTable::retrieveFromCache (   $type,
  $subtype 
)

Retrieve subtype from the cache.

Parameters
string$type
string$subtype
Returns
\stdClass|null

@access private

Definition at line 103 of file SubtypeTable.php.

◆ setCachedValues()

Elgg\Database\SubtypeTable::setCachedValues ( array  $values)

Set the cached values from the boot data.

Parameters
array$valuesValues from boot data
Returns
void

Definition at line 42 of file SubtypeTable.php.

◆ update()

Elgg\Database\SubtypeTable::update (   $type,
  $subtype,
  $class = '' 
)

Update a registered \ElggEntity type, subtype, and class name.

Parameters
string$typeType
string$subtypeSubtype
string$classClass name to use when loading this entity
Returns
bool

Definition at line 241 of file SubtypeTable.php.

Member Data Documentation

◆ $cache

Elgg\Database\SubtypeTable::$cache = null
protected

Definition at line 20 of file SubtypeTable.php.

◆ $db

Elgg\Database\SubtypeTable::$db
protected

Definition at line 25 of file SubtypeTable.php.


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