Skip to content

Commit 49f4ce1

Browse files
committed
Check Twig environment on demand. Fix #46.
1 parent e2a2990 commit 49f4ce1

File tree

2 files changed

+3
-19
lines changed

2 files changed

+3
-19
lines changed

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
"symfony/filesystem": "^2.7 || ^3.4 || ^4.0",
99
"twig/twig": "^1.41 || ^2.12"
1010
},
11+
"conflict": {
12+
"drush/drush": "< 10.3.2"
13+
},
1114
"bin": [
1215
"bin/dcg"
1316
],

src/bootstrap.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,3 @@ function dcg_get_twig_environment($loader) {
5151
}
5252
return $environment;
5353
}
54-
55-
// Determine major Twig version.
56-
// \Twig\Environment::MAJOR_VERSION is not suitable here because of
57-
// https://github.com/twigphp/Twig/pull/2945
58-
// Use this workaround as drupal/drupal is locked on Twig 1.38.
59-
list($twig_major_version) = sscanf(Environment::VERSION, '%d.%d.%d');
60-
61-
// \Twig\Environment::tokenize() signature has been changed in Twig 2, so that
62-
// it is not possible to maintain the same \Twig\Environment sub-class for both
63-
// Twig versions.
64-
$twig_environment_class = sprintf('DrupalCodeGenerator\Twig\Twig%dEnvironment', $twig_major_version);
65-
if (!class_exists('DrupalCodeGenerator\Twig\TwigEnvironment')) {
66-
class_alias($twig_environment_class, 'DrupalCodeGenerator\Twig\TwigEnvironment');
67-
}
68-
69-
// Legacy TwigEnvironment class is still used in Drush.
70-
if (!class_exists('DrupalCodeGenerator\TwigEnvironment')) {
71-
class_alias($twig_environment_class, 'DrupalCodeGenerator\TwigEnvironment');
72-
}

0 commit comments

Comments
 (0)