Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2d01b80

Browse files
committed
fixed circular reference in Twig Form integration
1 parent4b5e412 commit2d01b80

File tree

11 files changed

+63
-43
lines changed

11 files changed

+63
-43
lines changed

‎src/Symfony/Bridge/Twig/CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
3.2.0
5+
-----
6+
7+
* Deprecated the possibility to inject the Form Twig Renderer into the form
8+
extension. Inject it on TwigRendererEngine instead.
9+
410
2.7.0
511
-----
612

‎src/Symfony/Bridge/Twig/Extension/FormExtension.php‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,26 @@
2323
*/
2424
class FormExtensionextends \Twig_Extensionimplements \Twig_Extension_InitRuntimeInterface
2525
{
26-
publicfunction__construct(TwigRendererInterface$renderer)
26+
private$renderer;
27+
28+
publicfunction__construct(TwigRendererInterface$renderer =null)
2729
{
30+
if (null !==$this->renderer) {
31+
@trigger_error(sprintf('Passing a Twig Form Renderer to the "%s" constructor is deprecated since version 3.2 and won\'t be possible in 4.0. Pass the Twig_Environment to the TwigRendererEngine constructor instead.',static::class),E_USER_DEPRECATED);
32+
}
2833
$this->renderer =$renderer;
2934
}
3035

3136
/**
3237
* {@inheritdoc}
38+
*
39+
* To be removed in 4.0
3340
*/
3441
publicfunctioninitRuntime(\Twig_Environment$environment)
3542
{
36-
$this->renderer->setEnvironment($environment);
43+
if (null !==$this->renderer) {
44+
$this->renderer->setEnvironment($environment);
45+
}
3746
}
3847

3948
/**

‎src/Symfony/Bridge/Twig/Form/TwigRendererEngine.php‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ class TwigRendererEngine extends AbstractRendererEngine implements TwigRendererE
2929
*/
3030
private$template;
3131

32+
publicfunction__construct(array$defaultThemes =array(),\Twig_Environment$environment =null)
33+
{
34+
if (null ===$environment) {
35+
@trigger_error(sprintf('Not passing a Twig Environment as the second argument for "%s" constructor is deprecated since version 3.2 and won\'t be possible in 4.0.',static::class),E_USER_DEPRECATED);
36+
}
37+
38+
parent::__construct($defaultThemes);
39+
$this->environment =$environment;
40+
}
41+
3242
/**
3343
* {@inheritdoc}
3444
*/

‎src/Symfony/Bridge/Twig/Form/TwigRendererEngineInterface.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
/**
1717
* @author Bernhard Schussek <bschussek@gmail.com>
18+
*
19+
* @deprecated Deprecated since version 3.2, to be removed in 4.0.
1820
*/
1921
interface TwigRendererEngineInterfaceextends FormRendererEngineInterface
2022
{

‎src/Symfony/Bridge/Twig/Form/TwigRendererInterface.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
/**
1717
* @author Bernhard Schussek <bschussek@gmail.com>
18+
*
19+
* @deprecated Deprecated since version 3.2, to be removed in 4.0.
1820
*/
1921
interface TwigRendererInterfaceextends FormRendererInterface
2022
{

‎src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,20 @@ protected function setUp()
3434
{
3535
parent::setUp();
3636

37-
$rendererEngine =newTwigRendererEngine(array(
38-
'bootstrap_3_horizontal_layout.html.twig',
39-
'custom_widgets.html.twig',
40-
));
41-
$this->renderer =newTwigRenderer($rendererEngine,$this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'));
42-
$extension =newFormExtension($this->renderer);
43-
4437
$loader =newStubFilesystemLoader(array(
4538
__DIR__.'/../../Resources/views/Form',
4639
__DIR__.'/Fixtures/templates/form',
4740
));
4841

4942
$environment =new \Twig_Environment($loader,array('strict_variables' =>true));
5043
$environment->addExtension(newTranslationExtension(newStubTranslator()));
51-
$environment->addExtension($extension);
52-
$extension->initRuntime($environment);
44+
$environment->addExtension(newFormExtension());
45+
46+
$rendererEngine =newTwigRendererEngine(array(
47+
'bootstrap_3_horizontal_layout.html.twig',
48+
'custom_widgets.html.twig',
49+
),$environment);
50+
$this->renderer =newTwigRenderer($rendererEngine,$this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'));
5351
$this->registerTwigRuntimeLoader($environment,$this->renderer);
5452
}
5553

‎src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,20 @@ protected function setUp()
3030
{
3131
parent::setUp();
3232

33-
$rendererEngine =newTwigRendererEngine(array(
34-
'bootstrap_3_layout.html.twig',
35-
'custom_widgets.html.twig',
36-
));
37-
$this->renderer =newTwigRenderer($rendererEngine,$this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'));
38-
$extension =newFormExtension($this->renderer);
39-
4033
$loader =newStubFilesystemLoader(array(
4134
__DIR__.'/../../Resources/views/Form',
4235
__DIR__.'/Fixtures/templates/form',
4336
));
4437

4538
$environment =new \Twig_Environment($loader,array('strict_variables' =>true));
4639
$environment->addExtension(newTranslationExtension(newStubTranslator()));
47-
$environment->addExtension($extension);
48-
$extension->initRuntime($environment);
40+
$environment->addExtension(newFormExtension());
41+
42+
$rendererEngine =newTwigRendererEngine(array(
43+
'bootstrap_3_layout.html.twig',
44+
'custom_widgets.html.twig',
45+
),$environment);
46+
$this->renderer =newTwigRenderer($rendererEngine,$this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'));
4947
$this->registerTwigRuntimeLoader($environment,$this->renderer);
5048
}
5149

‎src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@ protected function setUp()
3131
{
3232
parent::setUp();
3333

34-
$rendererEngine =newTwigRendererEngine(array(
35-
'form_div_layout.html.twig',
36-
'custom_widgets.html.twig',
37-
));
38-
$this->renderer =newTwigRenderer($rendererEngine,$this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'));
39-
$extension =newFormExtension($this->renderer);
40-
4134
$loader =newStubFilesystemLoader(array(
4235
__DIR__.'/../../Resources/views/Form',
4336
__DIR__.'/Fixtures/templates/form',
@@ -48,8 +41,13 @@ protected function setUp()
4841
$environment->addGlobal('global','');
4942
// the value can be any template that exists
5043
$environment->addGlobal('dynamic_template_name','child_label');
51-
$environment->addExtension($extension);
52-
$extension->initRuntime($environment);
44+
$environment->addExtension(newFormExtension());
45+
46+
$rendererEngine =newTwigRendererEngine(array(
47+
'form_div_layout.html.twig',
48+
'custom_widgets.html.twig',
49+
),$environment);
50+
$this->renderer =newTwigRenderer($rendererEngine,$this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'));
5351
$this->registerTwigRuntimeLoader($environment,$this->renderer);
5452
}
5553

‎src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ protected function setUp()
3030
{
3131
parent::setUp();
3232

33-
$rendererEngine =newTwigRendererEngine(array(
34-
'form_table_layout.html.twig',
35-
'custom_widgets.html.twig',
36-
));
37-
$this->renderer =newTwigRenderer($rendererEngine,$this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'));
38-
$extension =newFormExtension($this->renderer);
39-
4033
$loader =newStubFilesystemLoader(array(
4134
__DIR__.'/../../Resources/views/Form',
4235
__DIR__.'/Fixtures/templates/form',
@@ -45,8 +38,13 @@ protected function setUp()
4538
$environment =new \Twig_Environment($loader,array('strict_variables' =>true));
4639
$environment->addExtension(newTranslationExtension(newStubTranslator()));
4740
$environment->addGlobal('global','');
48-
$environment->addExtension($extension);
49-
$extension->initRuntime($environment);
41+
$environment->addExtension(newFormExtension());
42+
43+
$rendererEngine =newTwigRendererEngine(array(
44+
'form_table_layout.html.twig',
45+
'custom_widgets.html.twig',
46+
),$environment);
47+
$this->renderer =newTwigRenderer($rendererEngine,$this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'));
5048
$this->registerTwigRuntimeLoader($environment,$this->renderer);
5149
}
5250

‎src/Symfony/Bundle/SecurityBundle/composer.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
"symfony/http-foundation":"~2.8|~3.0",
3333
"symfony/security-acl":"~2.8|~3.0",
3434
"symfony/templating":"~2.8|~3.0",
35-
"symfony/twig-bundle":"~2.8|~3.0",
36-
"symfony/twig-bridge":"~2.8|~3.0",
35+
"symfony/twig-bundle":"~3.2",
36+
"symfony/twig-bridge":"~3.2",
3737
"symfony/process":"~2.8|~3.0",
3838
"symfony/validator":"~2.8|~3.0",
3939
"symfony/var-dumper":"~3.2",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp