Skip to content

Commit 7d7e355

Browse files
committed
feat: new moderation hooks #76
komments.comment.replied komments.comment.published also: komments.comment.received now gets the comment data
1 parent 8903790 commit 7d7e355

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

lib/KommentModeration.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ public function publishComment(string $id): mixed
3636
$comment = $this->storage->getSingleComment($id);
3737
$newStatus = $comment->published()->isTrue() ? false : true;
3838
$result = $this->storage->updateComment($id, ['published' => $newStatus]);
39+
40+
kirby()->trigger('komments.comment.published', ['comment' => $comment]);
41+
3942
return $result ? $newStatus : $comment->published();
4043
}
4144

@@ -99,6 +102,8 @@ public function replyToComment(string $id, array $formData)
99102

100103
$saveResult = $this->storage->saveComment($newComment);
101104

105+
kirby()->trigger('komments.comment.replied', ['comment' => $comment]);
106+
102107
return [
103108
'created' => $saveResult,
104109
'published' => $publishResult,

plugin/routes.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@
7777

7878
$storage->saveComment($comment);
7979

80-
kirby()->trigger('komments.comment.received', []);
80+
kirby()->trigger('komments.comment.received', ['comment' => $comment]);
81+
82+
if ($comment->parentId()->isNotEmpty()) {
83+
kirby()->trigger('komments.comment.replied', ['comment' => $comment]);
84+
}
8185

8286
if ($shouldReturnJson) {
8387
$response = [

vendor/composer/installed.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php return array(
22
'root' => array(
33
'name' => 'mauricerenck/komments',
4-
'pretty_version' => '3.2.1',
5-
'version' => '3.2.1.0',
4+
'pretty_version' => '3.2.3',
5+
'version' => '3.2.3.0',
66
'reference' => null,
77
'type' => 'kirby-plugin',
88
'install_path' => __DIR__ . '/../../',
@@ -29,8 +29,8 @@
2929
'dev_requirement' => false,
3030
),
3131
'mauricerenck/komments' => array(
32-
'pretty_version' => '3.2.1',
33-
'version' => '3.2.1.0',
32+
'pretty_version' => '3.2.3',
33+
'version' => '3.2.3.0',
3434
'reference' => null,
3535
'type' => 'kirby-plugin',
3636
'install_path' => __DIR__ . '/../../',

0 commit comments

Comments
 (0)