Skip to content

Commit 679ac48

Browse files
committed
Merge branch '2.7' into 2.8
2 parents e3db793 + efea90e commit 679ac48

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
@@ -537,6 +537,18 @@ console command:
537537
538538
For more information, see the :doc:`/book/service_container` chapter.
539539

540+
.. tip::
541+
542+
To get a container configuration parameter in controller you can use the
543+
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::getParameter`
544+
method::
545+
546+
$from = $this->getParameter('app.mailer.from');
547+
548+
.. versionadded:: 2.7
549+
The ``Controller::getParameter()`` method was introduced in Symfony
550+
2.7. Use ``$this->container->getParameter()`` in versions prior to 2.7.
551+
540552
.. index::
541553
single: Controller; Managing errors
542554
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());
@@ -163,7 +163,7 @@ You can also define your own sorting algorithm with ``sort()`` method::
163163

164164
$sort = function (\SplFileInfo $a, \SplFileInfo $b)
165165
{
166-
return strcmp($a->getRealpath(), $b->getRealpath());
166+
return strcmp($a->getRealPath(), $b->getRealPath());
167167
};
168168

169169
$finder->sort($sort);

components/http_foundation/introduction.rst

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

480+
use Symfony\Component\HttpFoundation\Response;
480481
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
481482

482-
$d = $response->headers->makeDisposition(
483+
$fileContent = ...; // the generated file content
484+
$response = new Response($fileContent);
485+
486+
$disposition = $response->headers->makeDisposition(
483487
ResponseHeaderBag::DISPOSITION_ATTACHMENT,
484488
'foo.pdf'
485489
);
486490

487-
$response->headers->set('Content-Disposition', $d);
491+
$response->headers->set('Content-Disposition', $disposition);
488492

489493
Alternatively, if you are serving a static file, you can use a
490494
:class:`Symfony\\Component\\HttpFoundation\\BinaryFileResponse`::
@@ -506,6 +510,7 @@ if it should::
506510
With the ``BinaryFileResponse``, you can still set the ``Content-Type`` of the sent file,
507511
or change its ``Content-Disposition``::
508512

513+
// ...
509514
$response->headers->set('Content-Type', 'text/plain');
510515
$response->setContentDisposition(
511516
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
@@ -171,6 +171,15 @@ to your class and choose which groups to use when serializing::
171171
$someObject,
172172
'json', array('groups' => array('group1'))
173173
);
174+
175+
In addition to the ``@Groups`` annotation, the Serializer component also
176+
supports Yaml or XML files. These files are automatically loaded when being
177+
stored in one of the following locations:
178+
179+
* The ``serialization.yml`` or ``serialization.xml`` file in
180+
the ``Resources/config/`` directory of a bundle;
181+
* All ``*.yml`` and ``*.xml`` files in the ``Resources/config/serialization/``
182+
directory of a bundle.
174183

175184
.. _cookbook-serializer-enabling-metadata-cache:
176185

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)