feat: listen to user life cycle events
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -183,6 +183,7 @@ class Store {
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* confirm if collections exist in data store
|
||||
*
|
||||
@@ -306,7 +307,12 @@ class Store {
|
||||
if ($identifier === null) {
|
||||
return $entity;
|
||||
}
|
||||
return $this->collectionDestroyById($tenantId, $userId, (string) $identifier) ? $entity : $entity;
|
||||
|
||||
$this->entityDestroyByCollectionId($tenantId, $userId, [(string) $identifier]);
|
||||
$this->chronicleExpungeByCollectionId($tenantId, [(string) $identifier]);
|
||||
$this->collectionDestroyById($tenantId, $userId, (string) $identifier);
|
||||
|
||||
return $entity;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -591,6 +597,21 @@ class Store {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete entities belonging to specific collections from the data store.
|
||||
*
|
||||
* @param string $tenantId tenant identifier
|
||||
* @param string $userId user identifier
|
||||
* @param array $identifiers collection identifiers
|
||||
*/
|
||||
private function entityDestroyByCollectionId(string $tenantId, string $userId, array $identifiers): void {
|
||||
$this->_store->selectCollection($this->_EntityTable)->deleteMany([
|
||||
'tid' => $tenantId,
|
||||
'uid' => $userId,
|
||||
'cid' => ['$in' => $identifiers],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* chronicle a operation to an entity to the data store
|
||||
*
|
||||
@@ -758,10 +779,12 @@ class Store {
|
||||
* @since Release 1.0.0
|
||||
*
|
||||
* @param array $identifiers collection of identifiers
|
||||
* @param string $tenantId tenant identifier
|
||||
*/
|
||||
private function chronicleExpungeByCollectionId(array $identifiers): void {
|
||||
private function chronicleExpungeByCollectionId(string $tenantId, array $identifiers): void {
|
||||
// Delete chronicle entries for the specified collection identifiers
|
||||
$this->_store->selectCollection($this->_ChronicleTable)->deleteMany([
|
||||
'tid' => $tenantId,
|
||||
'cid' => ['$in' => $identifiers]
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user