From 0c33d99506ec9ac710d00299c0a828f87608d178 Mon Sep 17 00:00:00 2001 From: odan Date: Sun, 25 Aug 2019 23:16:31 +0200 Subject: [PATCH] Add twig to php compiler #2 --- bin/parse-twig.php | 23 +++-------------------- composer.json | 2 +- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/bin/parse-twig.php b/bin/parse-twig.php index f77257b0a..202322c67 100644 --- a/bin/parse-twig.php +++ b/bin/parse-twig.php @@ -17,6 +17,7 @@ // Translate the text and save the file. // +use Odan\Twig\TwigCompiler; use Slim\App; use Twig\Environment as Twig; @@ -29,23 +30,5 @@ $twig = $app->getContainer()->get(Twig::class); -$twig->disableDebug(); - -// Force auto-reload to always have the latest version of the template -$twig->enableAutoReload(); - -// The Twig cache must be enabled -$twig->setCache($cachePath); - -// Iterate over all your templates -$directory = new RecursiveDirectoryIterator($templatePath, FilesystemIterator::SKIP_DOTS); - -foreach (new RecursiveIteratorIterator($directory, RecursiveIteratorIterator::SELF_FIRST) as $file) { - /** @var SplFileInfo $file */ - if ($file->isFile() && $file->getExtension() === 'twig') { - $templateName = substr($file->getPathname(), strlen($templatePath) + 1); - $templateName = str_replace('\\', '/', $templateName); - echo sprintf("Parsing: %s\n", $templateName); - $twig->loadTemplate($templateName); - } -} +$compiler = new TwigCompiler($twig, $cachePath); +$compiler->compile(); diff --git a/composer.json b/composer.json index 33b4d4493..c3cca271d 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "nyholm/psr7": "^1.2", "nyholm/psr7-server": "^0.3.0", "odan/twig-assets": "^2.1", - "odan/twig-translation": "^1.2", + "odan/twig-translation": "^1.2.1", "psr/log": "^1.1", "selective/basepath": "^0.1.0", "slim/slim": "^4.1",