Skip to content

Commit bdd73a6

Browse files
committed
Merge branch '2.8' into 3.0
2 parents 813fdc2 + 679ac48 commit bdd73a6

File tree

10 files changed

+55
-21
lines changed

10 files changed

+55
-21
lines changed

book/controller.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,18 @@ console command:
533533
534534
For more information, see the :doc:`/book/service_container` chapter.
535535

536+
.. tip::
537+
538+
To get a container configuration parameter in controller you can use the
539+
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::getParameter`
540+
method::
541+
542+
$from = $this->getParameter('app.mailer.from');
543+
544+
.. versionadded:: 2.7
545+
The ``Controller::getParameter()`` method was introduced in Symfony
546+
2.7. Use ``$this->container->getParameter()`` in versions prior to 2.7.
547+
536548
.. index::
537549
single: Controller; Managing errors
538550
single: Controller; 404 pages

book/from_flat_php_to_symfony2.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,13 @@ an individual blog result based on a given id::
254254
function get_post_by_id($id)
255255
{
256256
$link = open_database_connection();
257-
$id = intval($id);
258-
$result = $link->query('SELECT created_at, title, body FROM post WHERE id = '.$id);
259-
$row = $result->fetch(PDO::FETCH_ASSOC);
257+
258+
$query = 'SELECT created_at, title, body FROM post WHERE id=:id';
259+
$statement = $link->prepare($query);
260+
$statement->bindValue(':id', $id, PDO::PARAM_INT);
261+
$statement->execute();
262+
263+
$row = $statement->fetch(PDO::FETCH_ASSOC);
260264

261265
close_database_connection($link);
262266

@@ -294,9 +298,7 @@ Creating the second page is now very easy and no code is duplicated. Still,
294298
this page introduces even more lingering problems that a framework can solve
295299
for you. For example, a missing or invalid ``id`` query parameter will cause
296300
the page to crash. It would be better if this caused a 404 page to be rendered,
297-
but this can't really be done easily yet. Worse, had you forgotten to clean
298-
the ``id`` parameter via the ``intval()`` function, your
299-
entire database would be at risk for an SQL injection attack.
301+
but this can't really be done easily yet.
300302

301303
Another major problem is that each individual controller file must include
302304
the ``model.php`` file. What if each controller file suddenly needed to include

components/browser_kit/introduction.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ Cookies
112112
Retrieving Cookies
113113
~~~~~~~~~~~~~~~~~~
114114

115-
The ``Crawler`` object exposes cookies (if any) through a
115+
The ``Client`` implementation exposes cookies (if any) through a
116116
:class:`Symfony\\Component\\BrowserKit\\CookieJar`, which allows you to store and
117117
retrieve any cookie while making requests with the client::
118118

@@ -123,7 +123,7 @@ retrieve any cookie while making requests with the client::
123123
$crawler = $client->request('GET', 'http://symfony.com');
124124

125125
// Get the cookie Jar
126-
$cookieJar = $crawler->getCookieJar();
126+
$cookieJar = $client->getCookieJar();
127127

128128
// Get a cookie by name
129129
$cookie = $cookieJar->get('name_of_the_cookie');
@@ -155,7 +155,7 @@ Looping Through Cookies
155155
$crawler = $client->request('GET', 'http://symfony.com');
156156
157157
// Get the cookie Jar
158-
$cookieJar = $crawler->getCookieJar();
158+
$cookieJar = $client->getCookieJar();
159159
160160
// Get array with all cookies
161161
$cookies = $cookieJar->all();

components/class_loader/class_loader.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ is straightforward::
3333

3434
$loader->register();
3535

36-
.. note::
37-
38-
The autoloader is automatically registered in a Symfony application
39-
(see ``app/autoload.php``).
40-
4136
Use :method:`Symfony\\Component\\ClassLoader\\ClassLoader::addPrefix` or
4237
:method:`Symfony\\Component\\ClassLoader\\ClassLoader::addPrefixes` to register
4338
your classes::

components/finder.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ directories::
3131

3232
foreach ($finder as $file) {
3333
// Dump the absolute path
34-
var_dump($file->getRealpath());
34+
var_dump($file->getRealPath());
3535

3636
// Dump the relative path to the file, omitting the filename
3737
var_dump($file->getRelativePath());
@@ -159,7 +159,7 @@ You can also define your own sorting algorithm with ``sort()`` method::
159159

160160
$sort = function (\SplFileInfo $a, \SplFileInfo $b)
161161
{
162-
return strcmp($a->getRealpath(), $b->getRealpath());
162+
return strcmp($a->getRealPath(), $b->getRealPath());
163163
};
164164

165165
$finder->sort($sort);

components/http_foundation/introduction.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,14 +474,18 @@ non-ASCII filenames is more involving. The
474474
:method:`Symfony\\Component\\HttpFoundation\\ResponseHeaderBag::makeDisposition`
475475
abstracts the hard work behind a simple API::
476476

477+
use Symfony\Component\HttpFoundation\Response;
477478
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
478479

479-
$d = $response->headers->makeDisposition(
480+
$fileContent = ...; // the generated file content
481+
$response = new Response($fileContent);
482+
483+
$disposition = $response->headers->makeDisposition(
480484
ResponseHeaderBag::DISPOSITION_ATTACHMENT,
481485
'foo.pdf'
482486
);
483487

484-
$response->headers->set('Content-Disposition', $d);
488+
$response->headers->set('Content-Disposition', $disposition);
485489

486490
Alternatively, if you are serving a static file, you can use a
487491
:class:`Symfony\\Component\\HttpFoundation\\BinaryFileResponse`::
@@ -503,6 +507,7 @@ if it should::
503507
With the ``BinaryFileResponse``, you can still set the ``Content-Type`` of the sent file,
504508
or change its ``Content-Disposition``::
505509

510+
// ...
506511
$response->headers->set('Content-Type', 'text/plain');
507512
$response->setContentDisposition(
508513
ResponseHeaderBag::DISPOSITION_ATTACHMENT,

contributing/code/standards.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ Structure
175175
switched to opt-in via ``@`` operator.
176176
Read more at :ref:`contributing-code-conventions-deprecations`.
177177

178+
* Do not use ``else``, ``elseif``, ``break`` after ``if`` and ``case`` conditions
179+
which return or throw something.
180+
178181
Naming Conventions
179182
------------------
180183

cookbook/controller/upload_file.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ Finally, you need to update the code of the controller that handles the form::
136136

137137
// Move the file to the directory where brochures are stored
138138
$file->move(
139-
$this->container->getParameter('brochures_directory'),
139+
$this->getParameter('brochures_directory'),
140140
$fileName
141141
);
142142

@@ -404,7 +404,7 @@ Now, register this class as a Doctrine listener:
404404
405405
// app/config/services.php
406406
use Symfony\Component\DependencyInjection\Reference;
407-
407+
408408
// ...
409409
$definition = new Definition(
410410
'AppBundle\EventListener\BrochureUploaderListener',

cookbook/serializer.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,15 @@ to your class and choose which groups to use when serializing::
159159
$someObject,
160160
'json', array('groups' => array('group1'))
161161
);
162+
163+
In addition to the ``@Groups`` annotation, the Serializer component also
164+
supports Yaml or XML files. These files are automatically loaded when being
165+
stored in one of the following locations:
166+
167+
* The ``serialization.yml`` or ``serialization.xml`` file in
168+
the ``Resources/config/`` directory of a bundle;
169+
* All ``*.yml`` and ``*.xml`` files in the ``Resources/config/serialization/``
170+
directory of a bundle.
162171

163172
.. _cookbook-serializer-enabling-metadata-cache:
164173

reference/configuration/monolog.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ Full Default Configuration
2727
main:
2828
type: fingers_crossed
2929
action_level: WARNING
30-
buffer_size: 30
30+
# By default, buffer_size is unlimited (0), which could
31+
# generate huge logs.
32+
buffer_size: 0
3133
handler: custom
3234
console:
3335
type: console
@@ -92,16 +94,22 @@ Full Default Configuration
9294
bubble="false"
9395
formatter="my_formatter"
9496
/>
97+
98+
<!-- By default, buffer-size is unlimited (0), which could
99+
generate huge logs. -->
95100
<monolog:handler
96101
name="main"
97102
type="fingers_crossed"
98103
action-level="warning"
99104
handler="custom"
105+
buffer-size="0"
100106
/>
107+
101108
<monolog:handler
102109
name="console"
103110
type="console"
104111
/>
112+
105113
<monolog:handler
106114
name="custom"
107115
type="service"

0 commit comments

Comments
 (0)