Skip to content

Commit aaeb15f

Browse files
committed
Merge branch '3.4' into 4.0
* 3.4: Fixed more Twig class namespaces Fix Twig namespaces and update doc for twig runtime extension Popper js is required Proposed a reword abut the "lazy" explanation Tell about ServiceLocatorTagPass::register() [Cache] Add note about lazy=true option
2 parents 5ce3ca8 + ee8f1d0 commit aaeb15f

File tree

9 files changed

+44
-17
lines changed

9 files changed

+44
-17
lines changed

components/cache/adapters/redis_adapter.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ array of ``key => value`` pairs representing option names and their respective v
9696

9797
// associative array of configuration options
9898
array(
99+
'lazy' => false,
99100
'persistent' => 0,
100101
'persistent_id' => null,
101102
'timeout' => 30,
@@ -113,6 +114,11 @@ Available Options
113114
If none is specified, it will return ``\Redis`` if the ``redis`` extension is
114115
available, and ``\Predis\Client`` otherwise.
115116

117+
``lazy`` (type: ``bool``, default: ``false``)
118+
Enables or disables lazy connections to the backend. It's ``false`` by
119+
default when using this as a stand-alone component and ``true`` by default
120+
when using it inside a Symfony application.
121+
116122
``persistent`` (type: ``int``, default: ``0``)
117123
Enables or disables use of persistent connections. A value of ``0`` disables persistent
118124
connections, and a value of ``1`` enables them.

components/form.rst

Lines changed: 7 additions & 4 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,12 +194,12 @@ 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
)));
198201
$formEngine = new TwigRendererEngine(array($defaultFormTheme), $twig);
199-
$twig->addRuntimeLoader(new \Twig_FactoryRuntimeLoader(array(
202+
$twig->addRuntimeLoader(new FactoryRuntimeLoader(array(
200203
FormRenderer::class => function () use ($formEngine, $csrfManager) {
201204
return new FormRenderer($formEngine, $csrfManager);
202205
},
@@ -213,7 +216,7 @@ to bootstrap or access Twig and add the :class:`Symfony\\Bridge\\Twig\\Extension
213216
->getFormFactory();
214217

215218
.. versionadded:: 1.30
216-
The ``Twig_FactoryRuntimeLoader`` was introduced in Twig 1.30.
219+
The ``Twig\\RuntimeLoader\\FactoryRuntimeLoader`` was introduced in Twig 1.30.
217220

218221
The exact details of your `Twig Configuration`_ will vary, but the goal is
219222
always to add the :class:`Symfony\\Bridge\\Twig\\Extension\\FormExtension`
@@ -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;

controller/service.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,13 @@ service and use it directly::
102102
namespace App\Controller;
103103

104104
use Symfony\Component\HttpFoundation\Response;
105+
use Twig\Environment;
105106

106107
class HelloController
107108
{
108109
private $twig;
109110

110-
public function __construct(\Twig_Environment $twig)
111+
public function __construct(Environment $twig)
111112
{
112113
$this->twig = $twig;
113114
}

frontend/encore/bootstrap.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,12 @@ file into ``global.scss``. You can even customize the Bootstrap variables first!
3737
Importing Bootstrap JavaScript
3838
------------------------------
3939

40-
Bootstrap JavaScript requires jQuery, so make sure you have this installed:
40+
Bootstrap JavaScript requires jQuery and Popper.js, so make sure you have this installed:
4141

4242
.. code-block:: terminal
4343
4444
$ yarn add jquery --dev
45+
$ yarn add popper.js --dev
4546
4647
Next, make sure to call ``.autoProvidejQuery()`` in your ``webpack.config.js`` file:
4748

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

service_container.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ But, with ``autoconfigure: true``, you don't need the tag. In fact, if you're us
728728
the :ref:`default services.yaml config <service-container-services-load-example>`,
729729
you don't need to do *anything*: the service will be automatically loaded. Then,
730730
``autoconfigure`` will add the ``twig.extension`` tag *for* you, because your class
731-
implements ``Twig_ExtensionInterface``. And thanks to ``autowire``, you can even add
731+
implements ``Twig\\Extension\\ExtensionInterface``. And thanks to ``autowire``, you can even add
732732
constructor arguments without any configuration.
733733

734734
.. _container-public:

service_container/service_subscribers_locators.rst

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,24 @@ Now you can use the service locator by injecting it in any other service:
349349
->setArguments(array(new Reference('app.command_handler_locator')))
350350
;
351351
352-
.. tip::
352+
In :doc:`compiler passes </service_container/compiler_passes>` it's recommended
353+
to use the :method:`Symfony\\Component\\DependencyInjection\\Compiler\\ServiceLocatorTagPass::register`
354+
method to create the service locators. This will save you some boilerplate and
355+
will share identical locators amongst all the services referencing them::
356+
357+
use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
358+
use Symfony\Component\DependencyInjection\ContainerBuilder;
359+
360+
public function process(ContainerBuilder $container)
361+
{
362+
//...
363+
364+
$locateableServices = array(
365+
//...
366+
'logger' => new Reference('logger'),
367+
);
353368

354-
If the service locator is not intended to be used by multiple services, it's
355-
better to create and inject it as an anonymous service.
369+
$myService->addArgument(ServiceLocatorTagPass::register($locateableServices));
370+
}
356371

357372
.. _`Command pattern`: https://en.wikipedia.org/wiki/Command_pattern

service_container/tags.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ Autoconfiguring Tags
6060

6161
If you enable :ref:`autoconfigure <services-autoconfigure>`, then some tags are
6262
automatically applied for you. That's true for the ``twig.extension`` tag: the
63-
container sees that your class extends ``Twig_Extension`` (or more accurately,
64-
that it implements ``Twig_ExtensionInterface``) and adds the tag for you.
63+
container sees that your class extends ``AbstractExtension`` (or more accurately,
64+
that it implements ``ExtensionInterface``) and adds the tag for you.
6565

6666
.. tip::
6767

templating/twig_extension.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ money:
3232
{# pass in the 3 optional arguments #}
3333
{{ product.price|price(2, ',', '.') }}
3434
35-
Create a class that extends the ``AbstractExtension`` class defined by Twig and
36-
fill in the logic::
35+
Create a class that extends ``AbstractExtension`` and fill in the logic::
3736

3837
// src/Twig/AppExtension.php
3938
namespace App\Twig;
@@ -98,14 +97,16 @@ callable defined in ``getFilters()``::
9897
namespace App\Twig;
9998

10099
use App\Twig\AppRuntime;
100+
use Twig\Extension\AbstractExtension;
101+
use Twig\TwigFilter;
101102

102-
class AppExtension extends \Twig_Extension
103+
class AppExtension extends AbstractExtension
103104
{
104105
public function getFilters()
105106
{
106107
return array(
107108
// the logic of this filter is now implemented in a different class
108-
new \Twig_SimpleFilter('price', array(AppRuntime::class, 'priceFilter')),
109+
new TwigFilter('price', array(AppRuntime::class, 'priceFilter')),
109110
);
110111
}
111112
}

0 commit comments

Comments
 (0)