Skip to content

Commit

Permalink
Merge branch '2.7' into 2.8
Browse files Browse the repository at this point in the history
* 2.7:
  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
  Fix UrlMatcher::match() URL
  • Loading branch information
javiereguiluz committed Feb 10, 2018
2 parents e808790 + 5242e92 commit 5ea29a5
Show file tree
Hide file tree
Showing 35 changed files with 57 additions and 52 deletions.
2 changes: 1 addition & 1 deletion best_practices/controllers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ for the homepage of our app:
->findLatest();
return $this->render('default/index.html.twig', array(
'posts' => $posts
'posts' => $posts,
));
}
}
Expand Down
2 changes: 1 addition & 1 deletion best_practices/forms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ some developers configure form buttons in the controller::
$form = $this->createForm(PostType::class, $post);
$form->add('submit', SubmitType::class, array(
'label' => 'Create',
'attr' => array('class' => 'btn btn-default pull-right')
'attr' => array('class' => 'btn btn-default pull-right'),
));

// ...
Expand Down
2 changes: 1 addition & 1 deletion components/dom_crawler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ Pass an array of values::
// sets multiple fields at once
$form->setValues(array('multi' => array(
1 => 'value',
'dimensional' => 'an other value'
'dimensional' => 'an other value',
)));

This is great, but it gets better! The ``Form`` object allows you to interact
Expand Down
2 changes: 1 addition & 1 deletion components/http_foundation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ class, which can make this even easier::

$response = new JsonResponse();
$response->setData(array(
'data' => 123
'data' => 123,
));

This encodes your array of data to JSON and sets the ``Content-Type`` header
Expand Down
2 changes: 1 addition & 1 deletion components/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ URL path and some array of custom variables in its constructor. This array
of custom variables can be *anything* that's significant to your application,
and is returned when that route is matched.

The :method:`UrlMatcher::match() <Symfony\\Component\\Routing\\UrlMatcher::match>`
The :method:`UrlMatcher::match() <Symfony\\Component\\Routing\\Matcher\\UrlMatcher::match>`
returns the variables you set on the route as well as the wildcard placeholders
(see below). Your application can now use this information to continue
processing the request. In addition to the configured variables, a ``_route``
Expand Down
15 changes: 9 additions & 6 deletions components/serializer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,10 @@ There are several types of normalizers available:
directly and through getters, setters, hassers, adders and removers. It supports
calling the constructor during the denormalization process.

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

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

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

:class:`Symfony\\Component\\Serializer\\Normalizer\\PropertyNormalizer`
This normalizer directly reads and writes public properties as well as
Expand Down Expand Up @@ -596,7 +598,8 @@ Circular references are common when dealing with entity relations::
}

To avoid infinite loops, :class:`Symfony\\Component\\Serializer\\Normalizer\\GetSetMethodNormalizer`
throws a :class:`Symfony\\Component\\Serializer\\Exception\\CircularReferenceException`
or :class:`Symfony\\Component\\Serializer\\Normalizer\\ObjectNormalizer`
throw a :class:`Symfony\\Component\\Serializer\\Exception\\CircularReferenceException`
when such a case is encountered::

$member = new Member();
Expand Down
3 changes: 1 addition & 2 deletions components/translation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ The constructor of the ``Translator`` class needs one argument: The locale.
.. code-block:: php
use Symfony\Component\Translation\Translator;
use Symfony\Component\Translation\MessageSelector;
$translator = new Translator('fr_FR', new MessageSelector());
$translator = new Translator('fr_FR');
.. note::

Expand Down
1 change: 0 additions & 1 deletion configuration/environments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ configuration file:
$container->loadFromExtension('web_profiler', array(
'toolbar' => true,
// ...
));
Expand Down
1 change: 0 additions & 1 deletion console/style.rst
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,6 @@ of your commands to change their appearance::

// After
$io = new CustomStyle($input, $output);

