Skip to content

Commit 0c53298

Browse files
committed
Merge branch '2.8' into 3.4
* 2.8: Fix missing trailling commas [Serializer] Added missing ObjectNormalizer [Serializer] By default the serializer do not convert to lower case properties Added a note about named form types Update translation.rst Fixed the path of an image Fix UrlMatcher::match() URL Updated a diagram to SVG format
2 parents 903189f + 5ea29a5 commit 0c53298

35 files changed

+78
-69
lines changed
-62.8 KB
Binary file not shown.

_images/security/authentication-guard-methods.svg

Lines changed: 1 addition & 0 deletions
Loading
Binary file not shown.

best_practices/controllers.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ for the homepage of our app:
111111
->findLatest();
112112
113113
return $this->render('default/index.html.twig', array(
114-
'posts' => $posts
114+
'posts' => $posts,
115115
));
116116
}
117117
}

best_practices/forms.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ some developers configure form buttons in the controller::
127127
$form = $this->createForm(PostType::class, $post);
128128
$form->add('submit', SubmitType::class, array(
129129
'label' => 'Create',
130-
'attr' => array('class' => 'btn btn-default pull-right')
130+
'attr' => array('class' => 'btn btn-default pull-right'),
131131
));
132132

133133
// ...

components/dom_crawler.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ Pass an array of values::
470470
// sets multiple fields at once
471471
$form->setValues(array('multi' => array(
472472
1 => 'value',
473-
'dimensional' => 'an other value'
473+
'dimensional' => 'an other value',
474474
)));
475475

476476
This is great, but it gets better! The ``Form`` object allows you to interact

components/routing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ URL path and some array of custom variables in its constructor. This array
6262
of custom variables can be *anything* that's significant to your application,
6363
and is returned when that route is matched.
6464

65-
The :method:`UrlMatcher::match() <Symfony\\Component\\Routing\\UrlMatcher::match>`
65+
The :method:`UrlMatcher::match() <Symfony\\Component\\Routing\\Matcher\\UrlMatcher::match>`
6666
returns the variables you set on the route as well as the wildcard placeholders
6767
(see below). Your application can now use this information to continue
6868
processing the request. In addition to the configured variables, a ``_route``

components/serializer.rst

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -554,9 +554,10 @@ There are several types of normalizers available:
554554
directly and through getters, setters, hassers, adders and removers. It supports
555555
calling the constructor during the denormalization process.
556556

557-
Objects are normalized to a map of property names (method name stripped of
558-
the "get"/"set"/"has"/"remove" prefix and converted to lower case) to property
559-
values.
557+
Objects are normalized to a map of property names and values (names are
558+
generated removing the ``get``, ``set``, ``has`` or ``remove`` prefix from
559+
the method name and lowercasing the first letter; e.g. ``getFirstName()`` ->
560+
``firstName``).
560561

561562
The ``ObjectNormalizer`` is the most powerful normalizer. It is configured by
562563
default when using the Symfony Standard Edition with the serializer enabled.
@@ -566,8 +567,9 @@ There are several types of normalizers available:
566567
(public methods starting with "get"). It will denormalize data by calling
567568
the constructor and the "setters" (public methods starting with "set").
568569

569-
Objects are normalized to a map of property names (method name stripped of
570-
the "get" prefix and converted to lower case) to property values.
570+
Objects are normalized to a map of property names and values (names are
571+
generated removing the ``get`` prefix from the method name and lowercasing
572+
the first letter; e.g. ``getFirstName()`` -> ``firstName``).
571573

572574
:class:`Symfony\\Component\\Serializer\\Normalizer\\PropertyNormalizer`
573575
This normalizer directly reads and writes public properties as well as
@@ -699,7 +701,8 @@ Circular references are common when dealing with entity relations::
699701
}
700702

