Skip to content

Commit

Permalink
removed the ability to register a global variable after the runtime o…
Browse files Browse the repository at this point in the history
…r the extensions have been initialized
  • Loading branch information
fabpot committed Aug 5, 2013
1 parent 82733aa commit e4b22aa
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 4 deletions.
1 change: 1 addition & 0 deletions 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

Expand Down
2 changes: 0 additions & 2 deletions lib/Twig/Environment.php
Expand Up @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions test/Twig/Tests/EnvironmentTest.php
Expand Up @@ -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');
Expand Down Expand Up @@ -134,7 +133,6 @@ public function testGlobals()
} catch (LogicException $e) {
$this->assertFalse(array_key_exists('bar', $twig->getGlobals()));
}
*/
}

public function testExtensionsAreNotInitializedWhenRenderingACompiledTemplate()
Expand Down

0 comments on commit e4b22aa

Please sign in to comment.