<?php

namespace app\controllers;

use app\handlers\basket\Basket;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Views\Twig;
use app\models\data\Product;

class HomeController {

	/**
	 * @param Request $request
	 * @param Response $response
	 * @param Twig $view
	 *
	 * @param Product $product
	 * @param Basket $basket
	 *
	 * @return Response
	 * @throws \app\handlers\basket\exceptions\QuantityExceededException
	 */
	public function index(Request $request, Response $response, Twig $view, Product $product, Basket $basket) {

		$basket->refresh();

		$products = $product->get();

		return $view->render($response, '/front/home/home.twig', [

			'products' => $products
		]);
	}
}