Skip to content

Commit

Permalink
[TwigBridge] Fix upgrade/changelog notes
Browse files Browse the repository at this point in the history
  • Loading branch information
chalasr committed Dec 27, 2016
1 parent 2de9dd1 commit a7ebe9c
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 6 deletions.
32 changes: 30 additions & 2 deletions UPGRADE-3.2.md
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
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
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 comments on commit a7ebe9c

Please sign in to comment.