Skip to content

Commit 2ed36f3

Browse files
committed
Merge branch '3.3' into 3.4
* 3.3: Missing a dot in the last block of code adding note to config Add "url" key in dbal configuration Fixed the internal references of the serializer docs Minor reword Update database.rst Review Typo fix: use correct parameter `options` [Serializer] Add docs for attributes context key Fix docs about making external requests with BrowserKit
2 parents be75758 + 0d6e3a1 commit 2ed36f3

File tree

6 files changed

+62
-15
lines changed

6 files changed

+62
-15
lines changed

components/browser_kit.rst

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ The BrowserKit Component
88
The BrowserKit component simulates the behavior of a web browser, allowing
99
you to make requests, click on links and submit forms programmatically.
1010

11+
.. note::
12+
13+
The BrowserKit component can only make internal requests to your application.
14+
If you need to make requests to external sites and applications, consider
15+
using `Goutte`_, a simple web scraper based on Symfony Components.
16+
1117
Installation
1218
------------
1319

@@ -60,7 +66,7 @@ URL::
6066
use Acme\Client;
6167

6268
$client = new Client();
63-
$crawler = $client->request('GET', 'http://symfony.com');
69+
$crawler = $client->request('GET', '/');
6470

6571
The value returned by the ``request()`` method is an instance of the
6672
:class:`Symfony\\Component\\DomCrawler\\Crawler` class, provided by the
@@ -78,7 +84,7 @@ performs the needed HTTP GET request to simulate the link click::
7884
use Acme\Client;
7985

8086
$client = new Client();
81-
$crawler = $client->request('GET', 'http://symfony.com');
87+
$crawler = $client->request('GET', '/product/123');
8288
$link = $crawler->selectLink('Go elsewhere...')->link();
8389
$client->click($link);
8490

@@ -120,7 +126,7 @@ retrieve any cookie while making requests with the client::
120126

121127
// Make a request
122128
$client = new Client();
123-
$crawler = $client->request('GET', 'http://symfony.com');
129+
$crawler = $client->request('GET', '/');
124130

125131
// Get the cookie Jar
126132
$cookieJar = $client->getCookieJar();
@@ -153,7 +159,7 @@ Looping Through Cookies
153159
154160
// Make a request
155161
$client = new Client();
156-
$crawler = $client->request('GET', 'http://symfony.com');
162+
$crawler = $client->request('GET', '/');
157163
158164
// Get the cookie Jar
159165
$cookieJar = $client->getCookieJar();
@@ -199,9 +205,8 @@ history::
199205

200206
use Acme\Client;
201207

202-
// make a real request to an external site
203208
$client = new Client();
204-
$client->request('GET', 'http://symfony.com');
209+
$client->request('GET', '/');
205210

206211
// select and click on a link
207212
$link = $crawler->selectLink('Documentation')->link();
@@ -218,9 +223,8 @@ also delete all the cookies::
218223

219224
use Acme\Client;
220225

221-
// make a real request to an external site
222226
$client = new Client();
223-
$client->request('GET', 'http://symfony.com');
227+
$client->request('GET', '/');
224228

225229
// delete history
226230
$client->restart();

components/serializer.rst

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,14 @@ The Serializer Component
1111
In order to do so, the Serializer component follows the following
1212
simple schema.
1313

14-
.. _component-serializer-encoders:
15-
.. _component-serializer-normalizers:
16-
1714
.. image:: /_images/components/serializer/serializer_workflow.png
1815

1916
As you can see in the picture above, an array is used as a man in
2017
the middle. This way, Encoders will only deal with turning specific
2118
**formats** into **arrays** and vice versa. The same way, Normalizers
2219
will deal with turning specific **objects** into **arrays** and vice versa.
2320

24-
Serialization is a complex topic. This component may not cover all your use cases out of the box,
21+
Serialization is a complex topic. This component may not cover all your use cases out of the box,
2522
but it can be useful for developing tools to serialize and deserialize your objects.
2623

2724
Installation
@@ -333,6 +330,46 @@ You are now able to serialize only attributes in the groups you want::
333330

334331
.. _ignoring-attributes-when-serializing:
335332

333+
Selecting Specific Attributes
334+
-----------------------------
335+
336+
It is also possible to serialize only a set of specific attributes::
337+
338+
use Symfony\Component\Serializer\Serializer;
339+
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
340+
341+
class User
342+
{
343+
public $familyName;
344+
public $givenName;
345+
public $company;
346+
}
347+
348+
class Company
349+
{
350+
public $name;
351+
public $address;
352+
}
353+
354+
$company = new Company();
355+
$company->name = 'Les-Tilleuls.coop';
356+
$company->address = 'Lille, France';
357+
358+
$user = new User();
359+
$user->familyName = 'Dunglas';
360+
$user->givenName = 'Kévin';
361+
$user->company = $company;
362+
363+
$serializer = new Serializer(array(new ObjectNormalizer()));
364+
365+
$data = $serializer->normalize($user, null, array('attributes' => array('familyName', 'company' => ['name'])));
366+
// $data = array('familyName' => 'Dunglas', 'company' => array('name' => 'Les-Tilleuls.coop'));
367+
368+
Only attributes that are not ignored (see below) are available.
369+
If some serialization groups are set, only attributes allowed by those groups can be used.
370+
371+
As for groups, attributes can be selected during both the serialization and deserialization process.
372+
336373
Ignoring Attributes
337374
-------------------
338375

@@ -503,6 +540,8 @@ When serializing, you can set a callback to format a specific object property::
503540
$serializer->serialize($person, 'json');
504541
// Output: {"name":"cordoval", "age": 34, "createdAt": "2014-03-22T09:43:12-0500"}
505542

543+
.. _component-serializer-normalizers:
544+
506545
Normalizers
507546
-----------
508547

@@ -569,6 +608,8 @@ There are several types of normalizers available:
569608
.. versionadded:: 3.4
570609
The ``DateIntervalNormalizer`` normalizer was added in Symfony 3.4.
571610

611+
.. _component-serializer-encoders:
612+
572613
Encoders
573614
--------
574615

frontend/encore/css-preprocessors.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ can also pass options to ``sass-loader``:
3232
3333
Encore
3434
// ...
35-
.enableSassLoader(function(sassOptions) {
35+
.enableSassLoader(function(options) {
3636
// https://github.com/sass/node-sass#options
3737
// options.includePaths = [...]
3838
});

frontend/encore/typescript.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Then enable it by calling:
5454
5555
Encore
5656
// ...
57-
enableForkedTypeScriptTypesChecking()
57+
.enableForkedTypeScriptTypesChecking()
5858
;
5959
6060
This plugin requires that you have a `tsconfig.json`_ file that is setup correctly.

reference/configuration/doctrine.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,8 @@ The following block shows all possible configuration keys:
300300
user: user
301301
password: secret
302302
driver: pdo_mysql
303+
# if the url option is specified, it will override the above config
304+
url: mysql://db_user:db_password@127.0.0.1:3306/db_name
303305
# the DBAL driverClass option
304306
driver_class: MyNamespace\MyDriverImpl
305307
# the DBAL driverOptions option

testing/database.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ How to Test Code that Interacts with the Database
66

77
If your code interacts with the database, e.g. reads data from or stores data
88
into it, you need to adjust your tests to take this into account. There are
9-
many ways how to deal with this. In a unit test, you can create a mock for
9+
many ways to deal with this. In a unit test, you can create a mock for
1010
a ``Repository`` and use it to return expected objects. In a functional test,
1111
you may need to prepare a test database with predefined values to ensure that
1212
your test always has the same data to work with.

0 commit comments

Comments
 (0)