2014-05-14 13:24:20 +00:00
|
|
|
<?php namespace System\Twig;
|
|
|
|
|
|
2019-03-27 19:15:17 +00:00
|
|
|
use Twig\Environment as TwigEnvironment;
|
2017-08-09 01:55:48 +00:00
|
|
|
use Illuminate\Contracts\View\Engine as EngineInterface;
|
2014-05-14 13:24:20 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* View engine used by the system, used for converting .htm files to twig.
|
|
|
|
|
*
|
|
|
|
|
* @package october\system
|
|
|
|
|
* @author Alexey Bobkov, Samuel Georges
|
|
|
|
|
*/
|
|
|
|
|
class Engine implements EngineInterface
|
|
|
|
|
{
|
|
|
|
|
/**
|
2019-03-27 19:15:17 +00:00
|
|
|
* @var TwigEnvironment
|
2014-05-14 13:24:20 +00:00
|
|
|
*/
|
|
|
|
|
protected $environment;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructor
|
|
|
|
|
*/
|
2019-03-27 19:15:17 +00:00
|
|
|
public function __construct(TwigEnvironment $environment)
|
2014-05-14 13:24:20 +00:00
|
|
|
{
|
|
|
|
|
$this->environment = $environment;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function get($path, array $vars = [])
|
|
|
|
|
{
|
|
|
|
|
$template = $this->environment->loadTemplate($path);
|
|
|
|
|
return $template->render($vars);
|
|
|
|
|
}
|
2014-10-18 09:58:50 +00:00
|
|
|
}
|