8000 Merge branch '4.0' · symfony/symfony-docs@8f8ddff · GitHub
[go: up one dir, main page]

Skip to content

Commit 8f8ddff

Browse files
committed
Merge branch '4.0'
* 4.0: (33 commits) Fix YAML identation Update rendering.rst Update formatter.rst remove part about adding extension Add "allowed_classes" argument for unserialize() Removed another unneeded closing block name Fix little typo fix indentation fix versionadded directive Fix a method reference value Fix "class_exists" PHP function URL Removed another unneeded closing block name add missing ";" Fix little typo Remove faulty PHP code blocks Fix typo in method setETag. Correct method name is setEtag Add kernel to list of excluded registered services Changes after code review Changes after code review Changes after code review ...
2 parents e192330 + 81645f9 commit 8f8ddff

22 files changed

+148
-151
lines changed

components/cache/psr6_psr16_adapters.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ instead. No problem! The Cache component provides the
3737
this use-case::
3838

3939
use Symfony\Component\Cache\Simple\FilesystemCache;
40-
use Symfony\Component\Cache\Adapter\SimpleCacheAdapter
40+
use Symfony\Component\Cache\Adapter\SimpleCacheAdapter;
4141

4242
// the PSR-16 cache object that you want to use
4343
$psr16Cache = new FilesystemCache();

components/intl.rst

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,6 @@ replace the intl classes:
4848

4949
Composer automatically exposes these classes in the global namespace.
5050

51-
If you don't use Composer but the
52-
:doc:`Symfony ClassLoader component </components/class_loader>`,
53-
you need to expose them manually by adding the following lines to your autoload
54-
code::
55-
56-
if (!function_exists('intl_is_failure')) {
57-
require '/path/to/Icu/Resources/stubs/functions.php';
58-
59-
$loader->registerPrefixFallback('/path/to/Icu/Resources/stubs');
60-
}
61-
6251
Writing and Reading Resource Bundles
6352
------------------------------------
6453

configuration/front_controllers_and_kernel.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ you must implement them all:
8383
:method:`Symfony\\Component\\HttpKernel\\KernelInterface::registerBundles`
8484
It must return an array of all bundles needed to run the application.
8585

86-
:method:`Symfony\\Bundle\\FrameworkBundle\\Kernel\\MicroKernelTrait:configureRoutes`
86+
:method:`Symfony\\Bundle\\FrameworkBundle\\Kernel\\MicroKernelTrait::configureRoutes`
8787
It adds individual routes or collections of routes to the application (for
8888
example loading the routes defined in some config file).
8989

contributing/community/review-comments.rst

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,18 @@ that, but swearing/cursing and name calling doesn't really encourage anyone to
4343
help you. Take a deep breath, count to 10 and try to *clearly* explain what problems
4444
you encounter.
4545

46-
Gender-neutral Pronouns
47-
-----------------------
46+
Inclusive Language
47+
------------------
4848

49-
While not "formally" required, it's better to use gender-neutral pronouns.
50-
Unless someone "indicated" their pronouns, use "they", "them" instead of
51-
"he", "she", "his", "hers", "his/hers", "he/she", etc.
49+
In an effort to be inclusive to a wide group of people, it's recommended to
50+
use personal pronouns that don't suggest a particular gender. Unless someone
51+
has stated their pronouns, use "they", "them" instead of "he", "she", "his",
52+
"hers", "his/hers", "he/she", etc.
5253

53-
Try to avoid using wording that may be considered excluding and needlessly gendered,
54-
like for example words that have a male base. For example we recommend to use other
55-
words like "folks", "team", "everyone" in place of "guys".
54+
Try to avoid using wording that may be considered excluding, needlessly gendered
55+
(e.g. words that have a male or female base), racially motivated or singles out
56+
a particular group in society. For example, it's recommended to use words like
57+
"folks", "team", "everyone" instead of "guys", "ladies", "yanks", etc.
5658

5759
Giving Positive Feedback
5860
------------------------

controller.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ method renders a template **and** puts that content into a ``Response``
182182
object for you::
183183

184184
// renders templates/lucky/number.html.twig
185-
return $this->render('lucky/number.html.twig', array('name' => $name));
185+
return $this->render('lucky/number.html.twig', array('number' => $number));
186186

