Elgg
Version master
|
Entity table database service. More...
Public Member Functions | |
__construct (Config $config, Database $db, EntityCache $entity_cache, MetadataCache $metadata_cache, EventsService $events, SessionManagerService $session_manager, Translator $translator) | |
Constructor. More... | |
setEntityClass (string $type, string $subtype, string $class= '') | |
Sets class constructor name for entities with given type and subtype. More... | |
getEntityClass (string $type, string $subtype) | |
Returns class name registered as a constructor for a given type and subtype. More... | |
getRow (int $guid, int $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 (int $guid,\stdClass $row) | |
Update entity table row. More... | |
rowToElggStar (\stdClass $row) | |
Create an Elgg* object from a given entity row. More... | |
invalidateCache (int $guid) | |
Invalidate cache for entity. More... | |
get (int $guid, string $type=null, string $subtype=null) | |
Loads and returns an entity object from a guid. More... | |
exists (int $guid) | |
Does an entity exist? More... | |
fetch (QueryBuilder $query, array $options=[]) | |
Returns an array of entities with optional filtering. More... | |
updateTimeDeleted (\ElggEntity $entity, int $deleted=null) | |
Update the time_deleted column in the entities table for $entity. More... | |
updateLastAction (\ElggEntity $entity, int $posted=null) | |
Update the last_action column in the entities table for $entity. More... | |
getUserForPermissionsCheck (int $guid=null) | |
Get a user by GUID even if the entity is hidden or disabled. More... | |
restore (\ElggEntity $entity) | |
Restore entity. More... | |
enable (\ElggEntity $entity) | |
Enables entity. More... | |
disable (\ElggEntity $entity) | |
Disables entity. More... | |
delete (\ElggEntity $entity, bool $recursive=true) | |
Delete entity and all of its properties. More... | |
trash (\ElggEntity $entity, bool $recursive=true) | |
Trash an entity (not quite delete but close) More... | |
Public Attributes | |
const | TABLE_NAME = 'entities' |
const | DEFAULT_JOIN_ALIAS = 'e' |
Protected Member Functions | |
deleteRelatedEntities (\ElggEntity $entity) | |
Deletes entities owned or contained by the entity being deletes. More... | |
trashRelatedEntities (\ElggEntity $entity) | |
Trash entities owned or contained by the entity being trashed. More... | |
deleteEntityProperties (\ElggEntity $entity) | |
Clear data from secondary tables. More... | |
Protected Attributes | |
Config | $config |
Database | $db |
EntityCache | $entity_cache |
MetadataCache | $metadata_cache |
EventsService | $events |
SessionManagerService | $session_manager |
Translator | $translator |
array | $deleted_guids = [] |
array | $trashed_guids = [] |
array | $entity_classes = [] |
Entity table database service.
Definition at line 25 of file EntityTable.php.
Elgg\Database\EntityTable::__construct | ( | Config | $config, |
Database | $db, | ||
EntityCache | $entity_cache, | ||
MetadataCache | $metadata_cache, | ||
EventsService | $events, | ||
SessionManagerService | $session_manager, | ||
Translator | $translator | ||
) |
Constructor.
Config | $config | Config |
Database | $db | Database |
EntityCache | $entity_cache | Entity cache |
MetadataCache | $metadata_cache | Metadata cache |
EventsService | $events | Events service |
SessionManagerService | $session_manager | Session manager |
Translator | $translator | Translator |
Definition at line 68 of file EntityTable.php.
Elgg\Database\EntityTable::delete | ( | \ElggEntity | $entity, |
bool | $recursive = true |
||
) |
Delete entity and all of its properties.
Definition at line 492 of file EntityTable.php.
|
protected |
Clear data from secondary tables.
\ElggEntity | $entity | Entity |
Definition at line 679 of file EntityTable.php.
|
protected |
Deletes entities owned or contained by the entity being deletes.
\ElggEntity | $entity | Entity |
Definition at line 591 of file EntityTable.php.
Elgg\Database\EntityTable::disable | ( | \ElggEntity | $entity | ) |
Disables entity.
\ElggEntity | $entity | Entity to disable |
Definition at line 476 of file EntityTable.php.
Elgg\Database\EntityTable::enable | ( | \ElggEntity | $entity | ) |
Enables entity.
\ElggEntity | $entity | Entity to enable |
Definition at line 461 of file EntityTable.php.
Elgg\Database\EntityTable::exists | ( | int | $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.
int | $guid | The GUID of the entity |
Definition at line 313 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.
QueryBuilder | $query | Query |
array | $options | Options |
Definition at line 333 of file EntityTable.php.
Elgg\Database\EntityTable::get | ( | int | $guid, |
string | $type = null , |
||
string | $subtype = null |
||
) |
Loads and returns an entity object from a guid.
int | $guid | The GUID of the entity |
string | $type | The type of the entity If given, even an existing entity with the given GUID will not be returned unless its type matches |
string | $subtype | The subtype of the entity If given, even an existing entity with the given GUID will not be returned unless its subtype matches |
Definition at line 267 of file EntityTable.php.
Elgg\Database\EntityTable::getEntityClass | ( | string | $type, |
string | $subtype | ||
) |
Returns class name registered as a constructor for a given type and subtype.
Definition at line 112 of file EntityTable.php.
Elgg\Database\EntityTable::getRow | ( | int | $guid, |
int | $user_guid = null |
||
) |
Returns a database row from the entities table.
Use get_entity() to return the fully loaded entity.
int | $guid | The GUID of the object to extract |
int | $user_guid | GUID of the user accessing the row Defaults to logged in user if null Builds an access query for a logged out user if 0 |
Definition at line 130 of file EntityTable.php.
Elgg\Database\EntityTable::getUserForPermissionsCheck | ( | int | $guid = null | ) |
Get a user by GUID even if the entity is hidden or disabled.
int | $guid | User GUID. Default is logged in user |
UserFetchFailureException |
Definition at line 417 of file EntityTable.php.
Elgg\Database\EntityTable::insertRow | ( | \stdClass | $row, |
array | $attributes = [] |
||
) |
Adds a new row to the entity table.
\stdClass | $row | Entity base information |
array | $attributes | All primary table attributes Used by database mock services to allow mocking entities that were instantiated using new keyword and calling ElggEntity::save() |
Definition at line 157 of file EntityTable.php.
Elgg\Database\EntityTable::invalidateCache | ( | int | $guid | ) |
Invalidate cache for entity.
int | $guid | GUID |
Definition at line 245 of file EntityTable.php.
Elgg\Database\EntityTable::restore | ( | \ElggEntity | $entity | ) |
Restore entity.
\ElggEntity | $entity | Entity to restore |
Definition at line 445 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.
\stdClass | $row | The row of the entry in the entities table. |
ClassException | |
DomainException |
Definition at line 204 of file EntityTable.php.
Elgg\Database\EntityTable::setEntityClass | ( | string | $type, |
string | $subtype, | ||
string | $class = '' |
||
) |
Sets class constructor name for entities with given type and subtype.
DomainException |
Definition at line 96 of file EntityTable.php.
Elgg\Database\EntityTable::trash | ( | \ElggEntity | $entity, |
bool | $recursive = true |
||
) |
Trash an entity (not quite delete but close)
\ElggEntity | $entity | Entity |
bool | $recursive | Trash all owned and contained entities |
Definition at line 529 of file EntityTable.php.
|
protected |
Trash entities owned or contained by the entity being trashed.
\ElggEntity | $entity | Entity |
Definition at line 634 of file EntityTable.php.
Elgg\Database\EntityTable::updateLastAction | ( | \ElggEntity | $entity, |
int | $posted = null |
||
) |
Update the last_action column in the entities table for $entity.
\ElggEntity | $entity | Entity annotation|relationship action carried out on |
int | $posted | Timestamp of last action |
Definition at line 395 of file EntityTable.php.
Elgg\Database\EntityTable::updateRow | ( | int | $guid, |
\stdClass | $row | ||
) |
Update entity table row.
int | $guid | Entity guid |
\stdClass | $row | Updated data |
Definition at line 181 of file EntityTable.php.
Elgg\Database\EntityTable::updateTimeDeleted | ( | \ElggEntity | $entity, |
int | $deleted = null |
||
) |
Update the time_deleted column in the entities table for $entity.
\ElggEntity | $entity | Entity to update |
int | $deleted | Timestamp when the entity was deleted |
Definition at line 370 of file EntityTable.php.
|
protected |
Definition at line 37 of file EntityTable.php.
|
protected |
Definition at line 39 of file EntityTable.php.
|
protected |
Definition at line 51 of file EntityTable.php.
|
protected |
Definition at line 41 of file EntityTable.php.
|
protected |
Definition at line 55 of file EntityTable.php.
|
protected |
Definition at line 45 of file EntityTable.php.
|
protected |
Definition at line 43 of file EntityTable.php.
|
protected |
Definition at line 47 of file EntityTable.php.
|
protected |
Definition at line 49 of file EntityTable.php.
|
protected |
Definition at line 53 of file EntityTable.php.
const Elgg\Database\EntityTable::DEFAULT_JOIN_ALIAS = 'e' |
Definition at line 35 of file EntityTable.php.
const Elgg\Database\EntityTable::TABLE_NAME = 'entities' |
Definition at line 33 of file EntityTable.php.