Skip to content

Commit c7af8cf

Browse files
committed
Merge branch '3.2'
* 3.2: (24 commits) Minor rewords Update session_configuration.rst [#7522] minor wording improvement [#7513] fix line length Update 'ide' example in framework.rst [#7219] move versionadded in front of description Improved the image for Doctrine + Web Debug Toolbar [Serializer] Docs for the PropertyInfo integration Finished this PR section chronology in comment Removed the example about Redis Update cache.rst Update bundles/configuration.rst Fix typos Removed tip that was meant for the 2.x versions fix usage of the session flag bag API Add caution related to deprecate mail transport Use https URLs when possible [Requirements] Clarify what are JSON and ctype Proposed a minor reword ...
2 parents 3467fc1 + 9435c92 commit c7af8cf

File tree

17 files changed

+149
-31
lines changed

17 files changed

+149
-31
lines changed
49.9 KB
Loading
-43.1 KB
Binary file not shown.

bundles/configuration.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ bundle configuration would look like:
8383
<?xml version="1.0" ?>
8484
8585
<container xmlns="http://symfony.com/schema/dic/services"
86-
xmlns:acme-social="http://example.org/dic/schema/acme_social"
86+
xmlns:acme-social="http://example.org/schema/dic/acme_social"
8787
xsi:schemaLocation="http://symfony.com/schema/dic/services
8888
http://symfony.com/schema/dic/services/services-1.0.xsd">
8989

components/cache.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ concepts:
143143
**Adapter**
144144
It implements the actual caching mechanism to store the information in the
145145
filesystem, in a database, etc. The component provides several ready to use
146-
adapters for common caching backends (Redis, APCu, etc.)
146+
adapters for common caching backends (Redis, APCu, Doctrine, PDO, etc.)
147147

148148
Basic Usage (PSR-6)
149149
-------------------

components/cache/cache_invalidation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Cache Invalidation
77

88
Cache invalidation is the process of removing all cached items related to a
99
change in the state of your model. The most basic kind of invalidation is direct
10-
items deletion. But when the state of a primary resource has spread accross
10+
items deletion. But when the state of a primary resource has spread across
1111
several cached items, keeping them in sync can be difficult.
1212

1313
The Symfony Cache component provides two mechanisms to help solving this problem:

components/config/caching.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ should be regenerated::
3838
$resources = array();
3939

4040
foreach ($yamlUserFiles as $yamlUserFile) {
41-
// see the previous article "Loading resources" to
42-
// see where $delegatingLoader comes from
41+
// see the article "Loading resources" to
42+
// know where $delegatingLoader comes from
4343
$delegatingLoader->load($yamlUserFile);
4444
$resources[] = new FileResource($yamlUserFile);
4545
}

components/http_foundation/session_configuration.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,20 @@ the ``php.ini`` directive ``session.gc_maxlifetime``. The meaning in this contex
139139
that any stored session that was saved more than ``gc_maxlifetime`` ago should be
140140
deleted. This allows one to expire records based on idle time.
141141

142+
However, some operating systems do their own session handling and set the
143+
``session.gc_probability`` variable to ``0`` to stop PHP doing garbage
144+
collection. That's why Symfony now overwrites this value to ``1``.
145+
146+
If you wish to use the original value set in your ``php.ini``, add the following
147+
configuration:
148+
149+
.. code-block:: yaml
150+
151+
# config.yml
152+
framework:
153+
session:
154+
gc_probability: null
155+
142156
You can configure these settings by passing ``gc_probability``, ``gc_divisor``
143157
and ``gc_maxlifetime`` in an array to the constructor of
144158
:class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\NativeSessionStorage`

components/serializer.rst

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,74 @@ you indicate that you're expecting an array instead of a single object.
821821
$data = ...; // The serialized data from the previous example
822822
$persons = $serializer->deserialize($data, 'Acme\Person[]', 'json');
823823
824+
Recursive Denormalization and Type Safety
825+
-----------------------------------------
826+
827+
The Serializer Component can use the :doc:`PropertyInfo Component </components/property_info>` to denormalize
828+
complex types (objects). The type of the class' property will be guessed using the provided
829+
extractor and used to recursively denormalize the inner data.
830+
831+
When using the Symfony Standard Edition, all normalizers are automatically configured to use the registered extractors.
832+
When using the component standalone, an implementation of :class:`Symfony\\Component\\PropertyInfo\\PropertyTypeExtractorInterface`,
833+
(usually an instance of :class:`Symfony\\Component\\PropertyInfo\\PropertyInfoExtractor`) must be passed as the 4th
834+
parameter of the ``ObjectNormalizer``::
835+
836+
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
837+
use Symfony\Component\Serializer\Serializer;
838+
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
839+
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
840+
841+
namespace Acme;
842+
843+
class ObjectOuter
844+
{
845+
private $inner;
846+
private $date;
847+
848+
public function getInner()
849+
{
850+
return $this->inner;
851+
}
852+
853+
public function setInner(ObjectInner $inner)
854+
{
855+
$this->inner = $inner;
856+
}
857+
858+
public function setDate(\DateTimeInterface $date)
859+
{
860+
$this->date = $date;
861+
}
862+
863+
public function getDate()
864+
{
865+
return $this->date;
866+
}
867+
}
868+
869+
class ObjectInner
870+
{
871+
public $foo;
872+
public $bar;
873+
}
874+
875+
$normalizer = new ObjectNormalizer(null, null, null, new ReflectionExtractor()); //
876+
$serializer = new Serializer(array(new DateTimeNormalizer(), $normalizer));
877+
878+
$obj = $serializer->denormalize(
879+
array('inner' => array('foo' => 'foo', 'bar' => 'bar'), 'date' => '1988/01/21'),
880+
'Acme\ObjectOuter'
881+
);
882+
883+
dump($obj->getInner()->foo); // 'foo'
884+
dump($obj->getInner()->bar); // 'bar'
885+
dump($obj->getDate()->format('Y-m-d')); // '1988-01-21'
886+
887+
When a ``PropertyTypeExtractor`` is available, the normalizer will also check that the data to denormalize
888+
matches the type of the property (even for primitive types). For instance, if a ``string`` is provided, but
889+
the type of the property is ``int``, an :class:`Symfony\\Component\\Serializer\\Exception\\UnexpectedValueException`
890+
will be thrown.
891+
824892
Learn more
825893
----------
826894

controller.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,14 +436,14 @@ read any flash messages from the session:
436436
<!-- app/Resources/views/base.html.php -->
437437

438438
// you can read and display just one flash message type...
439-
<?php foreach ($view['session']->getFlash('notice') as $message): ?>
439+
<?php foreach ($view['session']->getFlashBag()->get('notice') as $message): ?>
440440
<div class="flash-notice">
441441
<?php echo $message ?>
442442
</div>
443443
<?php endforeach ?>
444444

445445
// ...or you can read and display every flash message available
446-
<?php foreach ($view['session']->getFlashes() as $type => $flash_messages): ?>
446+
<?php foreach ($view['session']->getFlashBag()->all() as $type => $flash_messages): ?>
447447
<?php foreach ($flash_messages as $flash_message): ?>
448448
<div class="flash-<?php echo $type ?>">
449449
<?php echo $message ?>

controller/service.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,12 +336,6 @@ controller:
336336
337337
return new StreamedResponse($callback);
338338
339-
.. tip::
340-
341-
``getRequest()`` has been deprecated. Instead, have an argument to your
342-
controller action method called ``Request $request``. The order of the
343-
parameters is not important, but the typehint must be provided.
344-
345339
.. _`Controller class source code`: https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php
346340
.. _`base Controller class`: https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php
347341
.. _`FrameworkExtraBundle documentation`: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/routing.html#controller-as-service

0 commit comments

Comments
 (0)