Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 73cac76

Browse files
committed
Merge branch '3.4'
* 3.4: (48 commits) [#8192] use path() in PHP templates Reworded the article about form login redirects Update Flex documentation with latest structure Explained the edge-case where the use_referer option doesn't work [#7572] fix wording [#7585] remove trailing whitespaces [#7585] minor rewording Fixed a typo Fixed a typo Update parent_services for tip consistency [#7685] use the method role Minor change Updating doc to specify priority of default normalizer [#7767] remove trailing space [#7767] replace "options" with "entry_options" [#7767] minor rewording [#8047] add inline code comment Fixed the issue in a different way Jquery datePicker syntax update Fix framework instantiation in event-dispatcher ...
2 parents b5e0c9e + 172e788 commit 73cac76

23 files changed

+476
-131
lines changed

components/http_foundation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ exist::
153153
// returns 'baz'
154154

155155
When PHP imports the request query, it handles request parameters like
156-
``foo[bar]=bar`` in a special way as it creates an array. So you can get the
156+
``foo[bar]=baz`` in a special way as it creates an array. So you can get the
157157
``foo`` parameter and you will get back an array with a ``bar`` element::
158158

159159
// the query string is '?foo[bar]=baz'

components/stopwatch.rst

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,24 @@ microtime by yourself. Instead, use the simple
3434
$event = $stopwatch->stop('eventName');
3535

3636
The :class:`Symfony\\Component\\Stopwatch\\StopwatchEvent` object can be retrieved
37-
from the :method:`Symfony\\Component\\Stopwatch\\Stopwatch::start`,
38-
:method:`Symfony\\Component\\Stopwatch\\Stopwatch::stop`,
39-
:method:`Symfony\\Component\\Stopwatch\\Stopwatch::lap` and
40-
:method:`Symfony\\Component\\Stopwatch\\Stopwatch::getEvent` methods.
37+
from the :method:`Symfony\\Component\\Stopwatch\\Stopwatch::start`,
38+
:method:`Symfony\\Component\\Stopwatch\\Stopwatch::stop`,
39+
:method:`Symfony\\Component\\Stopwatch\\Stopwatch::lap` and
40+
:method:`Symfony\\Component\\Stopwatch\\Stopwatch::getEvent` methods.
4141
The latter should be used when you need to retrieve the duration of an event
4242
while it is still running.
4343

44+
.. tip::
45+
46+
By default, the stopwatch truncates any sub-millisecond time measure to ``0``,
47+
so you can't measure microseconds or nanoseconds. If you need more precision,
48+
pass ``true`` to the ``Stopwatch`` class constructor to enable full precision::
49+
50+
$stopwatch = new Stopwatch(true);
51+
52+
.. versionadded:: 3.4
53+
Full precision support was introduced in Symfony 3.4.
54+
4455
The stopwatch can be reset to its original state at any given time with the
4556
:method:`Symfony\\Component\\Stopwatch\\Stopwatch::reset` method, which deletes
4657
all the data measured so far.

components/validator.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ characters long::
4646
}
4747
}
4848

49+
The validator returns the list of violations.
50+
4951
Retrieving a Validator Instance
5052
-------------------------------
5153

components/workflow.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ these statuses are called **places**. You can define the workflow like this::
4444
use Symfony\Component\Workflow\Workflow;
4545
use Symfony\Component\Workflow\MarkingStore\SingleStateMarkingStore;
4646

47-
$definition = new DefinitionBuilder();
48-
$definition->addPlaces(['draft', 'review', 'rejected', 'published'])
47+
$definitionBuilder = new DefinitionBuilder();
48+
$definition = $definitionBuilder->addPlaces(['draft', 'review', 'rejected', 'published'])
4949
// Transitions are defined with a unique name, an origin place and a destination place
5050
->addTransition(new Transition('to_review', 'draft', 'review'))
5151
->addTransition(new Transition('publish', 'review', 'published'))

controller/service.rst

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,15 @@ syntax:
2424

2525
.. configuration-block::
2626

