8000 [TwigBridge] Fix upgrade/changelog notes by chalasr · Pull Request #21022 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[TwigBridge] Fix upgrade/changelog notes #21022

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions UPGRADE-3.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,36 @@ Serializer
TwigBridge
----------

* Deprecated the possibility to inject the Form Twig Renderer into the form
extension. Inject it into the `TwigRendererEngine` instead.
* Injecting the Form `TwigRenderer` into the `FormExtension` is deprecated and has no more effect.
Upgrade Twig to `^1.30`, inject the `Twig_Environment` into the `TwigRendererEngine` and load
the `TwigRenderer` using the `Twig_FactoryRuntimeLoader` instead.

Before:

```php
use Symfony\Bridge\Twig\Extension\FormExtension;
use Symfony\Bridge\Twig\Form\TwigRenderer;
use Symfony\Bridge\Twig\Form\TwigRendererEngine;

// ...
$rendererEngine = new TwigRendererEngine(array('form_div_layout.html.twig'));
$rendererEngine->setEnvironment($twig);
$twig->addExtension(new FormExtension(new TwigRenderer($rendererEngine, $csrfTokenManager)));
```

After:

```php
$rendererEngine = new TwigRendererEngine(array('form_div_layout.html.twig'), $twig);
$twig->addRuntimeLoader(new \Twig_FactoryRuntimeLoader(array(
TwigRenderer::class => function () use ($rendererEngine, $csrfTokenManager) {
return new TwigRenderer($rendererEngine, $csrfTokenManager);
},
)));
$twig->addExtension(new FormExtension());
```

* Deprecated the `TwigRendererEngineInterface` interface, it will be removed in 4.0.

Validator
---------
Expand Down
32 changes: 30 additions & 2 deletions UPGRADE-4.0.md
8000
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,36 @@ Translation
TwigBridge
----------

* The possibility to inject the Form Twig Renderer into the form extension
has been removed. Inject it into the `TwigRendererEngine` instead.
* Removed the possibility to inject the Form `TwigRenderer` into the `FormExtension`.
Upgrade Twig to `^1.30`, inject the `Twig_Environment` into the `TwigRendererEngine` and load
the `TwigRenderer` using the `Twig_FactoryRuntimeLoader` instead.

Before:

```php
use Symfony\Bridge\Twig\Extension\FormExtension;
use Symfony\Bridge\Twig\Form\TwigRenderer;
use Symfony\Bridge\Twig\Form\TwigRendererEngine;

// ...
$rendererEngine = new TwigRendererEngine(array('form_div_layout.html.twig'));
$rendererEngine->setEnvironment($twig);
$twig->addExtension(new FormExtension(new TwigRenderer($rendererEngine, $csrfTokenManager)));
```

After:

```php
$rendererEngine = new TwigRendererEngine(array('form_div_layout.html.twig'), $twig);
$twig->addRuntimeLoader(new \Twig_FactoryRuntimeLoader(array(
TwigRenderer::class => function () use ($rendererEngine, $csrfTokenManager) {
return new TwigRenderer($rendererEngine, $csrfTokenManager);
},
)));
$twig->addExtension(new FormExtension());
```

* Removed the `TwigRendererEngineInterface` interface.

Validator
---------
Expand Down
33 changes: 31 additions & 2 deletions src/Symfony/Bridge/Twig/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,37 @@ CHANGELOG
-----

* added `AppVariable::getToken()`
* Deprecated the possibility to inject the Form Twig Renderer into the form
extension. Inject it on TwigRendererEngine instead.
* Deprecated the possibility to inject the Form `TwigRenderer` into the `FormExtension`.
* [BC BREAK] Registering the `FormExtension` without configuring a runtime loader for the `TwigRenderer`
doesn't work anymore.

Before:

```php
use Symfony\Bridge\Twig\Extension\FormExtension;
use Symfony\Bridge\Twig\Form\TwigRenderer;
use Symfony\Bridge\Twig\Form\TwigRendererEngine;

// ...
$rendererEngine = new TwigRendererEngine(array('form_div_layout.html.twig'));
$rendererEngine->setEnvironment($twig);
$twig->addExtension(new FormExtension(new TwigRenderer($rendererEngine, $csrfTokenManager)));
```

After:

```php
// ...
$rendererEngine = new TwigRendererEngine(array('form_div_layout.html.twig'), $twig);
// require Twig 1.30+
$twig->addRuntimeLoader(new \Twig_FactoryRuntimeLoader(array(
TwigRenderer::class => function () use ($rendererEngine, $csrfTokenManager) {
return new TwigRenderer($rendererEngine, $csrfTokenManager);
},
)));
$twig->addExtension(new FormExtension());
```
* Deprecated the `TwigRendererEngineInterface` interface.

2.7.0
-----
Expand Down
0