187187
Templating and Twig are explained more in the
188188
:doc:`Creating and Using Templates article </templating>`.
@@ -308,7 +308,7 @@ use:
308308
309309
$ php bin/console make:crud Product
310310
311-
.. versionadded::
311+
.. versionadded:: 1.2
312312
The ``make:crud`` command was introduced in MakerBundle 1.2.
313313

314314
.. index::

doctrine.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ knows that the first migration was already executed earlier. Behind the scenes,
272272
automatically manages a ``migration_versions`` table to track this.
273273

274274
Each time you make a change to your schema, run these two commands to generate the
275-
migration and then execute it. Be sure to commit the migration files and run execute
275+
migration and then execute it. Be sure to commit the migration files and execute
276276
them when you deploy.
277277

278278
.. _doctrine-generating-getters-and-setters:
@@ -316,7 +316,7 @@ then go to the Code -> Generate menu and select "Getters and Setters"::
316316

317317
.. tip::
318318

319-
Typically you won't need a ``setId()`` method: Doctrine will set this for you
319+
Typically you won't need a ``setId()`` method: Doctrine will set the ID
320320
automatically.
321321

322322
Persisting Objects to the Database

form/bootstrap4.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ template which other templates extend from):
1616
{% endblock %}
1717
{% block head_js %}
1818
<!-- Copy JavaScript from https://getbootstrap.com/docs/4.0/getting-started/introduction/#js -->
19-
{% endblock head %}
19+
{% endblock %}
2020

2121
If your application uses modern front-end practices, it's better to use
2222
:doc:`Webpack Encore </frontend>` and follow :doc:`this tutorial </frontend/encore/bootstrap>`
@@ -75,7 +75,7 @@ If you prefer to apply the Bootstrap styles on a form to form basis, include the
7575
{% block body %}
7676
<h1>User Sign Up:</h1>
7777
{{ form(form) }}
78-
{% endblock body %}
78+
{% endblock %}
7979
8080
Accessibility
8181
-------------

form/rendering.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ of code. Of course, you'll usually need much more flexibility when rendering:
2121

2222
.. code-block:: html+php
2323

24-
<!-- templates/default/newAction.html.php -->
24+
<!-- templates/default/new.html.php -->
2525
<?php echo $view['form']->start($form) ?>
2626
<?php echo $view['form']->errors($form) ?>
2727

frontend/encore/server-data.rst

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,18 @@ Fetch this in JavaScript:
1616

1717
.. code-block:: javascript
1818
19-
// jquery isn't required, but makes things simple
20-
var $ = require('jquery');
21-
22-
$(document).ready(function() {
23-
var isAuthenticated = $('.js-user-rating').data('is-authenticated');
19+
document.addEventListener('DOMContentLoaded', function() {
20+
var userRating = document.querySelector('.js-user-rating');
21+
var isAuthenticated = userRating.dataset.isAuthenticated;
2422
});
2523
24+
.. note::
25+
26+
When `accessing data attributes from JavaScript`_, the attribute names are
27+
converted from dash-style to camelCase. For example, ``data-is-authenticated``
28+
becomes ``isAuthenticated`` and ``data-number-of-reviews`` becomes
29+
``numberOfReviews``.
30+
2631
There is no size limit for the value of the ``data-`` attributes, so you can
2732
store any content. In Twig, use the ``html_attr`` escaping strategy to avoid messing
2833
with HTML attributes. For example, if your ``User`` object has some ``getProfileData()``
@@ -33,3 +38,5 @@ method that returns an array, you could do the following:
3338
<div data-user-profile="{{ app.user ? app.user.profileData|json_encode|e('html_attr') : '' }}">
3439
<!-- ... -->
3540
</div>
41+
42+
.. _`accessing data attributes from JavaScript`: https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes

http_cache/validation.rst

Lines changed: 1 addition & 1 deletion
C403
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ exposing a simple and efficient pattern::
200200

201201
// create a Response with an ETag and/or a Last-Modified header
202202
$response = new Response();
203-
$response->setETag($article->computeETag());
203+
$response->setEtag($article->computeETag());
204204
$response->setLastModified($article->getPublishedAt());
205205

206206
// Set response as public. Otherwise it will be private by default.

logging/formatter.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ configure your handler to use it:
6868
'file' => array(
6969
'type' => 'stream',
7070
'level' => 'debug',
71-
'formatter' => JsonFormatter::class',
71+
'formatter' => JsonFormatter::class,
7272
),
7373
),
7474
));

