8000 Merge branch '2.3' into 2.7 · symfony/symfony-docs@e29b7ab · GitHub
[go: up one dir, main page]

Skip to content

Commit e29b7ab

Browse files
committed
Merge branch '2.3' into 2.7
2 parents f9edfd5 + c8f4583 commit e29b7ab

File tree

9 files changed

+51
-64
lines changed

9 files changed

+51
-64
lines changed

book/http_cache.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,11 +1207,6 @@ One great advantage of the ESI renderer is that you can make your application
12071207
as dynamic as needed and at the same time, hit the application as little as
12081208
possible.
12091209

1210-
.. tip::
1211-
1212-
The listener only responds to local IP addresses or
1213-
:doc:`trusted proxies </cookbook/request/load_balancer_reverse_proxy>`.
1214-
12151210
.. note::
12161211

12171212
Once you start using ESI, remember to always use the ``s-maxage``

components/event_dispatcher/container_aware_dispatcher.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,15 @@ and the second argument is the service's class name (which must implement
6868
The ``EventSubscriberInterface`` is exactly as you would expect::
6969

7070
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
71+
use Symfony\Component\HttpKernel\KernelEvents;
7172
// ...
7273

7374
class StoreSubscriber implements EventSubscriberInterface
7475
{
7576
public static function getSubscribedEvents()
7677
{
7778
return array(
78-
'kernel.response' => array(
79+
KernelEvents::RESPONSE => array(
7980
array('onKernelResponsePre', 10),
8081
array('onKernelResponsePost', 0),
8182
),

cookbook/bundles/configuration.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ can place it anywhere you like. You should return this path as the base path::
373373
}
374374
}
375375

376-
Assume the XSD file is called ``hello-1.0.xsd``, the schema location will be
376+
Assuming the XSD file is called ``hello-1.0.xsd``, the schema location will be
377377
``http://acme_company.com/schema/dic/hello/hello-1.0.xsd``:
378378

379379
.. code-block:: xml

cookbook/composer.rst

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,24 @@ following sections.
1414
Install Composer on Linux and Mac OS X
1515
--------------------------------------
1616

17-
To install Composer on Linux or Mac OS X, execute the following two commands:
17+
#. Run the installer as described in `the official Composer documentation`_;
18+
#. Execute the following command to move the ``composer.phar`` to a directory that is in your path:
1819

19-
.. code-block:: bash
20+
.. code-block:: bash
2021
21-
$ curl -sS https://getcomposer.org/installer | php
22-
$ sudo mv composer.phar /usr/local/bin/composer
23-
24-
.. note::
25-
26-
If you don't have ``curl`` installed, you can also just download the
27-
``installer`` file manually at https://getcomposer.org/installer and
28-
then run:
29-
30-
.. code-block:: bash
31-
32-
$ php installer
33-
$ sudo mv composer.phar /usr/local/bin/composer
22+
$ sudo mv composer.phar /usr/local/bin/composer
3423
3524
Install Composer on Windows
3625
---------------------------
3726

38-
Download the installer from `getcomposer.org/download`_, execute it and follow
39-
the instructions.
27+
Download the installer from `getcomposer.org`_, execute it and follow the instructions.
4028

4129
Learn more
4230
----------
4331

4432
Read the `Composer documentation`_ to learn more about its usage and features.
4533

4634
.. _`Composer`: https://getcomposer.org/
47-
.. _`getcomposer.org/download`: https://getcomposer.org/download
4835
.. _`Composer documentation`: https://getcomposer.org/doc/00-intro.md
36+
.. _`getcomposer.org`: https://getcomposer.org/Composer-Setup.exe
37+
.. _the official Composer documentation: https://getcomposer.org/download

cookbook/event_dispatcher/event_listener.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,15 @@ listen to the same ``kernel.exception`` event::
142142

143143
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
144144
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
145+
use Symfony\Component\HttpKernel\KernelEvents;
145146

146147
class ExceptionSubscriber implements EventSubscriberInterface
147148
{
148149
public static function getSubscribedEvents()
149150
{
150151
// return the subscribed events, their methods and priorities
151152
return array(
152-
'kernel.exception' => array(
153+
KernelEvents::EXCEPTION => array(
153154
array('processException', 10),
154155
array('logException', 0),
155156
array('notifyException', -10),

cookbook/form/data_transformers.rst

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ to render the form, and then back into a ``DateTime`` object on submit.
1616
When a form field has the ``inherit_data`` option set, Data Transformers
1717
won't be applied to that field.
1818

19-
Simple Example: Sanitizing HTML on User Input
20-
---------------------------------------------
19+
.. _simple-example-sanitizing-html-on-user-input:
2120

22-
Suppose you have a Task form with a description ``textarea`` type::
21+
Simple Example: Transforming String Tags from User Input to an Array
22+
--------------------------------------------------------------------
23+
24+
Suppose you have a Task form with a tags ``text`` type::
2325

2426
// src/AppBundle/Form/TaskType.php
2527
namespace AppBundle\Form\Type;
@@ -32,7 +34,7 @@ Suppose you have a Task form with a description ``textarea`` type::
3234
{
3335
public function buildForm(FormBuilderInterface $builder, array $options)
3436
{
35-
$builder->add('description', 'textarea');
37+
$builder->add('tags', 'text')
3638
}
3739

3840
public function configureOptions(OptionsResolver $resolver)
@@ -45,15 +47,10 @@ Suppose you have a Task form with a description ``textarea`` type::
4547
// ...
4648
}
4749

48-
But, there are two complications:
49-
50-
#. Your users are allowed to use *some* HTML tags, but not others: you need a way
51-
to call :phpfunction:`strip_tags` after the form is submitted;
50+
Internally the ``tags`` are stored as an array, but displayed to the user as a
51+
simple comma seperated string to make them easier to edit.
5252

53-
#. To be friendly, you want to convert ``<br/>`` tags into line breaks (``\n``) before
54-
rendering the field so the text is easier to edit.
55-
56-
This is a *perfect* time to attach a custom data transformer to the ``description``
53+
This is a *perfect* time to attach a custom data transformer to the ``tags``
5754
field. The easiest way to do this is with the :class:`Symfony\\Component\\Form\\CallbackTransformer`
5855
class::
5956

@@ -68,20 +65,17 @@ class::
6865
{
6966
public function buildForm(FormBuilderInterface $builder, array $options)
7067
{
71-
$builder->add('description', 'textarea');
68+
$builder->add('tags', 'text');
7269

73-
$builder->get('description')
70+
$builder->get('tags')
7471
->addModelTransformer(new CallbackTransformer(
75-
// transform <br/> to \n so the textarea reads easier
76-
function ($originalDescription) {
77-
return preg_replace('#<br\s*/?>#i', "\n", $originalDescription);
72+
function ($tagsAsArray) {
73+
// transform the array to a string
74+
return implode(', ', $tagsAsArray);
7875
},
79-
function ($submittedDescription) {
80-
// remove most HTML tags (but not br,p)
81-
$cleaned = strip_tags($submittedDescription, '<br><br/><p>');
82-
83-
// transform any \n to real <br/>
84-
return str_replace("\n", '<br/>', $cleaned);
76+
function ($tagsAsString) {
77+
// transform the string back to an array
78+
return explode(', ', $tagsAsString);
8579
}
8680
))
8781
;
@@ -90,10 +84,10 @@ class::
9084
// ...
9185
}
9286

93-
The ``CallbackTransformer`` takes two callback functions as arguments. The first transforms
94-
the original value into a format that'll be used to render the field. The second
95-
does the reverse: it transforms the submitted value back into the format you'll use
96-
in your code.
87+
The ``CallbackTransformer`` takes two callback functions as arguments. The
88+
first transforms the original value into a format that'll be used to render the
89+
field. The second does the reverse: it transforms the submitted value back into
90+
the format you'll use in your code.
9791

9892
.. tip::
9993

@@ -105,7 +99,8 @@ You can also add the transformer, right when adding the field by changing the fo
10599
slightly::
106100

107101
$builder->add(
108-
$builder->create('description', 'textarea')
102+
$builder
103+
->create('tags', 'text')
109104
->addModelTransformer(...)
110105
);
111106

cookbook/form/form_collections.rst

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,18 @@ objects::
6969

7070
class Tag
7171
{
72-
public $name;
73-
}
72+
private $name;
7473

75-
.. tip::
74+
public function getName()
75+
{
76+
return $this->name;
77+
}
7678

77-
The ``name`` property is public here, but it can just as easily be protected
78-
or private (but then it would need ``getName`` and ``setName`` methods).
79+
public function setName($name)
80+
{
81+
$this->name = $name;
82+
}
83+
}
7984

8085
Then, create a form class so that a ``Tag`` object can be modified by the user::
8186

@@ -162,10 +167,10 @@ In your controller, you'll now initialize a new instance of ``TaskType``::
162167
// dummy code - this is here just so that the Task has some tags
163168
// otherwise, this isn't an interesting example
164169
$tag1 = new Tag();
165-
$tag1->name = 'tag1';
170+
$tag1->setName('tag1');
166171
$task->getTags()->add($tag1);
167172
$tag2 = new Tag();
168-
$tag2->name = 'tag2';
173+
$tag2->setName('tag2');
169174
$task->getTags()->add($tag2);
170175
// end dummy code
171176

cookbook/request/load_balancer_reverse_proxy.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ In this case, you'll need to - *very carefully* - trust *all* proxies.
9292
$response = $kernel->handle($request);
9393
// ...
9494

95-
#. Ensure that the trusted_proxies setting in your ``app/config/config.yml``
95+
#. Ensure that the trusted_proxies setting in your ``app/config/config.yml``
9696
is not set or it will overwrite the ``setTrustedProxies`` call above.
9797

9898
That's it! It's critical that you prevent traffic from all non-trusted sources.

create_framework/http_kernel_httpkernel_class.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,9 @@ only if needed::
150150
namespace Simplex;
151151

152152
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
153-
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
154153
use Symfony\Component\HttpFoundation\Response;
154+
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
155+
use Symfony\Component\HttpKernel\KernelEvents;
155156

156157
class StringResponseListener implements EventSubscriberInterface
157158
{
@@ -166,7 +167,7 @@ only if needed::
166167

167168
public static function getSubscribedEvents()
168169
{
169-
return array('kernel.view' => 'onView');
170+
return array(KernelEvents::VIEW => 'onView');
170171
}
171172
}
172173

0 commit comments

Comments
 (0)
0