// ...
}
}
2 changes: 1 addition & 1 deletion doctrine/event_listeners_subscribers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ managers that use this connection.
->register('my.listener2', SearchIndexer2::class)
->addTag('doctrine.event_listener', array(
'event' => 'postPersist',
'connection' => 'default'
'connection' => 'default',
))
;
$container
Expand Down
2 changes: 1 addition & 1 deletion email/spool.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ swiftmailer with the memory option, use the following configuration:
// app/config/config.php
$container->loadFromExtension('swiftmailer', array(
// ...
'spool' => array('type' => 'memory')
'spool' => array('type' => 'memory'),
));
.. _spool-using-a-file:
Expand Down
2 changes: 1 addition & 1 deletion form/form_dependencies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ create your form::
{
$task = ...;
$form = $this->createForm(TaskType::class, $task, array(
'entity_manager' => $this->get('doctrine.orm.entity_manager')
'entity_manager' => $this->get('doctrine.orm.entity_manager'),
));

// ...
Expand Down
2 changes: 1 addition & 1 deletion form/inherit_data_option.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ for that::
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'inherit_data' => true
'inherit_data' => true,
));
}
}
Expand Down
7 changes: 7 additions & 0 deletions forms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,13 @@ the choice is ultimately up to you.

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


.. note::

The form name is automatically generated from the type class name. If you want
to modify it, use the :method:`Symfony\\Component\\Form\\FormFactoryInterface::createNamed` method.
You can even suppress the name completely by setting it to an empty string.

Final Thoughts
--------------

Expand Down
2 changes: 1 addition & 1 deletion http_cache/validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ exposing a simple and efficient pattern::
// or render a template with the $response you've already started
return $this->render('article/show.html.twig', array(
'article' => $article,
'comments' => $comments
'comments' => $comments,
), $response);
}
}
Expand Down
6 changes: 3 additions & 3 deletions quick_tour/the_controller.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ a new method called ``helloAction()`` with the following content::
public function helloAction($name)
{
return $this->render('default/hello.html.twig', array(
'name' => $name
'name' => $name,
));
}
}
Expand Down Expand Up @@ -125,7 +125,7 @@ as its default value::
public function helloAction($name, $_format)
{
return $this->render('default/hello.'.$_format.'.twig', array(
'name' => $name
'name' => $name,
));
}

Expand Down Expand Up @@ -168,7 +168,7 @@ option of the ``@Route()`` annotation::
public function helloAction($name, $_format)
{
return $this->render('default/hello.'.$_format.'.twig', array(
'name' => $name
'name' => $name,
));
}

Expand Down
4 changes: 2 additions & 2 deletions quick_tour/the_view.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ on its type:
{# 1. Simple variables #}
{# $this->render('template.html.twig', array(
'name' => 'Fabien')
) #}
'name' => 'Fabien',
)) #}
{{ name }}
{# 2. Arrays #}
Expand Down
2 changes: 1 addition & 1 deletion reference/configuration/framework.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,7 @@ Assume you have custom global form themes in
'templating' => array(
'form' => array(
'resources' => array(
'WebsiteBundle:Form'
'WebsiteBundle:Form',
),
),
),
Expand Down
4 changes: 2 additions & 2 deletions reference/configuration/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -675,11 +675,11 @@ multiple firewalls, the "context" could actually be shared:
'firewalls' => array(
'somename' => array(
// ...
'context' => 'my_context'
'context' => 'my_context',
),
'othername' => array(
// ...
'context' => 'my_context'
'context' => 'my_context',
),
),
));
Expand Down
2 changes: 1 addition & 1 deletion reference/constraints/CardScheme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ on an object that will contain a credit card number.
{
$metadata->addPropertyConstraint('cardNumber', new Assert\CardScheme(array(
'schemes' => array(
'VISA'
'VISA',
),
'message' => 'Your credit card number is invalid.',
)));
Expand Down
2 changes: 1 addition & 1 deletion reference/constraints/Isbn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ on an object that will contain an ISBN.
{
$metadata->addPropertyConstraint('isbn', new Assert\Isbn(array(
'type' => 'isbn10',
'message' => 'This value is not valid.'
'message' => 'This value is not valid.',
)));
}
}
Expand Down
8 changes: 4 additions & 4 deletions reference/forms/types/collection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ address as its own input text box::

