Skip to content

Commit f994157

Browse files
committed
Make DCG 1 compatible with Drupal 9
1 parent 1963949 commit f994157

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
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.38.2 || ^2.10"
9+
"twig/twig": "^1.41 || ^2.12"
1010
},
1111
"bin": [
1212
"bin/dcg"

src/Helper/Renderer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace DrupalCodeGenerator\Helper;
44

55
use Symfony\Component\Console\Helper\Helper;
6-
use Twig_Environment;
6+
use Twig\Environment;
77

88
/**
99
* Output dumper form generators.
@@ -13,17 +13,17 @@ class Renderer extends Helper {
1313
/**
1414
* The twig environment.
1515
*
16-
* @var \Twig_Environment
16+
* @var \Twig\Environment
1717
*/
1818
protected $twig;
1919

2020
/**
2121
* Constructs a generator command.
2222
*
23-
* @param \Twig_Environment $twig
23+
* @param \Twig\Environment $twig
2424
* The twig environment.
2525
*/
26-
public function __construct(Twig_Environment $twig) {
26+
public function __construct(Environment $twig) {
2727
$this->twig = $twig;
2828
}
2929

src/bootstrap.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
use DrupalCodeGenerator\ApplicationFactory;
9+
use Twig\Environment;
910

1011
/**
1112
* DCG root.
@@ -31,13 +32,13 @@ function dcg_create_application() {
3132
}
3233

3334
// Determine major Twig version.
34-
// Twig_Environment::MAJOR_VERSION is not suitable here because of
35+
// \Twig\Environment::MAJOR_VERSION is not suitable here because of
3536
// https://github.com/twigphp/Twig/pull/2945
3637
// 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+
list($twig_major_version) = sscanf(Environment::VERSION, '%d.%d.%d');
3839

39-
// Twig_Environment::tokenize() signature has been changed in Twig 2, so that
40-
// it is not possible to maintain the same Twig_Environment sub-class for both
40+
// \Twig\Environment::tokenize() signature has been changed in Twig 2, so that
41+
// it is not possible to maintain the same \Twig\Environment sub-class for both
4142
// Twig versions.
4243
$twig_environment_class = sprintf('DrupalCodeGenerator\Twig\Twig%dEnvironment', $twig_major_version);
4344
class_alias($twig_environment_class, 'DrupalCodeGenerator\Twig\TwigEnvironment');

0 commit comments

Comments
 (0)