Various improvements
This commit is contained in:
@@ -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'] ?? ''),
|
||||
|
||||
@@ -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']);
|
||||
|
||||
Reference in New Issue
Block a user