Adding convenience codegen(..) function

This commit is contained in:
Pavel Shevaev 2023-11-14 23:20:17 +03:00
parent 27f32804cc
commit 0b9db7e6a0
1 changed files with 12 additions and 0 deletions

View File

@ -2,6 +2,18 @@
namespace metagen_php;
use Exception;
function codegen(?string $cache_dir, \mtgMetaInfo $meta, array $options = []) : string
{
$twig = get_twig();
if(!empty($cache_dir))
$twig->setCache($cache_dir);
$options['meta'] = $meta;
return $twig->render('codegen_bundle.twig', $options);
}
function get_twig(array $inc_path = [])
{
array_unshift($inc_path, __DIR__ . "/../tpl/");