27-
.. code-block:: yaml
28-
29-
# app/config/routing.yml
30-
hello:
31-
path: /hello
32-
defaults: { _controller: app.hello_controller:indexAction }
33-
3427
.. code-block:: php-annotations
3528
36-
# src/AppBundle/Controller/HelloController.php
29+
// src/AppBundle/Controller/HelloController.php
3730
3831
// You need to use Sensio's annotation to specify a service id
3932
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
4033
// ...
34+
35+
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
4136
4237
/**
4338
* @Route(service="app.hello_controller")
@@ -47,6 +42,13 @@ syntax:
4742
// ...
4843
}
4944
45+
.. code-block:: yaml
46+
47+
# app/config/routing.yml
48+
hello:
49+
path: /hello
50+
defaults: { _controller: app.hello_controller:indexAction }
51+
5052
.. code-block:: xml
5153
5254
<!-- app/config/routing.xml -->

create_framework/event_dispatcher.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,11 @@ the registration of a listener for the ``response`` event::
138138

139139
$response->setContent($response->getContent().'GA CODE');
140140
});
141+
142+
$controllerResolver = new ControllerResolver();
143+
$argumentResolver = new ArgumentResolver();
141144

142-
$framework = new Simplex\Framework($dispatcher, $matcher, $resolver);
145+
$framework = new Simplex\Framework($dispatcher, $matcher, $controllerResolver, $argumentResolver);
143146
$response = $framework->handle($request);
144147

145148
$response->send();

forms.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -562,10 +562,10 @@ the correct values of a number of field options.
562562
field ``nullable``). This is very useful, as your client-side validation will
563563
automatically match your validation rules.
564564

565-
``max_length``
566-
If the field is some sort of text field, then the ``max_length`` option can be
567-
guessed from the validation constraints (if ``Length`` or ``Range`` is used) or
568-
from the Doctrine metadata (via the field's length).
565+
``maxlength``
566+
If the field is some sort of text field, then the ``maxlength`` option attribute
567+
can be guessed from the validation constraints (if ``Length`` or ``Range`` is used)
568+
or from the Doctrine metadata (via the field's length).
569569

570570
.. caution::
571571

frontend/encore/babel.rst

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,39 @@ Need to extend the Babel configuration further? The easiest way is via
1919
// first, install any presets you want to use (e.g. yarn add babel-preset-es2017)
2020
// then, modify the default Babel configuration
2121
.configureBabel(function(babelConfig) {
22+
// add additional presets
2223
babelConfig.presets.push('es2017');
24+
25+
// no plugins are added by default, but you can add some
26+
// babelConfig.plugins = ['styled-jsx/babel'];
2327
})
2428
;
2529
26-
You can also create a standard ``.babelrc`` file at the root of your project.
27-
Just make sure to configure it with all the presets you need: as soon as a
28-
``.babelrc`` is present, Encore can no longer add *any* Babel configuration for
29-
you!
30+
Creating a .babelrc File
31+
------------------------
32+
33+
Instead of calling ``configureBabel()``, you could create a ``.babelrc`` file
34+
at the root of your project. This is a more "standard" way of configuring
35+
Babel, but it has a downside: as soon as a ``.babelrc`` file is present,
36+
**Encore can no longer add any Babel configuration for you**. For example,
37+
if you call ``Encore.enableReactPreset()``, the ``react`` preset will *not*
38+
automatically be added to Babel: you must add it yourself in ``.babelrc``.
39+
40+
An example ``.babelrc`` file might look like this:
41+
42+
.. code-block:: json
43+
44+
{
45+
presets: [
46+
['env', {
47+
modules: false,
48+
targets: {
49+
browsers: '> 1%',
50+
uglify: true
51+
},
52+
useBuiltIns: true
53+
}]
54+
]
55+
}
3056
3157
.. _`Babel`: http://babeljs.io/

page_creation.rst

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,7 @@ random) number and prints it. To do that, create a "Controller class" and a
6868
Before diving into this, test it out! If you are using PHP's internal web server
6969
go to:
7070

71-
http://localhost:8000/app_dev.php/lucky/number
72-
73-
.. tip::
74-
75-
If you're using the built-in PHP web-server, you can omit the ``app_dev.php``
76-
part of the URL.
71+
http://localhost:8000/lucky/number
7772

7873
If you see a lucky number being printed back to you, congratulations! But before
7974
you run off to play the lottery, check out how this works. Remember the two steps

reference/configuration/security.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,14 @@ use_referer
416416
**type**: ``boolean`` **default**: ``false``
417417

418418
If ``true``, the user is redirected to the value stored in the ``HTTP_REFERER``
419-
header when no previous URL was stored in the session.
419+
header when no previous URL was stored in the session. If the referrer URL is
420+
the same as the one generated with the ``login_path`` route, the user is
421+
redirected to the ``default_target_path`` to avoid a redirection loop.
422+
423+
.. note::
424+
425+
For historical reasons, and to match the misspelling of the HTTP standard,
426+
the option is called ``use_referer`` instead of ``use_referrer``.
420427

421428
.. _reference-security-pbkdf2:
422429

reference/dic_tags.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,10 @@ and :class:`Symfony\\Component\\Serializer\\Normalizer\\DenormalizerInterface`.
940940

941941
For more details, see :doc:`/serializer`.
942942

943+
The priorities of the default normalizers can be found in the
944+
:method:`Symfony\\Bundle\\FrameworkBundle\\DependencyInjection\\FrameworkExtension::registerSerializerConfiguration`
945+
method.
946+
943947
swiftmailer.default.plugin
944948
--------------------------
945949

reference/forms/types/collection.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,15 @@ form you have to set this option to true. However, existing collection entries
277277
will only be deleted if you have the allow_delete_ option enabled. Otherwise
278278
the empty values will be kept.
279279

280+
.. caution::
281+
282+
The ``delete_empty`` option only removes items when the normalized value is
283+
``null``. If the nested `type`_ is a compound form type, you must either set
284+
the ``required`` option to ``false`` or set the ``empty_data`` option to
285+
``null``. Both of these options can be set inside `entry_options`_. Read
286+
about the :ref:`form's empty_data option <reference-form-option-empty-data>`
287+
to learn why this is necessary.
288+
280289
entry_options
281290
~~~~~~~~~~~~~
282291

reference/forms/types/date.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,14 @@ make the following changes::
101101
'attr' => ['class' => 'js-datepicker'],
102102
));
103103

104-
Assuming you're using jQuery, you can initialize the date picker via:
104+
Then, add the following JavaScript code in your template to initialize the date
105+
picker:
105106

106107
.. code-block:: html
107108

108109
<script>
109110
$(document).ready(function() {
111+
// configure the bootstrap datepicker
110112
$('.js-datepicker').datepicker({
111113
format: 'yyyy-mm-dd'
112114
});

reference/forms/types/form.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ option on the form.
7171

7272
.. include:: /reference/forms/types/options/data_class.rst.inc
7373

74+
.. _reference-form-option-empty-data:
75+
7476
.. include:: /reference/forms/types/options/empty_data.rst.inc
7577
:end-before: DEFAULT_PLACEHOLDER
7678

reference/forms/types/options/data.rst.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ an individual field, you can set it in the data option::
2020

2121
The ``data`` option *always* overrides the value taken from the domain data
2222
(object) when rendering. This means the object value is also overriden when
23-
the form edits an already persisted object, causing it to lose it's
23+
the form edits an already persisted object, causing it to lose its
2424
persisted value when the form is submitted.

routing/scheme.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,18 @@ the URI scheme via schemes:
4848
The above configuration forces the ``secure`` route to always use HTTPS.
4949

5050
When generating the ``secure`` URL, and if the current scheme is HTTP, Symfony
51-
will automatically generate an absolute URL with HTTPS as the scheme:
51+
will automatically generate an absolute URL with HTTPS as the scheme, even when
52+
using the ``path()`` function:
5253

5354
.. code-block:: twig
5455
5556
{# If the current scheme is HTTPS #}
5657
{{ path('secure') }}
57-
{# generates /secure #}
58+
{# generates a relative URL: /secure #}
5859
5960
{# If the current scheme is HTTP #}
6061
{{ path('secure') }}
61-
{# generates https://example.com/secure #}
62+
{# generates an absolute URL: https://example.com/secure #}
6263
6364
The requirement is also enforced for incoming requests. If you try to access
6465
the ``/secure`` path with HTTP, you will automatically be redirected to the

0 commit comments

Comments
 (0)