<?php
namespace Controleur;
use Model\CommentaryModel;
use Gateway\CommentaryGateway;
use Model\UserModel;
use Gateway\UserGateway;


use Gateway\QuoteGateway;


class UserControler {

    private QuoteGateway $quoteGateway;
    private CommentaryModel $cMod;
    private UserModel $uMod;

    public function __construct() {
        global $co;
        $this->quoteGateway = new QuoteGateway($co); 
        $this->cMod = new CommentaryModel(new CommentaryGateway($co));
        $this->uMod = new UserModel(new UserGateway($co));
    }
    
    public function profil() {

        global $vues;
        require_once $vues['profil'];

    }
    public function quiz() {
        global $vues;
        require_once $vues['quiz'];
    }


    public function addComment(){
        $id = $_POST['idQuote'];
        $this->cMod->createComment($_POST['content'],$_POST['idQuote'],$this->uMod->getIdByUsername($_SESSION['user']));
        header("Location: /~kekentin/WF/WF-Website/quote/$id");
    }
    

    public function favorite(array $args) {
        global $vues;
        
        $userId = $this->uMod->getIdByUsername($_SESSION["user"]);

        $favorites = $this->quoteGateway->getFavorites($userId);

        require_once $vues['favorite'];
    }
}
