Skip to content

Commit 9e183fc

Browse files
committed
Fixes #47: Alias classes only if they haven't been aliased before.
1 parent 0e045f7 commit 9e183fc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/bootstrap.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ function dcg_create_application() {
4141
// it is not possible to maintain the same \Twig\Environment sub-class for both
4242
// Twig versions.
4343
$twig_environment_class = sprintf('DrupalCodeGenerator\Twig\Twig%dEnvironment', $twig_major_version);
44-
class_alias($twig_environment_class, 'DrupalCodeGenerator\Twig\TwigEnvironment');
44+
if (!class_exists('DrupalCodeGenerator\Twig\TwigEnvironment')) {
45+
class_alias($twig_environment_class, 'DrupalCodeGenerator\Twig\TwigEnvironment');
46+
}
4547

4648
// Legacy TwigEnvironment class is still used in Drush.
47-
class_alias($twig_environment_class, 'DrupalCodeGenerator\TwigEnvironment');
49+
if (!class_exists('DrupalCodeGenerator\TwigEnvironment')) {
50+
class_alias($twig_environment_class, 'DrupalCodeGenerator\TwigEnvironment');
51+
}

0 commit comments

Comments
 (0)