refactor comment system into comments plugin
This commit is contained in:
parent
31844269c0
commit
fb36329556
8 changed files with 134 additions and 101 deletions
25
public/site/plugins/comments/routes/delete.php
Normal file
25
public/site/plugins/comments/routes/delete.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'pattern' => '(:all)delete-comment.json',
|
||||
'method' => 'POST',
|
||||
'action' => function () {
|
||||
$json = file_get_contents('php://input');
|
||||
$data = json_decode($json);
|
||||
|
||||
$page = page($data->pageUri);
|
||||
$file = $page->file($data->fileName);
|
||||
$user = kirby()->user($data->userUuid);
|
||||
|
||||
|
||||
$comments = $file->comments()->isEmpty() == true ? [] : Yaml::decode($file->comments()->value());
|
||||
|
||||
unset($comments[$data->id] );
|
||||
|
||||
$newFile = $file->update([
|
||||
'comments' => $comments
|
||||
]);
|
||||
|
||||
return getFileData($newFile);
|
||||
}
|
||||
];
|
||||
Loading…
Add table
Add a link
Reference in a new issue