701703
To avoid infinite loops, :class:`Symfony\\Component\\Serializer\\Normalizer\\GetSetMethodNormalizer`
702-
throws a :class:`Symfony\\Component\\Serializer\\Exception\\CircularReferenceException`
704+
or :class:`Symfony\\Component\\Serializer\\Normalizer\\ObjectNormalizer`
705+
throw a :class:`Symfony\\Component\\Serializer\\Exception\\CircularReferenceException`
703706
when such a case is encountered::
704707

705708
$member = new Member();

components/translation.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ The constructor of the ``Translator`` class needs one argument: The locale.
3434
.. code-block:: php
3535
3636
use Symfony\Component\Translation\Translator;
37-
use Symfony\Component\Translation\MessageSelector;
3837
39-
$translator = new Translator('fr_FR', new MessageSelector());
38+
$translator = new Translator('fr_FR');
4039
4140
.. note::
4241

configuration/environments.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ configuration file:
139139
140140
$container->loadFromExtension('web_profiler', array(
141141
'toolbar' => true,
142-
143142
// ...
144143
));
145144

console/style.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,6 @@ of your commands to change their appearance::
369369

370370
// After
371371
$io = new CustomStyle($input, $output);
372-
373372
// ...
374373
}
375374
}

doctrine/event_listeners_subscribers.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ managers that use this connection.
7878
$container->autowire(SearchIndexer2::class)
7979
->addTag('doctrine.event_listener', array(
8080
'event' => 'postPersist',
81-
'connection' => 'default'
81+
'connection' => 'default',
8282
))
8383
;
8484
$container->autowire(SearchIndexerSubscriber::class)

email/spool.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ swiftmailer with the memory option, use the following configuration:
5252
// app/config/config.php
5353
$container->loadFromExtension('swiftmailer', array(
5454
// ...
55-
'spool' => array('type' => 'memory')
55+
'spool' => array('type' => 'memory'),
5656
));
5757
5858
.. _spool-using-a-file:

form/inherit_data_option.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ for that::
106106
public function configureOptions(OptionsResolver $resolver)
107107
{
108108
$resolver->setDefaults(array(
109-
'inherit_data' => true
109+
'inherit_data' => true,
110110
));
111111
}
112112
}

forms.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,13 @@ the choice is ultimately up to you.
683683

684684
$form->get('agreeTerms')->setData(true);
685685

686+
687+
.. note::
688+
689+
The form name is automatically generated from the type class name. If you want
690+
to modify it, use the :method:`Symfony\\Component\\Form\\FormFactoryInterface::createNamed` method.
691+
You can even suppress the name completely by setting it to an empty string.
692+
686693
Final Thoughts
687694
--------------
688695

http_cache/validation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ exposing a simple and efficient pattern::
218218
// or render a template with the $response you've already started
219219
return $this->render('article/show.html.twig', array(
220220
'article' => $article,
221-
'comments' => $comments
221+
'comments' => $comments,
222222
), $response);
223223
}
224224
}

quick_tour/the_controller.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ a new method called ``helloAction()`` with the following content::
7070
public function helloAction($name)
7171
{
7272
return $this->render('default/hello.html.twig', array(
73-
'name' => $name
73+
'name' => $name,
7474
));
7575
}
7676
}
@@ -124,7 +124,7 @@ as its default value::
124124
public function helloAction($name, $_format)
125125
{
126126
return $this->render('default/hello.'.$_format.'.twig', array(
127-
'name' => $name
127+
'name' => $name,
128128
));
129129
}
130130

@@ -167,7 +167,7 @@ option of the ``@Route()`` annotation::
167167
public function helloAction($name, $_format)
168168
{
169169
return $this->render('default/hello.'.$_format.'.twig', array(
170-
'name' => $name
170+
'name' => $name,
171171
));
172172
}
173173

