Skip to content

Commit 9f95a7a

Browse files
committed
Merge branch '2.8' into 3.4
* 2.8: Fix Twig namespaces and update doc for twig runtime extension
2 parents e9d9835 + a84a2f0 commit 9f95a7a

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

components/form.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ to bootstrap or access Twig and add the :class:`Symfony\\Bridge\\Twig\\Extension
178178
use Symfony\Bridge\Twig\Extension\FormExtension;
179179
use Symfony\Component\Form\FormRenderer;
180180
use Symfony\Bridge\Twig\Form\TwigRendererEngine;
181+
use Twig\Environment;
182+
use Twig\Loader\FilesystemLoader;
183+
use Twig\RuntimeLoader\FactoryRuntimeLoader;
181184

182185
// the Twig file that holds all the default markup for rendering forms
183186
// this file comes with TwigBridge
@@ -191,7 +194,7 @@ to bootstrap or access Twig and add the :class:`Symfony\\Bridge\\Twig\\Extension
191194
// the path to your other templates
192195
$viewsDirectory = realpath(__DIR__.'/../views');
193196

194-
$twig = new Twig_Environment(new Twig_Loader_Filesystem(array(
197+
$twig = new Environment(new FilesystemLoader(array(
195198
$viewsDirectory,
196199
$vendorTwigBridgeDirectory.'/Resources/views/Form',
197200
)));
@@ -253,7 +256,7 @@ installed:
253256
$ composer require symfony/translation symfony/config
254257
255258
Next, add the :class:`Symfony\\Bridge\\Twig\\Extension\\TranslationExtension`
256-
to your ``Twig_Environment`` instance::
259+
to your ``Twig\\Environment`` instance::
257260

258261
use Symfony\Component\Form\Forms;
259262
use Symfony\Component\Translation\Translator;

reference/configuration/twig.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ called to determine the default escaping applied to the template.
8484
base_template_class
8585
~~~~~~~~~~~~~~~~~~~
8686

87-
**type**: ``string`` **default**: ``'Twig_Template'``
87+
**type**: ``string`` **default**: ``'Twig\\Template'``
8888

8989
Twig templates are compiled into PHP classes before using them to render
9090
contents. This option defines the base class from which all the template classes

templating/twig_extension.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,15 @@ Create a class that extends ``\Twig_Extension`` and fill in the logic::
2626
// src/AppBundle/Twig/AppExtension.php
2727
namespace AppBundle\Twig;
2828

29-
class AppExtension extends \Twig_Extension
29+
use Twig\Extension\AbstractExtension;
30+
use Twig\TwigFilter;
31+
32+
class AppExtension extends AbstractExtension
3033
{
3134
public function getFilters()
3235
{
3336
return array(
34-
new \Twig_SimpleFilter('price', array($this, 'priceFilter')),
37+
new TwigFilter('price', array($this, 'priceFilter')),
3538
);
3639
}
3740

0 commit comments

Comments
 (0)