quick_tour/flex_recipes.rst

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ Thanks to Flex, after one command, you can start using Twig immediately:
7676
.. code-block:: diff
7777
7878
// src/Controller/DefaultController.php
79-
// ...
79+
namespace App\Controller;
8080
81+
use Symfony\Component\Routing\Annotation\Route;
82+
- use Symfony\Component\HttpFoundation\Response;
8183
+ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
8284
8385
-class DefaultController
@@ -150,15 +152,26 @@ Rich API Support
150152

151153
Are you building an API? You can already return JSON easily from any controller::
152154

153-
/**
154-
* @Route("/api/hello/{name}")
155-
*/
156-
public function apiExample($name)
155+
// src/Controller/DefaultController.php
156+
namespace App\Controller;
157+
158+
use Symfony\Component\Routing\Annotation\Route;
159+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
160+
161+
class DefaultController extends AbstractController
157162
{
158-
return $this->json([
159-
'name' => $name,
160-
'symfony' => 'rocks',
161-
]);
163+
// ...
164+
165+
/**
166+
* @Route("/api/hello/{name}")
167+
*/
168+
public function apiExample($name)
169+
{
170+
return $this->json([
171+
'name' => $name,
172+
'symfony' => 'rocks',
173+
]);
174+
}
162175
}
163176

164177
But for a *truly* rich API, try installing `Api Platform`_:
@@ -176,7 +189,7 @@ rich API for a ``product`` table? Create a ``Product`` entity and give it the
176189
``@ApiResource()`` annotation::
177190

178191
// src/Entity/Product.php
179-
// ...
192+
namespace App\Entity;
180193

181194
use ApiPlatform\Core\Annotation\ApiResource;
182195
use Doctrine\ORM\Mapping as ORM;

quick_tour/the_architecture.rst

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,24 @@ Want a logging system? No problem:
2121
This installs and configures (via a recipe) the powerful `Monolog`_ library. To
2222
use the logger in a controller, add a new argument type-hinted with ``LoggerInterface``::
2323

24+
// src/Controller/DefaultController.php
25+
namespace App\Controller;
26+
2427
use Psr\Log\LoggerInterface;
25-
// ...
28+
use Symfony\Component\Routing\Annotation\Route;
29+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
2630

27-
public function index($name, LoggerInterface $logger)
31+
class DefaultController extends AbstractController
2832
{
29-
$logger->info("Saying hello to $name!");
33+
/**
34+
* @Route("/hello/{name}")
35+
*/
36+
public function index($name, LoggerInterface $logger)
37+
{
38+
$logger->info("Saying hello to $name!");
3039

31-
// ...
40+
// ...
41+
}
3242
}
3343

3444
That's it! The new log message will be written to ``var/log/dev.log``. Of course, this
@@ -89,16 +99,27 @@ this code directly in your controller, create a new class::
8999

90100
Great! You can use this immediately in your controller::
91101

102+
// src/Controller/DefaultController.php
103+
namespace App\Controller;
104+
92105
use App\GreetingGenerator;
93-
// ...
106+
use Psr\Log\LoggerInterface;
107+
use Symfony\Component\Routing\Annotation\Route;
108+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
94109

95-
public function index($name, LoggerInterface $logger, GreetingGenerator $generator)
110+
class DefaultController extends AbstractController
96111
{
97-
$greeting = $generator->getRandomGreeting();
112+
/**
113+
* @Route("/hello/{name}")
114+
*/
115+
public function index($name, LoggerInterface $logger, GreetingGenerator $generator)
116+
{
117+
$greeting = $generator->getRandomGreeting();
98118

99-
$logger->info("Saying $greeting to $name!");
119+
$logger->info("Saying $greeting to $name!");
100120

101-
// ...
121+
// ...
122+
}
102123
}
103124

104125
That's it! Symfony will instantiate the ``GreetingGenerator`` automatically and
@@ -108,6 +129,7 @@ difference is that it's done in the constructor:
108129

109130
.. code-block:: diff
110131
132+
// src/GreetingGenerator.php
111133
+ use Psr\Log\LoggerInterface;
112134
113135
class GreetingGenerator
@@ -174,6 +196,7 @@ After creating just *one* file, you can use this immediately:
174196

175197
.. code-block:: twig
176198
199+
{# templates/default/index.html.twig #}
177200
{# Will print something like "Hey Symfony!" #}
178201
<h1>{{ name|greet }}</h1>
179202

0 commit comments

Comments
 (0)
0