public static function getTwig() { if (!self::$twig) { \Twig_Autoloader::register(); $cache = Config::get('cache') ? Config::get('cache') . '/' : false; $loader = new \Twig_Loader_Filesystem(Config::get('views') . '/'); $twig = new \Twig_Environment($loader, array('cache' => $cache, 'debug' => Config::get('debug'))); // Add globals $twig->addGlobal('session', Session::getInstance()); $twig->addGlobal('url', new URL()); self::$twig = $twig; } return self::$twig; }
function test_without_static() { Session::getInstance()->set('hello', 'world'); $this->assertEquals('world', Session::getInstance()->get('hello')); }