quick_tour/the_view.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ on its type:
6868
6969
{# 1. Simple variables #}
7070
{# $this->render('template.html.twig', array(
71-
'name' => 'Fabien')
72-
) #}
71+
'name' => 'Fabien',
72+
)) #}
7373
{{ name }}
7474
7575
{# 2. Arrays #}

reference/configuration/framework.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@ Assume you have custom global form themes in
14621462
'templating' => array(
14631463
'form' => array(
14641464
'resources' => array(
1465-
'WebsiteBundle:Form'
1465+
'WebsiteBundle:Form',
14661466
),
14671467
),
14681468
),

reference/configuration/security.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -739,11 +739,11 @@ multiple firewalls, the "context" could actually be shared:
739739
'firewalls' => array(
740740
'somename' => array(
741741
// ...
742-
'context' => 'my_context'
742+
'context' => 'my_context',
743743
),
744744
'othername' => array(
745745
// ...
746-
'context' => 'my_context'
746+
'context' => 'my_context',
747747
),
748748
),
749749
));

reference/constraints/CardScheme.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ on an object that will contain a credit card number.
8989
{
9090
$metadata->addPropertyConstraint('cardNumber', new Assert\CardScheme(array(
9191
'schemes' => array(
92-
'VISA'
92+
'VISA',
9393
),
9494
'message' => 'Your credit card number is invalid.',
9595
)));

reference/constraints/Isbn.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ on an object that will contain an ISBN.
8989
{
9090
$metadata->addPropertyConstraint('isbn', new Assert\Isbn(array(
9191
'type' => 'isbn10',
92-
'message' => 'This value is not valid.'
92+
'message' => 'This value is not valid.',
9393
)));
9494
}
9595
}

reference/forms/types/collection.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ address as its own input text box::
5959

6060
$builder->add('emails', CollectionType::class, array(
6161
// each entry in the array will be an "email" field
62-
'entry_type' => EmailType::class,
62+
'entry_type' => EmailType::class,
6363
// these options are passed to each "email" type
64-
'entry_options' => array(
65-
'attr' => array('class' => 'email-box')
64+
'entry_options' => array(
65+
'attr' => array('class' => 'email-box'),
6666
),
6767
));
6868

reference/forms/types/date.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ values for the year, month and day fields::
152152

153153
$builder->add('dueDate', DateType::class, array(
154154
'placeholder' => array(
155-
'year' => 'Year', 'month' => 'Month', 'day' => 'Day'
155+
'year' => 'Year', 'month' => 'Month', 'day' => 'Day',
156156
)
157157
));
158158

reference/forms/types/options/group_by.rst.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Take the following example::
2020
'now' => new \DateTime('now'),
2121
'tomorrow' => new \DateTime('+1 day'),
2222
'1 week' => new \DateTime('+1 week'),
23-
'1 month' => new \DateTime('+1 month')
23+
'1 month' => new \DateTime('+1 month'),
2424
),
2525
'group_by' => function($val, $key, $index) {
2626
if ($val <= new \DateTime('+3 days')) {

reference/forms/types/options/preferred_choices.rst.inc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ you can list the most popular on top, like Bork Bork and Pirate::
1515
'English' => 'en',
1616
'Spanish' => 'es',
1717
'Bork' => 'muppets',
18-
'Pirate' => 'arr'
18+
'Pirate' => 'arr',
1919
),
20-
'preferred_choices' => array('muppets', 'arr')
20+
'preferred_choices' => array('muppets', 'arr'),
2121
));
2222

2323
This options can also be a callback function to give you more flexibility. This might
@@ -31,7 +31,7 @@ be especially useful if your values are objects::
3131
'now' => new \DateTime('now'),
3232
'tomorrow' => new \DateTime('+1 day'),
3333
'1 week' => new \DateTime('+1 week'),
34-
'1 month' => new \DateTime('+1 month')
34+
'1 month' => new \DateTime('+1 month'),
3535
),
3636
'preferred_choices' => function ($val, $key) {
3737
// prefer options within 3 days

routing/requirements.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ a routing ``{wildcard}`` to only match some regular expression:
6565
$collection->add('blog_list', new Route('/blog/{page}', array(
6666
'_controller' => 'AppBundle:Blog:list',
6767
), array(
68-
'page' => '\d+'
68+
'page' => '\d+',
6969
)));
7070
7171
// ...

security/access_control.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,11 @@ pattern so that it is only accessible by requests from the local server itself:
209209
array(
210210
'path' => '^/internal',
211211
'role' => 'IS_AUTHENTICATED_ANONYMOUSLY',
212-
'ips' => '127.0.0.1, ::1'
212+
'ips' => '127.0.0.1, ::1',
213213
),
214214
array(
215215
'path' => '^/internal',
216-
'role' => 'ROLE_NO_ACCESS'
216+
'role' => 'ROLE_NO_ACCESS',
217217
),
218218
),
219219
));

