mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-17 04:46:49 +00:00
relaxed globals management to avoid a BC break (closes #965)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
* 1.12.1 (2013-XX-XX)
|
||||
|
||||
* relaxed globals management to avoid a BC break
|
||||
* added support for {{ some_string[:2] }}
|
||||
|
||||
* 1.12.0 (2013-01-08)
|
||||
|
||||
@@ -89,3 +89,10 @@ Interfaces
|
||||
* ``Twig_ParserInterface`` (use ``Twig_Parser`` instead)
|
||||
* ``Twig_ExistsLoaderInterface`` (merged with ``Twig_LoaderInterface``)
|
||||
* ``Twig_TemplateInterface`` (use ``Twig_Template`` instead)
|
||||
|
||||
Globals
|
||||
-------
|
||||
|
||||
* As of Twig 2.x, the ability to register a global variable after the runtime
|
||||
or the extensions have been initialized is not possible anymore (but
|
||||
changing the value of an already registered global is possible).
|
||||
|
||||
@@ -996,10 +996,12 @@ class Twig_Environment
|
||||
if (null === $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) {
|
||||
|
||||
@@ -71,6 +71,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
|
||||
$globals = $twig->getGlobals();
|
||||
$this->assertEquals('bar', $globals['foo']);
|
||||
|
||||
/* 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');
|
||||
@@ -117,6 +118,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase
|
||||
} catch (LogicException $e) {
|
||||
$this->assertFalse(array_key_exists('bar', $twig->getGlobals()));
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public function testExtensionsAreNotInitializedWhenRenderingACompiledTemplate()
|
||||
|
||||
Reference in New Issue
Block a user