Files
nextcloud-tables/lib/Listener/WhenRowDeletedAuditLogListener.php
Arthur Schiwon 2a6a33887e feat(Events): webhook compatible Row events with public model
- 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>
2024-07-18 14:21:55 +02:00

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(),
]);
}
}