for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Cecil\Renderer\Twig;
use Cecil\Builder;
use Cecil\Config;
use Cecil\Renderer\Twig;
use Psr\Log\LoggerInterface;
/**
* Factory to create and configure the Twig Renderer.
*
* This factory allows creating the renderer with all its dependencies
* in a lazy manner (only when needed).
*/
class TwigFactory
{
private Config $config;
private LoggerInterface $logger;
private Builder $builder;
public function __construct(
Config $config,
LoggerInterface $logger,
Builder $builder
) {
$this->config = $config;
$this->logger = $logger;
$this->builder = $builder;
}
* Creates a Twig renderer instance.
* @param string|array|null $templatesPath Template path(s) (uses default config if null)
* @return Twig Configured renderer instance
public function create(string|array|null $templatesPath = null): Twig
if ($templatesPath === null) {
$templatesPath = $this->config->getLayoutsPath();
return new Twig($this->builder, $templatesPath);