Skip to content

Commit 1da9f06

Browse files
committed
Align Twig version with Drupal core
1 parent 0f9737b commit 1da9f06

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"ext-json": "*",
77
"symfony/console": "^3.4 || ^4.0",
88
"symfony/filesystem": "^2.7 || ^3.4 || ^4.0",
9-
"twig/twig": "^1.39 || ^2.10"
9+
"twig/twig": "^1.38.2 || ^2.10"
1010
},
1111
"bin": [
1212
"bin/dcg"

src/bootstrap.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,16 @@ function dcg_create_application() {
3030
return ApplicationFactory::create();
3131
}
3232

33+
// Determine major Twig version.
34+
// Twig_Environment::MAJOR_VERSION is not suitable here because of
35+
// https://github.com/twigphp/Twig/pull/2945
36+
// Use this workaround as drupal/drupal is locked on Twig 1.38.
37+
list($twig_major_version) = sscanf(Twig_Environment::VERSION, '%d.%d.%d');
38+
3339
// Twig_Environment::tokenize() signature has been changed in Twig 2, so that
3440
// it is not possible to maintain the same Twig_Environment sub-class for both
3541
// Twig versions.
36-
$twig_environment_class = sprintf('DrupalCodeGenerator\Twig\Twig%dEnvironment', Twig_Environment::MAJOR_VERSION);
42+
$twig_environment_class = sprintf('DrupalCodeGenerator\Twig\Twig%dEnvironment', $twig_major_version);
3743
class_alias($twig_environment_class, 'DrupalCodeGenerator\Twig\TwigEnvironment');
3844

3945
// Legacy TwigEnvironment class is still used in Drush.

0 commit comments

Comments
 (0)