Skip to content

Commit de8b1e7

Browse files
Phenix789javiereguiluz
authored andcommitted
Fix Twig namespaces and update doc for twig runtime extension
1 parent b569015 commit de8b1e7

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

components/form.rst

+5-2
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ to bootstrap or access Twig and add the :class:`Symfony\\Bridge\\Twig\\Extension
181181
use Symfony\Bridge\Twig\Extension\FormExtension;
182182
use Symfony\Bridge\Twig\Form\TwigRenderer;
183183
use Symfony\Bridge\Twig\Form\TwigRendererEngine;
184+
use Twig\Environment;
185+
use Twig\Loader\FilesystemLoader;
186+
use Twig\RuntimeLoader\FactoryRuntimeLoader;
184187

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

197-
$twig = new Twig_Environment(new Twig_Loader_Filesystem(array(
200+
$twig = new Environment(new FilesystemLoader(array(
198201
$viewsDirectory,
199202
$vendorTwigBridgeDirectory.'/Resources/views/Form',
200203
)));
@@ -251,7 +254,7 @@ installed:
251254
$ composer require symfony/translation symfony/config
252255
253256
Next, add the :class:`Symfony\\Bridge\\Twig\\Extension\\TranslationExtension`
254-
to your ``Twig_Environment`` instance::
257+
to your ``Twig\\Environment`` instance::
255258

256259
use Symfony\Component\Form\Forms;
257260
use Symfony\Component\Translation\Translator;

reference/configuration/twig.rst

+1-1
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

+5-2
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,15 @@ As an example you'll create a price filter to format a given number into price::
3333
// src/AppBundle/Twig/AppExtension.php
3434
namespace AppBundle\Twig;
3535

36-
class AppExtension extends \Twig_Extension
36+
use Twig\Extension\AbstractExtension;
37+
use Twig\TwigFilter;
38+
39+
class AppExtension extends AbstractExtension
3740
{
3841
public function getFilters()
3942
{
4043
return array(
41-
new \Twig_SimpleFilter('price', array($this, 'priceFilter')),
44+
new TwigFilter('price', array($this, 'priceFilter')),
4245
);
4346
}
4447

0 commit comments

Comments
 (0)