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

WARNING: API IN FLUX. More...

Public Member Functions

 __construct (Config $config, Database $db, EntityCache $entity_cache, MetadataCache $metadata_cache, PrivateSettingsCache $private_settings_cache, EventsService $events, ElggSession $session, Translator $translator, LoggerInterface $logger)
 Constructor. More...
 
 setEntityClass ($type, $subtype, $class= '')
 Sets class constructor name for entities with given type and subtype. More...
 
 getEntityClass ($type, $subtype)
 Returns class name registered as a constructor for a given type and subtype. More...
 
 getRow ($guid, $user_guid=null)
 Returns a database row from the entities table. More...
 
 insertRow (stdClass $row, array $attributes=[])
 Adds a new row to the entity table. More...
 
 updateRow ($guid, stdClass $row)
 Update entity table row. More...
 
 rowToElggStar (stdClass $row)
 Create an Elgg* object from a given entity row. More...
 
 getFromCache ($guid)
 Get an entity from the in-memory or memcache caches. More...
 
 invalidateCache ($guid)
 Invalidate cache for entity. More...
 
 get ($guid, $type=null, $subtype=null)
 Loads and returns an entity object from a guid. More...
 
 exists ($guid)
 Does an entity exist? More...
 
 enable ($guid, $recursive=true)
 Enable an entity. More...
 
 fetch (QueryBuilder $query, array $options=[])
 Returns an array of entities with optional filtering. More...
 
 updateLastAction (ElggEntity $entity, $posted=null)
 Update the last_action column in the entities table for $guid. More...
 
 getUserForPermissionsCheck ($guid=0)
 Get a user by GUID even if the entity is hidden or disabled. More...
 
 disableEntities (ElggEntity $entity)
 Disables all entities owned and contained by a user (or another entity) More...
 
 delete (\ElggEntity $entity, $recursive=true)
 Delete entity and all of its properties. More...
 

Protected Member Functions

 deleteRelatedEntities (ElggEntity $entity)
 Deletes entities owned or contained by the entity being deletes. More...
 
 deleteEntityProperties (ElggEntity $entity)
 Clear data from secondary tables. More...
 

Protected Attributes

 $config
 
 $db
 
 $table
 
 $entity_classes
 
 $entity_cache
 
 $entity_preloader
 
 $metadata_cache
 
 $private_settings_cache
 
 $events
 
 $session
 
 $translator
 
 $logger
 

Detailed Description

WARNING: API IN FLUX.

DO NOT USE DIRECTLY.

Definition at line 38 of file EntityTable.php.

Constructor & Destructor Documentation

Elgg\Database\EntityTable::__construct ( Config  $config,
Database  $db,
EntityCache  $entity_cache,
MetadataCache  $metadata_cache,
PrivateSettingsCache  $private_settings_cache,
EventsService  $events,
ElggSession  $session,
Translator  $translator,
LoggerInterface  $logger 
)

Constructor.

Parameters
Config$configConfig
Database$dbDatabase
EntityCache$entity_cacheEntity cache
MetadataCache$metadata_cacheMetadata cache
PrivateSettingsCache$private_settings_cachePrivate Settings cache
EventsService$eventsEvents service
ElggSession$sessionSession
Translator$translatorTranslator
LoggerInterface$loggerLogger

Definition at line 115 of file EntityTable.php.

Member Function Documentation

Elgg\Database\EntityTable::delete ( \ElggEntity  $entity,
  $recursive = true 
)

Delete entity and all of its properties.

Parameters
ElggEntity$entityEntity
bool$recursiveDelete all owned and contained entities
Returns
bool
Exceptions
DatabaseException

Definition at line 625 of file EntityTable.php.

Elgg\Database\EntityTable::deleteEntityProperties ( ElggEntity  $entity)
protected

Clear data from secondary tables.

Parameters
ElggEntity$entityEntity
Returns
void

Definition at line 710 of file EntityTable.php.

Elgg\Database\EntityTable::deleteRelatedEntities ( ElggEntity  $entity)
protected

Deletes entities owned or contained by the entity being deletes.

Parameters
ElggEntity$entityEntity
Returns
void
Exceptions
DatabaseException

Definition at line 670 of file EntityTable.php.

Elgg\Database\EntityTable::disableEntities ( ElggEntity  $entity)

Disables all entities owned and contained by a user (or another entity)

Parameters
ElggEntity$entityOwner/container entity
Returns
bool
Exceptions
DatabaseException

Definition at line 595 of file EntityTable.php.

Elgg\Database\EntityTable::enable (   $guid,
  $recursive = true 
)

Enable an entity.

Parameters
int$guidGUID of entity to enable
bool$recursiveRecursively enable all entities disabled with the entity?
Returns
bool

Definition at line 452 of file EntityTable.php.

Elgg\Database\EntityTable::exists (   $guid)

Does an entity exist?

This function checks for the existence of an entity independent of access permissions. It is useful for situations when a user cannot access an entity and it must be determined whether entity has been deleted or the access level has changed.

Parameters
int$guidThe GUID of the entity
Returns
bool

Definition at line 430 of file EntityTable.php.

Elgg\Database\EntityTable::fetch ( QueryBuilder  $query,
array  $options = [] 
)

Returns an array of entities with optional filtering.

Entities are the basic unit of storage in Elgg. This function provides the simplest way to get an array of entities. There are many options available that can be passed to filter what sorts of entities are returned.

