From 7baa142488879722eaffe263ddc064072f4df973 Mon Sep 17 00:00:00 2001 From: filippo.bertilotti <filippobertilotti@gmail.com> Date: Tue, 14 May 2024 10:23:53 +0200 Subject: [PATCH] autodichiarazione delle dipendenze (auto wiring) (parte 83) --- src/App/Controllers/products.php | 18 +++++++++++++++--- 1 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/App/Controllers/products.php b/src/App/Controllers/products.php index ed3769b..b9191a2 100644 --- a/src/App/Controllers/products.php +++ b/src/App/Controllers/products.php @@ -1,16 +1,28 @@ <?php namespace App\Controllers; use App\Models\Product; +use Framework\Viewer; class Products { + public function __construct(private Viewer $viewer, private Product $product) { } public function index() { $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() { - 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