From 8cb4bd47128f836255687a635f76c0e6fd3dc643 Mon Sep 17 00:00:00 2001 From: filippo.bertilotti <filippobertilotti@gmail.com> Date: Wed, 15 May 2024 12:06:40 +0200 Subject: [PATCH] refactor, utilizzo di exception al posto di exit per maggiori informazioni sull'errore (parte 94) --- src/App/Controllers/products.php | 18 ++++++++++++------ 1 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/App/Controllers/products.php b/src/App/Controllers/products.php index 4b124f5..eb91be1 100644 --- a/src/App/Controllers/products.php +++ b/src/App/Controllers/products.php @@ -1,18 +1,24 @@ <?php namespace App\Controllers; use App\Models\Product; +use Framework\Viewer; class Products { + public function __construct(private $viewer, private Product $model) { } public function index() { + + $products = $this->model->getData(); - $model = new Product; - $products = $model->getData(); - - require "views/products_index.php"; + echo $this->viewer->render("shared/header.php"); + echo $this->viewer->render("Products/index.php", [ + "products"=> $products + ]); } public function show(string $id) { - var_dump($id); - require "views/products_show.php"; + echo $this->viewer->render("shared/header.php"); + echo $this->viewer->render("Products/show.php", [ + "id"=> $id + ]); } public function showPage(string $title, string $id, string $page) { -- Gitblit v1.8.0