Parameters
QueryBuilder$queryQuery
array$optionsOptions
Returns
ElggEntity[]
Exceptions
DatabaseException

Definition at line 483 of file EntityTable.php.

Elgg\Database\EntityTable::get (   $guid,
  $type = null,
  $subtype = null 
)

Loads and returns an entity object from a guid.

Parameters
int$guidThe GUID of the entity
string$typeThe type of the entity If given, even an existing entity with the given GUID will not be returned unless its type matches
string$subtypeThe subtype of the entity If given, even an existing entity with the given GUID will not be returned unless its subtype matches
Returns
ElggEntity|false The correct Elgg or custom object based upon entity type and subtype
Exceptions
ClassException
InvalidParameterException

Definition at line 379 of file EntityTable.php.

Elgg\Database\EntityTable::getEntityClass (   $type,
  $subtype 
)

Returns class name registered as a constructor for a given type and subtype.

Parameters
string$typeEntity type
string$subtypeEntity subtype
Returns
string

Definition at line 164 of file EntityTable.php.

Elgg\Database\EntityTable::getFromCache (   $guid)

Get an entity from the in-memory or memcache caches.

Parameters
int$guidGUID
Returns
|false

Definition at line 324 of file EntityTable.php.

Elgg\Database\EntityTable::getRow (   $guid,
  $user_guid = null 
)

Returns a database row from the entities table.

See also
entity_row_to_elggstar()

Use get_entity() to return the fully loaded entity.

Warning
This will only return results if a) it exists, b) you have access to it. see _elgg_get_access_where_sql().
Parameters
int$guidThe GUID of the object to extract
int$user_guidGUID of the user accessing the row Defaults to logged in user if null Builds an access query for a logged out user if 0
Returns
stdClass|false

Definition at line 189 of file EntityTable.php.

Elgg\Database\EntityTable::getUserForPermissionsCheck (   $guid = 0)

Get a user by GUID even if the entity is hidden or disabled.

Parameters
int$guidUser GUID. Default is logged in user
Returns
ElggUser|false
Exceptions
ClassException
InvalidParameterException

Definition at line 558 of file EntityTable.php.

Elgg\Database\EntityTable::insertRow ( stdClass  $row,
array  $attributes = [] 
)

Adds a new row to the entity table.

Parameters
stdClass$rowEntity base information
array$attributesAll primary table attributes Used by database mock services to allow mocking entities that were instantiated using new keyword and calling ElggEntity::save()
Returns
int|false

Definition at line 217 of file EntityTable.php.

Elgg\Database\EntityTable::invalidateCache (   $guid)

Invalidate cache for entity.

Parameters
int$guidGUID
Returns
void

Definition at line 352 of file EntityTable.php.

Elgg\Database\EntityTable::rowToElggStar ( stdClass  $row)

Create an Elgg* object from a given entity row.

Handles loading all tables into the correct class.

See also
get_entity_as_row()
get_entity()
Parameters
stdClass$rowThe row of the entry in the entities table.
Returns
ElggEntity|false
Exceptions
ClassException
InvalidParameterException

Definition at line 283 of file EntityTable.php.

Elgg\Database\EntityTable::setEntityClass (   $type,
  $subtype,
  $class = '' 
)

Sets class constructor name for entities with given type and subtype.

Parameters
string$typeEntity type
string$subtypeEntity subtype
string$classEntity class
Returns
void
Exceptions
InvalidParameterException

Definition at line 148 of file EntityTable.php.

Elgg\Database\EntityTable::updateLastAction ( ElggEntity  $entity,
  $posted = null 
)

Update the last_action column in the entities table for $guid.

Warning
This is different to time_updated. Time_updated is automatically set, while last_action is only set when explicitly called.
Parameters
ElggEntity$entityEntity annotation|relationship action carried out on
int$postedTimestamp of last action
Returns
int

Definition at line 527 of file EntityTable.php.

Elgg\Database\EntityTable::updateRow (   $guid,
stdClass  $row 
)

Update entity table row.

Parameters
int$guidEntity guid
stdClass$rowUpdated data
Returns
int|false

Definition at line 246 of file EntityTable.php.

Member Data Documentation

Elgg\Database\EntityTable::$config
protected

Definition at line 45 of file EntityTable.php.

Elgg\Database\EntityTable::$db
protected

Definition at line 50 of file EntityTable.php.

Elgg\Database\EntityTable::$entity_cache
protected

Definition at line 65 of file EntityTable.php.

Elgg\Database\EntityTable::$entity_classes
protected

Definition at line 60 of file EntityTable.php.

Elgg\Database\EntityTable::$entity_preloader
protected

Definition at line 70 of file EntityTable.php.

Elgg\Database\EntityTable::$events
protected

Definition at line 85 of file EntityTable.php.

Elgg\Database\EntityTable::$logger
protected

Definition at line 100 of file EntityTable.php.

Elgg\Database\EntityTable::$metadata_cache
protected

Definition at line 75 of file EntityTable.php.

Elgg\Database\EntityTable::$private_settings_cache
protected

Definition at line 80 of file EntityTable.php.

Elgg\Database\EntityTable::$session
protected

Definition at line 90 of file EntityTable.php.

Elgg\Database\EntityTable::$table
protected

Definition at line 55 of file EntityTable.php.

Elgg\Database\EntityTable::$translator
protected

Definition at line 95 of file EntityTable.php.


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