From 2bddb6faf9aeddf40602187c57c421da8ded5c3e Mon Sep 17 00:00:00 2001 From: filippo.bertilotti <filippobertilotti@gmail.com> Date: Tue, 14 May 2024 12:06:32 +0200 Subject: [PATCH] inizializzazione Container e refactor code (parte 88) --- src/App/Controllers/products.php | 25 ++++++++++++++++++------- 1 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/App/Controllers/products.php b/src/App/Controllers/products.php index 68c4516..d7d2159 100644 --- a/src/App/Controllers/products.php +++ b/src/App/Controllers/products.php @@ -1,16 +1,27 @@ <?php namespace App\Controllers; +use App\Models\Product; +use Framework\Viewer; class Products { + public function __construct(private Viewer $viewer, private Product $model) { } public function index() { - require "src/models/product.php"; - - $model = new Product; - $products = $model->getData(); + + $products = $this->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() { - require "views/products_show.php"; + public function show(string $id) { + 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) { + echo $title, " ", $id, " ", $page; } } \ No newline at end of file -- Gitblit v1.8.0