Skip to content

Commit 300b71a

Browse files
committed
Merge branch '2.2'
2 parents eb11780 + 18ebdda commit 300b71a

File tree

18 files changed

+87
-45
lines changed

18 files changed

+87
-45
lines changed

book/http_cache.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,8 @@ example).
533533
.. tip::
534534

535535
The 304 status code means "Not Modified". It's important because with
536-
this status code do *not* contain the actual content being requested.
537-
Instead, the response is simply a light-weight set of directions that
536+
this status code the response does *not* contain the actual content being
537+
requested. Instead, the response is simply a light-weight set of directions that
538538
tell cache that it should use its stored version.
539539

540540
Like with expiration, there are two different HTTP headers that can be used

book/performance.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Internally, this builds the big class map array in ``vendor/composer/autoload_cl
6767
Caching the Autoloader with APC
6868
-------------------------------
6969

70-
Another solution is to to cache the location of each class after it's located
70+
Another solution is to cache the location of each class after it's located
7171
the first time. Symfony comes with a class - :class:`Symfony\\Component\\ClassLoader\\ApcClassLoader` -
7272
that does exactly this. To use it, just adapt your front controller file.
7373
If you're using the Standard Distribution, this code should already be available

book/security.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ First, enable form login under your firewall:
358358
359359
Now, when the security system initiates the authentication process, it will
360360
redirect the user to the login form (``/login`` by default). Implementing this
361-
login form visually is your job. First, the create two routes we used in the
361+
login form visually is your job. First, create the two routes you used in the
362362
security configuration: the ``login`` route will display the login form (i.e.
363363
``/login``) and the ``login_check`` route will handle the login form
364364
submission (i.e. ``/login_check``):

book/translation.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ for example, that you're translating a simple message from inside a controller::
102102

103103
public function indexAction()
104104
{
105-
$t = $this->get('translator')->trans('Symfony2 is great');
105+
$translated = $this->get('translator')->trans('Symfony2 is great');
106106

107-
return new Response($t);
107+
return new Response($translated);
108108
}
109109

110110
When this code is executed, Symfony2 will attempt to translate the message
@@ -179,9 +179,9 @@ Sometimes, a message containing a variable needs to be translated::
179179

180180
public function indexAction($name)
181181
{
182-
$t = $this->get('translator')->trans('Hello '.$name);
182+
$translated = $this->get('translator')->trans('Hello '.$name);
183183

184-
return new Response($t);
184+
return new Response($translated);
185185
}
186186

187187
However, creating a translation for this string is impossible since the translator
@@ -195,12 +195,12 @@ variable with a "placeholder"::
195195

