135 $where->guids =
$guid;
139 $select->select(
'e.*');
140 $select->addClause($where);
142 return $this->db->getDataRow($select) ?: null;
162 'container_guid' => $insert->param($row->container_guid,
ELGG_VALUE_GUID),
163 'access_id' => $insert->param($row->access_id,
ELGG_VALUE_ID),
169 return $this->db->insertData($insert);
182 $update->set(
'owner_guid', $update->param($row->owner_guid,
ELGG_VALUE_GUID))
183 ->
set(
'container_guid', $update->param($row->container_guid,
ELGG_VALUE_GUID))
184 ->
set(
'access_id', $update->param($row->access_id,
ELGG_VALUE_ID))
189 return $this->db->updateData($update);
204 if (!isset($row->guid) || !isset($row->subtype)) {
209 if ($class_name && !class_exists($class_name)) {
210 $this->
getLogger()->error(
"Class '{$class_name}' was not found, missing plugin?");
216 'object' => \ElggObject::class,
217 'user' => \ElggUser::class,
218 'group' => \ElggGroup::class,
219 'site' => \ElggSite::class,
222 if (isset($map[$row->type])) {
223 $class_name = $map[$row->type];
225 throw new DomainException(
"Entity type {$row->type} is not supported.");
229 $entity =
new $class_name($row);
231 throw new ClassException(
"{$class_name} must extend " . \ElggEntity::class);
245 $entity = $this->entity_cache->load($guid);
297 (!isset($type) ||
$entity->type === $type) &&
298 (!isset($subtype) ||
$entity->subtype === $subtype)
303 $row = $this->
getRow($guid);
308 if (isset($type) && $row->type !== $type) {
312 if (isset($subtype) && $row->subtype !== $subtype) {
318 if (
$entity instanceof \stdClass) {
340 public function exists(
int $guid): bool {
343 return !empty($this->
getRow($guid));
367 $preload = array_filter(
$results,
function ($e) {
368 return $e instanceof \ElggEntity;
371 $this->metadata_cache->populateFromEntities($preload);
373 $props_to_preload = [];
375 $props_to_preload[] =
'owner_guid';
379 $props_to_preload[] =
'container_guid';
382 if (!empty($props_to_preload)) {
383 _elgg_services()->entityPreloader->preload($preload, $props_to_preload);
407 ->where($update->compare(
'guid',
'=', $entity->guid,
ELGG_VALUE_GUID));
409 $this->db->updateData($update);
423 if (empty($guid) || $guid === $this->session_manager->getLoggedInUserGuid()) {
424 return $this->session_manager->getLoggedInUser();
429 return $this->
get(
$guid,
'user');
435 $message = $this->translator->translate(
'UserFetchFailureException', [$guid]);
455 return $this->db->updateData(
$qb);
470 return $this->db->updateData(
$qb);
482 $guid = $entity->guid;
487 if (!$this->events->triggerBefore(
'delete', $entity->type, $entity)) {
491 $this->events->trigger(
'delete', $entity->type, $entity);
499 $this->deleted_guids[] = $entity->guid;
510 $this->db->deleteData(
$qb);
512 $this->events->triggerAfter(
'delete', $entity->type, $entity);
542 'batch_inc_offset' =>
false,
547 if (in_array($e->guid, $this->deleted_guids)) {
553 if (!$this->
delete($e,
true)) {
575 _elgg_services()->relationshipsTable->removeAll($entity->guid,
'',
false,
'',
false);
576 _elgg_services()->relationshipsTable->removeAll($entity->guid,
'',
true,
'',
false);
580 _elgg_services()->delayedEmailQueueTable->deleteAllRecipientRows($entity->guid);
583 $dir = new \Elgg\EntityDirLocator($entity->guid);
enable(\ElggEntity $entity)
Enables entity.
elgg_call(int $flags, Closure $closure)
Calls a callable autowiring the arguments using public DI services and applying logic based on flags...
deleteOwnedAccessCollections()
Remove all access collections owned by this entity.
const ELGG_DISABLE_SYSTEM_LOG
getFromCache(int $guid)
Get an entity from the in-memory or memcache caches.
static table($table, $alias=null)
{}
SessionManagerService $session_manager
deleteOwnedAnnotations(string $name=null)
Deletes all annotations owned by this object (annotations.owner_guid = $this->guid).
EntityCache $entity_cache
disable(\ElggEntity $entity)
Disables entity.
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
Exception thrown if a value does not adhere to a defined valid data domain.
Database abstraction query builder.
fetch(QueryBuilder $query, array $options=[])
Returns an array of entities with optional filtering.
deleteAnnotations(string $name=null)
Deletes all annotations on this object (annotations.entity_guid = $this->guid).
trait TimeUsing
Adds methods for setting the current time (for testing)
deleteRelatedEntities(\ElggEntity $entity)
Deletes entities owned or contained by the entity being deletes.
getUserForPermissionsCheck(int $guid=null)
Get a user by GUID even if the entity is hidden or disabled.
elgg_get_ignore_access()
Functions for Elgg's access system for entities, metadata, and annotations.
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
MetadataCache $metadata_cache
getCurrentTime($modifier= '')
Get the (cloned) time.
trait Loggable
Enables adding a logger.
const ELGG_IGNORE_ACCESS
elgg_call() flags
invalidateCache(int $guid)
Invalidate cache for entity.
getEntityClass(string $type, string $subtype)
Returns class name registered as a constructor for a given type and subtype.
static intoTable($table)
{}
A generic parent class for Class exceptions.
const ELGG_SHOW_DISABLED_ENTITIES
removeAllRelatedRiverItems()
Removes all river items related to this entity.
elgg_get_entities(array $options=[])
Fetches/counts entities or performs a calculation on their properties.
Builds queries for filtering entities by their properties in the entities table.
rowToElggStar(\stdClass $row)
Create an Elgg* object from a given entity row.
Exception indicating a user could not be looked up for a permissions check.
Volatile cache for entities.
compare($x, $comparison, $y=null, $type=null, $case_sensitive=null)
Build value comparison clause.
deleteMetadata(string $name=null)
Deletes all metadata on this object (metadata.entity_guid = $this->guid).
EntityPreloader $entity_preloader
updateLastAction(\ElggEntity $entity, int $posted=null)
Update the last_action column in the entities table for $entity.
deleteAccessCollectionMemberships()
Remove the membership of all access collections for this entity (if the entity is a user) ...
const ELGG_VALUE_TIMESTAMP
elgg_delete_directory(string $directory, bool $leave_base_directory=false)
Delete a directory and all its contents.
static fromTable($table, $alias=null)
{}
exists(int $guid)
Does an entity exist?
getLogger()
Returns logger.
merge($parts=null, $boolean= 'AND')
Merges multiple composite expressions with a boolean.
updateRow(int $guid,\stdClass $row)
Update entity table row.
__construct(Config $config, Database $db, EntityCache $entity_cache, MetadataCache $metadata_cache, EventsService $events, SessionManagerService $session_manager, Translator $translator)
Constructor.
deleteEntityProperties(\ElggEntity $entity)
Clear data from secondary tables.
_elgg_services()
Get the global service provider.
getRow(int $guid, int $user_guid=null)
Returns a database row from the entities table.
Preload entities based on properties of fetched objects.
$attributes
Elgg AJAX loader.
setEntityClass(string $type, string $subtype, string $class= '')
Sets class constructor name for entities with given type and subtype.
insertRow(\stdClass $row, array $attributes=[])
Adds a new row to the entity table.
static fromTable($table, $alias=null)
{}
Entity table database service.
$guid
Reset an ElggUpgrade.