Skip to content

Commit 59db8d8

Browse files
committed
Merge branch '4.1'
* 4.1: Fixed more Twig class namespaces Fix Twig namespaces and update doc for twig runtime extension Popper js is required ChoiceValidator : remove 'strict' option Proposed a reword abut the "lazy" explanation Tell about ServiceLocatorTagPass::register() [Cache] Add note about lazy=true option
2 parents 4ea4efe + 2473c21 commit 59db8d8

File tree

10 files changed

+44
-27
lines changed

10 files changed

+44
-27
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
@@ -97,12 +97,13 @@ service and use it directly::
9797
namespace App\Controller;
9898

9999
use Symfony\Component\HttpFoundation\Response;
100+
use Twig\Environment;
100101

101102
class HelloController
102103
{
103104
private $twig;
104105

105-
public function __construct(\Twig_Environment $twig)
106+
public function __construct(Environment $twig)
106107
{
107108
$this->twig = $twig;
108109
}

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

reference/constraints/Choice.rst

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ an array of items is one of those valid choices.
1717
| | - `multipleMessage`_ |
1818
| | - `minMessage`_ |
1919
| | - `maxMessage`_ |
20-
| | - `strict`_ |
2120
| | - `payload`_ |
2221
+----------------+----------------------------------------------------------------------+
2322
| Class | :class:`Symfony\\Component\\Validator\\Constraints\\Choice` |
@@ -360,13 +359,4 @@ maxMessage
360359
This is the validation error message that's displayed when the user chooses
361360
too many options per the `max`_ option.
362361

363-
strict
364-
~~~~~~
365-
366-
**type**: ``boolean`` **default**: ``true``
367-
368-
The validator will also check the type of the input value. Specifically,
369-
this value is passed to as the third argument to the PHP :phpfunction:`in_array`
370-
method when checking to see if a value is in the valid choices array.
371-
372362
.. include:: /reference/constraints/_payload-option.rst.inc

service_container.rst

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

772772
.. _container-public:

service_container/service_subscribers_locators.rst

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,10 +362,25 @@ Now you can use the service locator by injecting it in any other service:
362362
->setArguments(array(new Reference('app.command_handler_locator')))
363363
;
364364
365-
.. tip::
365+
In :doc:`compiler passes </service_container/compiler_passes>` it's recommended
366+
to use the :method:`Symfony\\Component\\DependencyInjection\\Compiler\\ServiceLocatorTagPass::register`
367+
method to create the service locators. This will save you some boilerplate and
368+
will share identical locators amongst all the services referencing them::
369+
370+
use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
371+
use Symfony\Component\DependencyInjection\ContainerBuilder;
372+
373+
public function process(ContainerBuilder $container)
374+
{
375+
//...
376+
377+
$locateableServices = array(
378+
//...
379+
'logger' => new Reference('logger'),
380+
);
366381

367-
If the service locator is not intended to be used by multiple services, it's
368-
better to create and inject it as an anonymous service.
382+
$myService->addArgument(ServiceLocatorTagPass::register($locateableServices));
383+
}
369384

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

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)