mirror of
https://github.com/nextcloud/tables.git
synced 2025-07-31 21:09:20 +00:00

- implements OCP\EventDispatcher\IWebhookCompatibleEvent - add lib/Model/Public/Row as sort of API-like model for Tables Row data - change exisiting events to use new abstract row event class Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
32 lines
734 B
PHP
32 lines
734 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace OCA\Tables\Listener;
|
|
|
|
use OCA\Tables\Event\RowDeletedEvent;
|
|
use OCA\Tables\Service\Support\AuditLogServiceInterface;
|
|
use OCP\EventDispatcher\Event;
|
|
use OCP\EventDispatcher\IEventListener;
|
|
|
|
/**
|
|
* @template-implements IEventListener<Event|RowDeletedEvent>
|
|
*/
|
|
final class WhenRowDeletedAuditLogListener implements IEventListener {
|
|
public function __construct(protected AuditLogServiceInterface $auditLogService) {
|
|
}
|
|
|
|
public function handle(Event $event): void {
|
|
if (!($event instanceof RowDeletedEvent)) {
|
|
return;
|
|
}
|
|
|
|
$row = $event->getRow();
|
|
$rowId = $row->rowId;
|
|
|
|
$this->auditLogService->log("Row with ID: $rowId was deleted", [
|
|
'row' => $row->jsonSerialize(),
|
|
]);
|
|
}
|
|
}
|