diff --git a/CHANGELOG b/CHANGELOG index 525644254f..988be787c6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ * 2.0.0 (201X-XX-XX) + * removed the ability to register a global variable after the runtime or the extensions have been initialized * improved the performance of the filesystem loader * removed features that were deprecated in 1.x diff --git a/lib/Twig/Environment.php b/lib/Twig/Environment.php index 6f67970819..2b616c6b25 100644 --- a/lib/Twig/Environment.php +++ b/lib/Twig/Environment.php @@ -986,11 +986,9 @@ public function addGlobal($name, $value) $this->globals = $this->initGlobals(); } - /* This condition must be uncommented in Twig 2.0 if (!array_key_exists($name, $this->globals)) { throw new LogicException(sprintf('Unable to add global "%s" as the runtime or the extensions have already been initialized.', $name)); } - */ } if ($this->extensionInitialized || $this->runtimeInitialized) { diff --git a/test/Twig/Tests/EnvironmentTest.php b/test/Twig/Tests/EnvironmentTest.php index f8b238ff53..0bd6ff9ced 100644 --- a/test/Twig/Tests/EnvironmentTest.php +++ b/test/Twig/Tests/EnvironmentTest.php @@ -87,7 +87,6 @@ public function testGlobals() $template = $twig->loadTemplate('{{foo}}'); $this->assertEquals('bar', $template->render(array())); - /* to be uncomment in Twig 2.0 // globals cannot be added after runtime init $twig = new Twig_Environment(new Twig_Loader_String()); $twig->addGlobal('foo', 'foo'); @@ -134,7 +133,6 @@ public function testGlobals() } catch (LogicException $e) { $this->assertFalse(array_key_exists('bar', $twig->getGlobals())); } - */ } public function testExtensionsAreNotInitializedWhenRenderingACompiledTemplate()