Skip to content

Commit 9766699

Browse files
committed
Merge branch '2.1' into 2.2
2 parents 85a6d22 + beb3665 commit 9766699

File tree

10 files changed

+110
-15
lines changed

10 files changed

+110
-15
lines changed

components/filesystem.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ Return the relative path of a directory given another one::
204204
'/var/lib/symfony/src/Symfony/Component'
205205
);
206206
// returns 'videos'
207-
$fs->makePathRelative('/tmp', '/tmp/videos');
207+
$fs->makePathRelative('/tmp/videos', '/tmp')
208208

209209
mirror
210210
~~~~~~

components/http_foundation/trusting_proxies.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ your proxy::
1818

1919
$request = Request::createFromGlobals();
2020
// only trust proxy headers coming from this IP address
21-
$request->setTrustedProxies(array(192.0.0.1));
21+
$request->setTrustedProxies(array('192.0.0.1'));
2222

2323
Configuring Header Names
2424
------------------------

cookbook/form/dynamic_form_modification.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ This can be used to get the ``SportMeetup`` id and retrieve it from the database
458458
given you have a reference to the object manager (if using doctrine). In
459459
the end, you have an event subscriber that listens to two different events,
460460
requires some external services and customizes the form. In such a situation,
461-
it's probably better to define this as a service rather than using an anonymouse
461+
it's probably better to define this as a service rather than using an anonymous
462462
function as the event listener callback.
463463

464464
The subscriber would now look like::

cookbook/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ The Cookbook
1313
validation/index
1414
configuration/index
1515
service_container/index
16+
session/index
1617
bundles/index
1718
email/index
1819
testing/index

cookbook/map.rst.inc

+4
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@
133133
* :doc:`/cookbook/service_container/scopes`
134134
* :doc:`/cookbook/service_container/compiler_passes`
135135

136+
* :doc:`/cookbook/session/index`
137+
138+
* :doc:`/cookbook/session/proxy_examples`
139+
136140
* **symfony1**
137141

138142
* :doc:`/cookbook/symfony1`

cookbook/session/index.rst

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Sessions
2+
========
3+
4+
.. toctree::
5+
:maxdepth: 2
6+
7+
proxy_examples

cookbook/session/proxy_examples.rst

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
.. index::
2+
single: Sessions, session proxy, proxy
3+
4+
Session Proxy Examples
5+
----------------------
6+
7+
The session proxy mechanism has a variety of uses and this example demonstrates
8+
two common uses. Rather than injecting the session handler as normal, a handler
9+
is injected into the proxy and registered with the session storage driver::
10+
11+
use Symfony\Component\HttpFoundation\Session\Session;
12+
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
13+
use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionStorage;
14+
15+
$proxy = new YourProxy(new PdoSessionStorage());
16+
$session = new Session(new NativeSessionStorage($proxy));
17+
18+
Below, you'll learn two real examples that can be used for ``YourProxy``:
19+
encryption of session data and readonly guest session.
20+
21+
Encryption of Session Data
22+
--------------------------
23+
24+
If you wanted to encrypt the session data, you could use the proxy to encrypt
25+
and decrypt the session as required::
26+
27+
use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy;
28+
29+
class EncryptedSessionProxy extends SessionHandlerProxy
30+
{
31+
private $key;
32+
33+
public function __construct(\SessionHandlerInterface $handler, $key)
34+
{
35+
$this->key = $key;
36+
37+
parent::__construct($handler);
38+
}
39+
40+
public function read($id)
41+
{
42+
$data = parent::write($id, $data);
43+
44+
return mcrypt_decrypt(\MCRYPT_3DES, $this->key, $data);
45+
}
46+
47+
public function write($id, $data)
48+
{
49+
$data = mcrypt_encrypt(\MCRYPT_3DES, $this->key, $data);
50+
51+
return parent::write($id, $data);
52+
}
53+
}
54+
55+
Readonly Guest Sessions
56+
-----------------------
57+
58+
There are some applications where a session is required for guest users, but
59+
there is no particular need to persist the session. In this case you can
60+
intercept the session before it writes::
61+
62+
use Foo\User;
63+
use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy;
64+
65+
class ReadOnlyGuestSessionProxy extends SessionHandlerProxy
66+
{
67+
private $user;
68+
69+
public function __construct(\SessionHandlerInterface $handler, User $user)
70+
{
71+
$this->user = $user;
72+
73+
parent::__construct($handler);
74+
}
75+
76+
public function write($id, $data)
77+
{
78+
if ($this->user->isGuest()) {
79+
return;
80+
}
81+
82+
return parent::write($id, $data);
83+
}
84+
}

reference/configuration/framework.rst

+9
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Configuration
2626
* enabled
2727
* field_name
2828
* `session`_
29+
* `name`_
2930
* `cookie_lifetime`_
3031
* `cookie_path`_
3132
* `cookie_domain`_
@@ -148,6 +149,14 @@ csrf_protection
148149
session
149150
~~~~~~~
150151

152+
name
153+
....
154+
155+
**type**: ``string`` **default**: ``null``
156+
157+
This specifies the name of the session cookie. By default it will use the cookie
158+
name which is defined in the ``php.ini`` with the ``session.name`` directive.
159+
151160
cookie_lifetime
152161
...............
153162

reference/constraints/Range.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ the following:
5151
{
5252
/**
5353
* @Assert\Range(
54-
* min = "120",
55-
* max = "180",
54+
* min = 120,
55+
* max = 180,
5656
* minMessage = "You must be at least 120cm tall to enter",
5757
* maxMessage = "You cannot be taller than 180cm to enter"
5858
* )

reference/dic_tags.rst

-10
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ may also be tags in other bundles you use that aren't listed here.
5555
+-----------------------------------+---------------------------------------------------------------------------+
5656
| `security.remember_me_aware`_ | To allow remember me authentication |
5757
+-----------------------------------+---------------------------------------------------------------------------+
58-
| `security.listener.factory`_ | Necessary when creating a custom authentication system |
59-
+-----------------------------------+---------------------------------------------------------------------------+
6058
| `swiftmailer.plugin`_ | Register a custom SwiftMailer Plugin |
6159
+-----------------------------------+---------------------------------------------------------------------------+
6260
| `templating.helper`_ | Make your service available in PHP templates |
@@ -711,14 +709,6 @@ of your configuration, and tag it with ``routing.loader``:
711709
712710
For more information, see :doc:`/cookbook/routing/custom_route_loader`.
713711
714-
security.listener.factory
715-
-------------------------
716-
717-
**Purpose**: Necessary when creating a custom authentication system
718-
719-
This tag is used when creating your own custom authentication system. For
720-
details, see :doc:`/cookbook/security/custom_authentication_provider`.
721-
722712
security.remember_me_aware
723713
--------------------------
724714

0 commit comments

Comments
 (0)