Conversie codeigniter 4

This commit is contained in:
2026-01-09 11:41:28 +01:00
parent dbd8c8aed2
commit f0b9c6ad40
242 changed files with 20034 additions and 346 deletions
@@ -0,0 +1,57 @@
<?php
namespace App\Controllers\Projects;
use App\Controllers\BaseController;
use CodeIgniter\HTTP\ResponseInterface;
class CommentsController extends BaseController
{
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
if (!defined('AUTHENTICATED') || AUTHENTICATED === false) {
die('NO ACCESS');
}
}
public function index()
{
// Default action
}
public function getComments(int $foreignID, string $tablename): ResponseInterface
{
$comments = \Comment::getComments($foreignID, $tablename);
return $this->json($comments);
}
public function getComment(int $commentID): ResponseInterface
{
$comment = \Comment::find($commentID);
$comment->comment = base64_decode($comment->comment);
return $this->json($comment);
}
public function addComment(int $foreignID, string $tablename): ResponseInterface
{
$commentID = \Comment::addComment($foreignID, $tablename);
return $this->json($commentID);
}
public function saveComment(int $commentID): ResponseInterface
{
$comment = $this->request->getPost('comment');
$comment = base64_encode($comment);
\Comment::whereId($commentID)->update(['comment' => $comment]);
return $this->json(['success' => true]);
}
}