196196
public function indexAction($name)
197197
{
198-
$t = $this->get('translator')->trans(
198+
$translated = $this->get('translator')->trans(
199199
'Hello %name%',
200200
array('%name%' => $name)
201201
);
202202

203-
return new Response($t);
203+
return new Response($translated);
204204
}
205205

206206
Symfony2 will now look for a translation of the raw message (``Hello %name%``)
@@ -391,9 +391,9 @@ Symfony2 will discover these files and use them when translating either
391391
This example illustrates the two different philosophies when creating
392392
messages to be translated::
393393

394-
$t = $translator->trans('Symfony2 is great');
394+
$translated = $translator->trans('Symfony2 is great');
395395

396-
$t = $translator->trans('symfony2.great');
396+
$translated = $translator->trans('symfony2.great');
397397

398398
In the first method, messages are written in the language of the default
399399
locale (English in this case). That message is then used as the "id"
@@ -643,7 +643,7 @@ all the forms as a string separated by a pipe (``|``)::
643643
To translate pluralized messages, use the
644644
:method:`Symfony\\Component\\Translation\\Translator::transChoice` method::
645645

646-
$t = $this->get('translator')->transChoice(
646+
$translated = $this->get('translator')->transChoice(
647647
'There is one apple|There are %count% apples',
648648
10,
649649
array('%count%' => 10)
@@ -793,7 +793,7 @@ texts* and complex expressions:
793793
Using the translation tags or filters have the same effect, but with
794794
one subtle difference: automatic output escaping is only applied to
795795
translations using a filter. In other words, if you need to be sure
796-
that your translated is *not* output escaped, you must apply the
796+
that your translated is *not* output escaped, you must apply the
797797
``raw`` filter after the translation filter:
798798

799799
.. code-block:: jinja

components/dom_crawler.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,13 @@ The crawler supports multiple ways of adding the content::
160160
$crawler->add('<html><body /></html>');
161161
$crawler->add('<root><node /></root>');
162162

163+
.. note::
164+
165+
When dealing with character sets other than ISO-8859-1, always add HTML
166+
content using the :method:`Symfony\\Component\\DomCrawler\\Crawler::addHTMLContent``
167+
method where you can specify the second parameter to be your target character
168+
set.
169+
163170
As the Crawler's implementation is based on the DOM extension, it is also able
164171
to interact with native :phpclass:`DOMDocument`, :phpclass:`DOMNodeList`
165172
and :phpclass:`DOMNode` objects:

components/process.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ anonymous function to the
5757

5858
$process = new Process('ls -lsa');
5959
$process->run(function ($type, $buffer) {
60-
if ('err' === $type) {
60+
if (Process::ERR === $type) {
6161
echo 'ERR > '.$buffer;
6262
} else {
6363
echo 'OUT > '.$buffer;
@@ -92,7 +92,7 @@ are done doing other stuff::
9292
// ... do other things
9393

9494
$process->wait(function ($type, $buffer) {
95-
if ('err' === $type) {
95+
if (Process:ERR === $type) {
9696
echo 'ERR > '.$buffer;
9797
} else {
9898
echo 'OUT > '.$buffer;

contributing/code/git.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ request (including comments) is saved in the repository.
1313
You can easily spot pull request merges as the commit message always follows
1414
this pattern:
1515

16-
.. block: text
16+
.. code-block:: text
1717
1818
merged branch USER_NAME/BRANCH_NAME (PR #1111)
1919
@@ -30,13 +30,13 @@ stored as a Git note (before March 22 2013, the discussion was part of the
3030
main merge commit message). To get access to these notes, add this line to
3131
your ``.git/config`` file:
3232

33-
.. block: text
33+
.. code-block:: ini
3434
3535
fetch = +refs/notes/*:refs/notes/*
3636
3737
After a fetch, getting the Github discussion for a commit is then a matter of
3838
adding ``--show-notes=github-comments`` to the ``git show`` command:
3939

40-
.. block: text
40+
.. code-block:: bash
4141
42-
git show HEAD --show-notes=github-comments
42+
$ git show HEAD --show-notes=github-comments

cookbook/bundles/extension.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,6 @@ global parameters available to use:
423423
* ``kernel.root_dir``
424424
* ``kernel.cache_dir``
425425
* ``kernel.logs_dir``
426-
* ``kernel.bundle_dirs``
427426
* ``kernel.bundles``
428427
* ``kernel.charset``
429428

cookbook/configuration/web_server_configuration.rst

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ are:
2121
.. code-block:: apache
2222
2323
<VirtualHost *:80>
24-
ServerName www.domain.tld
24+
ServerName domain.tld
25+
ServerAlias www.domain.tld
2526
2627
DocumentRoot /var/www/project/web
2728
<Directory /var/www/project/web>
@@ -30,7 +31,7 @@ are:
3031
Order allow,deny
3132
Allow from All
3233
</Directory>
33-
34+
3435
ErrorLog /var/log/apache2/project_error.log
3536
CustomLog /var/log/apache2/project_access.log combined
3637
</VirtualHost>
@@ -59,7 +60,7 @@ are:
5960
.. code-block:: nginx
6061
6162
server {
62-
server_name www.domain.tld;
63+
server_name domain.tld www.domain.tld;
6364
root /var/www/project/web;
6465
6566
location / {
@@ -72,7 +73,7 @@ are:
7273
rewrite ^(.*)$ /app.php/$1 last;
7374
}
7475
75-
location ~ ^/(app|app_dev)\.php(/|$) {
76+
location ~ ^/(app|app_dev|config)\.php(/|$) {
7677
fastcgi_pass unix:/var/run/php5-fpm.sock;
7778
fastcgi_split_path_info ^(.+\.php)(/.*)$;
7879
include fastcgi_params;
@@ -91,10 +92,14 @@ are:
9192

9293
.. tip::
9394

94-
This executes **only** ``app.php`` and ``app_dev.php`` in the web directory.
95-
All other files will be served as text. If you have other PHP files in
96-
your web directory, be sure to include them in the ``location`` block
97-
above.
95+
This executes **only** ``app.php``, ``app_dev.php`` and ``config.php`` in
96+
the web directory. All other files will be served as text. You **must**
97+
also make sure that if you *do* deploy ``app_dev.php`` or ``config.php``
98+
that these files are secured and not available to any outside user (the
99+
IP checking code at the top of each file does this by default).
100+
101+
If you have other PHP files in your web directory that need to be executed,
102+
be sure to include them in the ``location`` block above.
98103

99104
.. _`Apache`: http://httpd.apache.org/docs/current/mod/core.html#documentroot
100105
.. _`Nginx`: http://wiki.nginx.org/Symfony

cookbook/form/form_customization.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ Using Form Variables
928928
--------------------
929929

930930
Most of the functions available for rendering different parts of a form (e.g.
931-
the form widget, form label, form widget, etc) also allow you to make certain
931+
the form widget, form label, form errors, etc) also allow you to make certain
932932
customizations directly. Look at the following example:
933933

934934
.. configuration-block::

cookbook/security/acl.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ Checking Access
166166
$securityContext = $this->get('security.context');
167167
168168
// check for edit access
169-
if (false === $securityContext->isGranted('EDIT', $comment))
170-
{
169+
if (false === $securityContext->isGranted('EDIT', $comment)) {
171170
throw new AccessDeniedException();
172171
}
173172

cookbook/security/entity_provider.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -593,21 +593,20 @@ The ``AcmeUserBundle:Group`` entity class defines three table fields (``id``,
593593
``name`` and ``role``). The unique ``role`` field contains the role name used by
594594
the Symfony security layer to secure parts of the application. The most
595595
important thing to notice is that the ``AcmeUserBundle:Group`` entity class
596-
implements the :class:`Symfony\\Component\\Security\\Core\\Role\\RoleInterface`
597-
that forces it to have a ``getRole()`` method::
596+
extends the :class:`Symfony\\Component\\Security\\Core\\Role\\Role`::
598597
599598
// src/Acme/Bundle/UserBundle/Entity/Group.php
600599
namespace Acme\UserBundle\Entity;
601600
602-
use Symfony\Component\Security\Core\Role\RoleInterface;
601+
use Symfony\Component\Security\Core\Role\Role;
603602
use Doctrine\Common\Collections\ArrayCollection;
604603
use Doctrine\ORM\Mapping as ORM;
605604
606605
/**
607606
* @ORM\Table(name="acme_groups")
608607
* @ORM\Entity()
609608
*/
610-
class Group implements RoleInterface
609+
class Group extends Role
611610
{
612611
/**
613612
* @ORM\Column(name="id", type="integer")

cookbook/security/voters.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,17 @@ and compare the IP address against a set of blacklisted IP addresses:
100100
That's it! The voter is done. The next step is to inject the voter into
101101
the security layer. This can be done easily through the service container.
102102

103+
.. tip::
104+
105+
Your implementation of the methods
106+
:method:`Symfony\\Component\\Security\\Core\\Authorization\\Voter\\VoterInterface::supportsAttribute`
107+
and :method:`Symfony\\Component\\Security\\Core\\Authorization\\Voter\\VoterInterface::supportsClass`
108+
are not being called internally by the framework. Once you have registered your
109+
voter the ``vote()`` method will always be called, regardless of whether
110+
or not these two methods return true. Therefore you need to call those
111+
methods in your implementation of the ``vote()`` method and return ``ACCESS_ABSTAIN``
112+
if your voter does not support the class or attribute.
113+
103114
Declaring the Voter as a Service
104115
--------------------------------
105116

cookbook/testing/profiling.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ the ``test`` environment)::
3939
// check the time spent in the framework
4040
$this->assertLessThan(
4141
500,
42-
$profile->getCollector('time')->getTotalTime()
42+
$profile->getCollector('time')->getDuration()
4343
);
4444
}
4545
}

reference/constraints/CardScheme.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ on an object that will contain a credit card number.
5454
.. code-block:: php-annotations
5555
5656
// src/Acme/SubscriptionBundle/Entity/Transaction.php
57+
namespace Acme\SubscriptionBundle\Entity\Transaction;
58+
5759
use Symfony\Component\Validator\Constraints as Assert;
5860
5961
class Transaction
@@ -67,16 +69,18 @@ on an object that will contain a credit card number.
6769
.. code-block:: php
6870
6971
// src/Acme/SubscriptionBundle/Entity/Transaction.php
72+
namespace Acme\SubscriptionBundle\Entity\Transaction;
73+
7074
use Symfony\Component\Validator\Mapping\ClassMetadata;
71-
use Symfony\Component\Validator\Constraints\CardScheme;
75+
use Symfony\Component\Validator\Constraints as Assert;
7276
7377
class Transaction
7478
{
7579
protected $cardNumber;
7680
7781
public static function loadValidatorMetadata(ClassMetadata $metadata)
7882
{
79-
$metadata->addPropertyConstraint('cardSchema', new CardScheme(array(
83+
$metadata->addPropertyConstraint('cardNumber', new Assert\CardScheme(array(
8084
'schemes' => array(
8185
'VISA'
8286
),
@@ -117,4 +121,4 @@ message
117121

118122
The message shown when the value does not pass the ``CardScheme`` check.
119123

120-
.. _`Wikipedia: Issuer identification number (IIN)`: http://en.wikipedia.org/wiki/Bank_card_number#Issuer_identification_number_.28IIN.29
124+
.. _`Wikipedia: Issuer identification number (IIN)`: http://en.wikipedia.org/wiki/Bank_card_number#Issuer_identification_number_.28IIN.29

reference/constraints/Luhn.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Luhn
2-
======
2+
====
33

44
.. versionadded:: 2.2
55
The Luhn validation is new in Symfony 2.2.
@@ -49,6 +49,8 @@ will contain a credit card number.
4949
.. code-block:: php-annotations
5050
5151
// src/Acme/SubscriptionBundle/Entity/Transaction.php
52+
namespace Acme\SubscriptionBundle\Entity\Transaction;
53+
5254
use Symfony\Component\Validator\Constraints as Assert;
5355
5456
class Transaction
@@ -62,16 +64,18 @@ will contain a credit card number.
6264
.. code-block:: php
6365
6466
// src/Acme/SubscriptionBundle/Entity/Transaction.php
67+
namespace Acme\SubscriptionBundle\Entity\Transaction;
68+
6569
use Symfony\Component\Validator\Mapping\ClassMetadata;
66-
use Symfony\Component\Validator\Constraints\Luhn;
70+
use Symfony\Component\Validator\Constraints as Assert;
6771
6872
class Transaction
6973
{
7074
protected $cardNumber;
7175
7276
public static function loadValidatorMetadata(ClassMetadata $metadata)
7377
{
74-
$metadata->addPropertyConstraint('luhn', new Luhn(array(
78+
$metadata->addPropertyConstraint('cardNumber', new Assert\Luhn(array(
7579
'message' => 'Please check your credit card number',
7680
)));
7781
}
@@ -87,4 +91,4 @@ message
8791

8892
The default message supplied when the value does not pass the Luhn check.
8993

90-
.. _`Luhn algorithm`: http://en.wikipedia.org/wiki/Luhn_algorithm
94+
.. _`Luhn algorithm`: http://en.wikipedia.org/wiki/Luhn_algorithm

reference/constraints/UniqueEntity.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ using an email address that already exists in the system.
1212
| | - `message`_ |
1313
| | - `em`_ |
1414
| | - `repositoryMethod`_ |
15+
| | - `ignoreNull`_ |
1516
+----------------+-------------------------------------------------------------------------------------+
1617
| Class | :class:`Symfony\\Bridge\\Doctrine\\Validator\\Constraints\\UniqueEntity` |
1718
+----------------+-------------------------------------------------------------------------------------+
@@ -145,3 +146,16 @@ repositoryMethod
145146
The name of the repository method to use for making the query to determine the
146147
uniqueness. If it's left blank, the ``findBy`` method will be used. This
147148
method should return a countable result.
149+
150+
.. versionadded:: 2.1
151+
The ``ignoreNull`` option was added in Symfony 2.1.
152+
153+
ignoreNull
154+
~~~~~~~~~~
155+
156+
**type**: ``Boolean`` **default**: ``true``
157+
158+
If this option is set to ``true``, then the constraint will allow multiple
159+
entities to have a ``null`` value for a field without failing validation.
160+
If set to ``false``, only one ``null`` value is allowed - if a second entity
161+
also has a ``null`` value, validation would fail.

0 commit comments

Comments
 (0)