security/csrf_in_login_form.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ After this, you have protected your login form against CSRF attacks.
217217
'form_login' => array(
218218
// ...
219219
'csrf_parameter' => '_csrf_security_token',
220-
'csrf_token_id' => 'a_private_string'
220+
'csrf_token_id' => 'a_private_string',
221221
),
222222
),
223223
),

security/entity_provider.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,14 +371,14 @@ so you only need the new interface::
371371
{
372372
return serialize(array(
373373
// ...
374-
$this->isActive
374+
$this->isActive,
375375
));
376376
}
377377
public function unserialize($serialized)
378378
{
379379
list (
380380
// ...
381-
$this->isActive
381+
$this->isActive,
382382
) = unserialize($serialized);
383383
}
384384
}

security/guard_authentication.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,9 @@ Each authenticator needs the following methods:
424424

425425
The picture below shows how Symfony calls Guard Authenticator methods:
426426

427-
.. image:: /_images/security/authentication-guard-methods.png
428-
:align: center
427+
.. raw:: html
428+
429+
<object data="../_images/security/authentication-guard-methods.svg" type="image/svg+xml"></object>
429430

430431
.. _guard-customize-error:
431432

security/impersonating_user.rst

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -185,32 +185,32 @@ The :doc:`/session/locale_sticky_session` article does not update the locale
185185
when you impersonate a user. If you *do* want to be sure to update the locale when
186186
you switch users, add an event subscriber on this event::
187187

188-
// src/AppBundle/EventListener/SwitchUserListener.php
189-
namespace AppBundle\EventListener;
188+
// src/AppBundle/EventListener/SwitchUserListener.php
189+
namespace AppBundle\EventListener;
190190

191-
use Symfony\Component\Security\Http\Event\SwitchUserEvent;
192-
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
193-
use Symfony\Component\Security\Http\SecurityEvents;
191+
use Symfony\Component\Security\Http\Event\SwitchUserEvent;
192+
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
193+
use Symfony\Component\Security\Http\SecurityEvents;
194194

195-
class SwitchUserSubscriber implements EventSubscriberInterface
195+
class SwitchUserSubscriber implements EventSubscriberInterface
196+
{
197+
public function onSwitchUser(SwitchUserEvent $event)
196198
{
197-
public function onSwitchUser(SwitchUserEvent $event)
198-
{
199-
$event->getRequest()->getSession()->set(
200-
'_locale',
201-
// assuming your User has some getLocale() method
202-
$event->getTargetUser()->getLocale()
203-
);
204-
}
199+
$event->getRequest()->getSession()->set(
200+
'_locale',
201+
// assuming your User has some getLocale() method
202+
$event->getTargetUser()->getLocale()
203+
);
204+
}
205205

206-
public static function getSubscribedEvents()
207-
{
208-
return array(
209-
// constant for security.switch_user
210-
SecurityEvents::SWITCH_USER => 'onSwitchUser',
211-
);
212-
}
206+
public static function getSubscribedEvents()
207+
{
208+
return array(
209+
// constant for security.switch_user
210+
SecurityEvents::SWITCH_USER => 'onSwitchUser',
211+
);
213212
}
213+
}
214214

215215
That's it! If you're using the :ref:`default services.yml configuration <service-container-services-load-example>`,
216216
Symfony will automatically discover your service and call ``onSwitchUser`` whenever

0 commit comments

Comments
 (0)