Various improvements

This commit is contained in:
julien
2026-03-09 02:33:58 +01:00
parent 6e5119348e
commit 41beedb964
6 changed files with 57 additions and 26 deletions

View File

@@ -35,12 +35,10 @@ class PostRepositoryMedoo
{
$row = $this->db->get('post', ['id', 'title', 'content'], ['id' => $id]);
// Medoo peut retourner false ou empty si rien trouvé — normaliser en null.
if (empty($row) || $row === false) {
return null;
}
// Forcer types et clés attendues
return [
'id' => (int)($row['id'] ?? 0),
'title' => (string)($row['title'] ?? ''),

View File

@@ -3,11 +3,11 @@
declare(strict_types=1);
use Slim\App;
use Slim\Views\Twig;
use App\Repositories\PostRepositoryMedoo;
use App\Controllers\PostController;
return function (App $app, array $services): void {
$twig = $services['twig'];
$repo = $services['post_repository'];
return function (App $app, Twig $twig, PostRepositoryMedoo $repo): void {
$controller = new PostController($twig, $repo);
$app->get('/', [$controller, 'index']);