Skip to content

Commit ad6ac14

Browse files
authored
Merge pull request #2 from ezsystems/forward_compatability
Use Symfony's namespace for backported features for full 4.x forward compatibility
2 parents 1c40277 + ee8d0f0 commit ad6ac14

File tree

4 files changed

+28
-14
lines changed

4 files changed

+28
-14
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
}
1111
],
1212
"autoload": {
13+
"classmap": ["src/lib/Symfony"],
1314
"psr-4": {
1415
"EzSystems\\SymfonyToolsBundle\\": "src/bundle/",
1516
"EzSystems\\SymfonyTools\\": "src/lib/"

doc/RedisSessionHandler.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ This feature has been backported from Symfony 4. The `RedisSessionHandler` allow
44
Last revision: https://github.com/symfony/symfony/commit/239a022cc01cca52c3f6ddde3231199369cf34c2
55

66
## Requirements
7-
- Symfony 3.x _(implies support for PHP >= 5.6, the feature is native as of Symfony 4)_
8-
- Redis extension or Predis _(using one of the following: RedisArray / RedisCluster / Predis\Client / RedisProxy / RedisClusterProxy)_
7+
- Symfony 3.x _(the feature is native as of Symfony 4)_
8+
- Redis extension _or_ Predis
99

1010
## Configuration
1111
After installing the bundle, you have to configure proper services on your own to be able to use RedisSessionHandler.
1212

1313
At first, you have to define service for Redis connection. It can be done in `app/config/services.yml`. Configuration should look like the following:
1414
```yaml
1515
redis_session_handler_connection:
16-
class: 'Redis' # RedisArray/RedisCluster/Predis\Client/RedisProxy/RedisClusterProxy are also supported
16+
class: 'Redis' # Or one of: RedisArray, RedisCluster, Predis\Client, or RedisProxy.
1717
calls:
1818
- method: connect
1919
arguments:
@@ -24,7 +24,7 @@ At first, you have to define service for Redis connection. It can be done in `ap
2424
Then, you need to define a proper service for handler itself:
2525
```yaml
2626
redis_session_handler:
27-
class: EzSystems\SymfonyTools\Symfony\Components\HttpFoundation\Session\Storage\Handler\RedisSessionHandler
27+
class: Symfony\Component\HttpFoundation\Session\Storage\Handler\RedisSessionHandler
2828
arguments:
2929
- '@redis_session_handler_connection'
3030
```

src/lib/Symfony/Components/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
<?php
22

3-
/**
4-
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
5-
* @license For full copyright and license information view LICENSE file distributed with this source code.
6-
*/
7-
83
/*
94
* This file is part of the Symfony package.
105
*
@@ -15,15 +10,14 @@
1510
*
1611
* Original source:
1712
* https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php
18-
* Last revision: https://github.com/symfony/symfony/commit/239a022cc01cca52c3f6ddde3231199369cf34c2
13+
* Last revision: https://github.com/symfony/symfony/commit/239a022cc01cca52c3f6ddde3231199369cf34c2 (+ CS commit: c0323b)
1914
*/
2015

21-
namespace EzSystems\SymfonyTools\Symfony\Components\HttpFoundation\Session\Storage\Handler;
16+
namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
2217

2318
use Predis\Response\ErrorInterface;
2419
use Symfony\Component\Cache\Traits\RedisClusterProxy;
2520
use Symfony\Component\Cache\Traits\RedisProxy;
26-
use Symfony\Component\HttpFoundation\Session\Storage\Handler\AbstractSessionHandler;
2721

2822
/**
2923
* Redis based session storage handler based on the Redis class
@@ -49,7 +43,7 @@ class RedisSessionHandler extends AbstractSessionHandler
4943
*
5044
* @throws \InvalidArgumentException When unsupported client or options are passed
5145
*/
52-
public function __construct($redis, array $options = array())
46+
public function __construct($redis, array $options = [])
5347
{
5448
if (
5549
!$redis instanceof \Redis &&
@@ -62,7 +56,7 @@ public function __construct($redis, array $options = array())
6256
throw new \InvalidArgumentException(sprintf('%s() expects parameter 1 to be Redis, RedisArray, RedisCluster or Predis\Client, %s given', __METHOD__, \is_object($redis) ? \get_class($redis) : \gettype($redis)));
6357
}
6458

65-
if ($diff = array_diff(array_keys($options), array('prefix'))) {
59+
if ($diff = array_diff(array_keys($options), ['prefix'])) {
6660
throw new \InvalidArgumentException(sprintf('The following options are not supported "%s"', implode(', ', $diff)));
6761
}
6862

src/lib/Symfony/LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2004-2019 Fabien Potencier
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is furnished
8+
to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

0 commit comments

Comments
 (0)