for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of the Divergence package.
*
* (c) Henry Paradiz <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Divergence\Responders;
use Divergence\App;
use Twig\Environment;
use Twig\Loader\FilesystemLoader;
use Psr\Http\Message\StreamInterface;
use Twig\Extension\StringLoaderExtension;
class TwigBuilder extends ResponseBuilder
{
protected string $contentType = 'text/html; charset=utf-8';
public function getBody(): StreamInterface
$loader = new FilesystemLoader([App::$App->ApplicationPath.'/views']);
$env = new Environment($loader, ['strict_variables' => true]);
$env->addExtension(new StringLoaderExtension());
$output = $env->render($this->template, $this->data);
return \GuzzleHttp\Psr7\stream_for($output);
}