<?php
include 'requires.php';


class twigController
{

    public function getTwig()
    {
        try {
            $loader = new Twig_Loader_Filesystem('templates');
            $twig = new Twig_Environment($loader, ['debug' => true]);
            $twig->addExtension(new Twig_Extension_Debug());
            if(isset($_SESSION['name'])){
                $twig->addGlobal('session', $_SESSION);
            }
            return $twig;
        } catch (PDOException $e) {
            echo 'Twig error: ' . $e->getMessage();
        }
    }
}

?>