$builder->add('emails', CollectionType::class, array(
// each entry in the array will be an "email" field
'entry_type' => EmailType::class,
'entry_type' => EmailType::class,
// these options are passed to each "email" type
'entry_options' => array(
'attr' => array('class' => 'email-box')
'entry_options' => array(
'attr' => array('class' => 'email-box'),
),
));

Expand Down Expand Up @@ -211,7 +211,7 @@ And update the template as follows:
{% endfor %}
</ul>
<a href="#"
<a href="#"
class="add-another-collection-widget"
data-list="#email-field-list">Add another email</a>

Expand Down
2 changes: 1 addition & 1 deletion reference/forms/types/date.rst
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ values for the year, month and day fields::

$builder->add('dueDate', DateType::class, array(
'placeholder' => array(
'year' => 'Year', 'month' => 'Month', 'day' => 'Day'
'year' => 'Year', 'month' => 'Month', 'day' => 'Day',
)
));

Expand Down
2 changes: 1 addition & 1 deletion reference/forms/types/options/group_by.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Take the following example::
'now' => new \DateTime('now'),
'tomorrow' => new \DateTime('+1 day'),
'1 week' => new \DateTime('+1 week'),
'1 month' => new \DateTime('+1 month')
'1 month' => new \DateTime('+1 month'),
),
'choices_as_values' => true,
'group_by' => function($val, $key, $index) {
Expand Down
6 changes: 3 additions & 3 deletions reference/forms/types/options/preferred_choices.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ you can list the most popular on top, like Bork Bork and Pirate::
'English' => 'en',
'Spanish' => 'es',
'Bork' => 'muppets',
'Pirate' => 'arr'
'Pirate' => 'arr',
),
'choices_as_values' => true,
'preferred_choices' => array('muppets', 'arr')
'preferred_choices' => array('muppets', 'arr'),
));

.. versionadded:: 2.7
Expand All @@ -35,7 +35,7 @@ be especially useful if your values are objects::
'now' => new \DateTime('now'),
'tomorrow' => new \DateTime('+1 day'),
'1 week' => new \DateTime('+1 week'),
'1 month' => new \DateTime('+1 month')
'1 month' => new \DateTime('+1 month'),
),
'choices_as_values' => true,
'preferred_choices' => function ($val, $key) {
Expand Down
2 changes: 1 addition & 1 deletion routing/requirements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ a routing ``{wildcard}`` to only match some regular expression:
$collection->add('blog_list', new Route('/blog/{page}', array(
'_controller' => 'AppBundle:Blog:list',
), array(
'page' => '\d+'
'page' => '\d+',
)));
// ...
Expand Down
4 changes: 2 additions & 2 deletions security/access_control.rst
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,11 @@ pattern so that it is only accessible by requests from the local server itself:
array(
'path' => '^/internal',
'role' => 'IS_AUTHENTICATED_ANONYMOUSLY',
'ips' => '127.0.0.1, ::1'
'ips' => '127.0.0.1, ::1',
),
array(
'path' => '^/internal',
'role' => 'ROLE_NO_ACCESS'
'role' => 'ROLE_NO_ACCESS',
),
),
));
Expand Down
2 changes: 1 addition & 1 deletion security/csrf_in_login_form.rst
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ After this, you have protected your login form against CSRF attacks.
'form_login' => array(
// ...
'csrf_parameter' => '_csrf_security_token',
'csrf_token_id' => 'a_private_string'
'csrf_token_id' => 'a_private_string',
),
),
),
Expand Down
4 changes: 2 additions & 2 deletions security/entity_provider.rst
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,14 @@ so you only need the new interface::
{
return serialize(array(
// ...
$this->isActive
$this->isActive,
));
}
public function unserialize($serialized)
{
list (
// ...
$this->isActive
$this->isActive,
) = unserialize($serialized);
}
}
Expand Down
2 changes: 1 addition & 1 deletion security/impersonating_user.rst
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ the sticky locale:
->register('app.switch_user_listener', SwitchUserListener::class)
->addTag('kernel.event_listener', array(
'event' => 'security.switch_user',
'method' => 'onSwitchUser'
'method' => 'onSwitchUser',
))
;
Expand Down
4 changes: 2 additions & 2 deletions security/named_encoders.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ named encoders:
'encoders' => array(
'harsh' => array(
'algorithm' => 'bcrypt',
'cost' => '15'
'cost' => '15',
),
),
));
Expand Down Expand Up @@ -165,7 +165,7 @@ you must register a service for it in order to use it as a named encoder:
// ...
'encoders' => array(
'app_encoder' => array(
'id' => 'app.password_encoder_service'
'id' => 'app.password_encoder_service',
),
),
));
Expand Down
2 changes: 1 addition & 1 deletion service_container/definitions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fetched from the container::

$definition = new Definition(DoctrineConfigManager::class, array(
new Reference('doctrine'), // a reference to another service
'%app.config_table_name%' // will be resolved to the value of a container parameter
'%app.config_table_name%', // will be resolved to the value of a container parameter
));

// gets all arguments configured for this definition
Expand Down
Loading

0 comments on commit 5ea29a5

Please sign in to comment.