Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit db365f4

Browse files
committed
Merging develop to master in preparation for 2.6.0
2 parents d11c52e + 5bd7ceb commit db365f4

30 files changed

+571
-236
lines changed

.travis.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,28 @@ matrix:
1717
- php: 5.5
1818
env:
1919
- EXECUTE_CS_CHECK=true
20+
- php: 5.5
21+
env:
22+
- EVENT_MANAGER_VERSION="^2.6.2"
23+
- SERVICE_MANAGER_VERSION="^2.7.5"
2024
- php: 5.6
2125
env:
2226
- EXECUTE_TEST_COVERALLS=true
27+
- php: 5.6
28+
env:
29+
- EVENT_MANAGER_VERSION="^2.6.2"
30+
- SERVICE_MANAGER_VERSION="^2.7.5"
31+
- php: 7
2332
- php: 7
33+
env:
34+
- EVENT_MANAGER_VERSION="^2.6.2"
35+
- SERVICE_MANAGER_VERSION="^2.7.5"
36+
- php: hhvm
2437
- php: hhvm
38+
env:
39+
- EVENT_MANAGER_VERSION="^2.6.2"
40+
- SERVICE_MANAGER_VERSION="^2.7.5"
2541
allow_failures:
26-
- php: 7
2742
- php: hhvm
2843

2944
notifications:
@@ -34,6 +49,10 @@ before_install:
3449
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
3550
- composer self-update
3651
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then composer require --dev --no-update satooshi/php-coveralls ; fi
52+
- if [[ $EVENT_MANAGER_VERSION != '' ]]; then composer require --no-update "zendframework/zend-eventmanager:$EVENT_MANAGER_VERSION" ; fi
53+
- if [[ $EVENT_MANAGER_VERSION == '' ]]; then composer require --no-update "zendframework/zend-eventmanager:^3.0" ; fi
54+
- if [[ $SERVICE_MANAGER_VERSION != '' ]]; then composer require --dev --no-update "zendframework/zend-servicemanager:$SERVICE_MANAGER_VERSION" ; fi
55+
- if [[ $SERVICE_MANAGER_VERSION == '' ]]; then composer require --dev --no-update "zendframework/zend-servicemanager:^3.0.3" ; fi
3756

3857
install:
3958
- travis_retry composer install --no-interaction --ignore-platform-reqs

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,32 @@
22

33
All notable changes to this project will be documented in this file, in reverse chronological order by release.
44

5+
## 2.6.0 - 2016-02-23
6+
7+
### Added
8+
9+
- [#29](https://github.com/zendframework/zend-session/pull/29) adds two new
10+
classes: `Zend\Session\Validator\ValidatorChainEM2` and `ValidatorChainEM3`.
11+
Due to differences in the `EventManagerInterface::attach()` method between
12+
zend-eventmanager v2 and v3, and the fact that `ValidatorChain` overrides that
13+
method, we now need an implementation targeting each major version. To provide
14+
a consistent use case, we use a polyfill that aliases the appropriate version
15+
to the `Zend\Session\ValidatorChain` class.
16+
17+
### Deprecated
18+
19+
- Nothing.
20+
21+
### Removed
22+
23+
- Nothing.
24+
25+
### Fixed
26+
27+
- [#29](https://github.com/zendframework/zend-session/pull/29) updates the code
28+
to be forwards compatible with the v3 releases of zend-eventmanager and
29+
zend-servicemanager.
30+
531
## 2.5.3 - TBD
632

733
### Added

composer.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@
1313
}
1414
},
1515
"require": {
16-
"php": ">=5.5",
17-
"zendframework/zend-eventmanager": "~2.5",
18-
"zendframework/zend-stdlib": "~2.5"
16+
"php": "^5.5 || ^7.0",
17+
"zendframework/zend-eventmanager": "^2.6.2 || ^3.0",
18+
"zendframework/zend-stdlib": "^2.7 || ^3.0"
1919
},
2020
"require-dev": {
21-
"zendframework/zend-cache": "~2.5",
22-
"zendframework/zend-db": "~2.5",
23-
"zendframework/zend-http": "~2.5",
24-
"zendframework/zend-servicemanager": "~2.5",
25-
"zendframework/zend-validator": "~2.5",
21+
"zendframework/zend-cache": "^2.6.1",
22+
"zendframework/zend-db": "^2.7",
23+
"zendframework/zend-http": "^2.5.4",
24+
"zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3",
25+
"zendframework/zend-validator": "^2.6",
26+
"container-interop/container-interop": "^1.1",
2627
"fabpot/php-cs-fixer": "1.7.*",
2728
"phpunit/PHPUnit": "~4.0"
2829
},

src/Service/ContainerAbstractServiceFactory.php

Lines changed: 51 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@
99

1010
namespace Zend\Session\Service;
1111

12+
use Interop\Container\ContainerInterface;
1213
use Zend\ServiceManager\AbstractFactoryInterface;
1314
use Zend\ServiceManager\ServiceLocatorInterface;
1415
use Zend\Session\Container;
16+
use Zend\Session\ManagerInterface;
1517

1618
/**
1719
* Session container abstract service factory.
1820
*
19-
* Allows creating Container instances, using the Zend\Service\ManagerInterface
21+
* Allows creating Container instances, using the ManagerInterface
2022
* if present. Containers are named in a "session_containers" array in the
2123
* Config service:
2224
*
@@ -51,19 +53,20 @@ class ContainerAbstractServiceFactory implements AbstractFactoryInterface
5153
protected $configKey = 'session_containers';
5254

5355
/**
54-
* @var \Zend\Session\ManagerInterface
56+
* @var ManagerInterface
5557
*/
5658
protected $sessionManager;
5759

5860
/**
59-
* @param ServiceLocatorInterface $services
60-
* @param string $name
61-
* @param string $requestedName
61+
* Can we create an instance of the given service? (v3 usage).
62+
*
63+
* @param ContainerInterface $container
64+
* @param string $requestedName
6265
* @return bool
6366
*/
64-
public function canCreateServiceWithName(ServiceLocatorInterface $services, $name, $requestedName)
67+
public function canCreate(ContainerInterface $container, $requestedName)
6568
{
66-
$config = $this->getConfig($services);
69+
$config = $this->getConfig($container);
6770
if (empty($config)) {
6871
return false;
6972
}
@@ -73,36 +76,62 @@ public function canCreateServiceWithName(ServiceLocatorInterface $services, $nam
7376
}
7477

7578
/**
76-
* @param ServiceLocatorInterface $services
77-
* @param string $name
78-
* @param string $requestedName
79+
* Can we create an instance of the given service? (v2 usage)
80+
*
81+
* @param ServiceLocatorInterface $container
82+
* @param string $name
83+
* @param string $requestedName
84+
* @return bool
85+
*/
86+
public function canCreateServiceWithName(ServiceLocatorInterface $container, $name, $requestedName)
87+
{
88+
return $this->canCreate($container, $requestedName);
89+
}
90+
91+
/**
92+
* Create and return a named container (v3 usage).
93+
*
94+
* @param ContainerInterface $container
95+
* @param string $requestedName
7996
* @return Container
8097
*/
81-
public function createServiceWithName(ServiceLocatorInterface $services, $name, $requestedName)
98+
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
8299
{
83-
$manager = $this->getSessionManager($services);
100+
$manager = $this->getSessionManager($container);
84101
return new Container($requestedName, $manager);
85102
}
86103

104+
/**
105+
* Create and return a named container (v2 usage).
106+
*
107+
* @param ContainerInterface $container
108+
* @param string $requestedName
109+
* @return Container
110+
*/
111+
public function createServiceWithName(ServiceLocatorInterface $container, $name, $requestedName)
112+
{
113+
return $this($container, $requestedName);
114+
}
115+
87116
/**
88117
* Retrieve config from service locator, and cache for later
89118
*
90-
* @param ServiceLocatorInterface $services
119+
* @param ContainerInterface $container
91120
* @return false|array
92121
*/
93-
protected function getConfig(ServiceLocatorInterface $services)
122+
protected function getConfig(ContainerInterface $container)
94123
{
95124
if (null !== $this->config) {
96125
return $this->config;
97126
}
98127

99-
if (!$services->has('Config')) {
128+
if (!$container->has('config')) {
100129
$this->config = [];
101130
return $this->config;
102131
}
103132

104-
$config = $services->get('Config');
105-
if (!isset($config[$this->configKey]) || !is_array($config[$this->configKey])) {
133+
$config = $container->get('config');
134+
if (! isset($config[$this->configKey]) || ! is_array($config[$this->configKey])) {
106135
$this->config = [];
107136
return $this->config;
108137
}
@@ -118,17 +147,17 @@ protected function getConfig(ServiceLocatorInterface $services)
118147
/**
119148
* Retrieve the session manager instance, if any
120149
*
121-
* @param ServiceLocatorInterface $services
122-
* @return null|\Zend\Session\ManagerInterface
150+
* @param ContainerInterface $container
151+
* @return null|ManagerInterface
123152
*/
124-
protected function getSessionManager(ServiceLocatorInterface $services)
153+
protected function getSessionManager(ContainerInterface $container)
125154
{
126155
if ($this->sessionManager !== null) {
127156
return $this->sessionManager;
128157
}
129158

130-
if ($services->has('Zend\Session\ManagerInterface')) {
131-
$this->sessionManager = $services->get('Zend\Session\ManagerInterface');
159+
if ($container->has(ManagerInterface::class)) {
160+
$this->sessionManager = $container->get(ManagerInterface::class);
132161
}
133162

134163
return $this->sessionManager;

src/Service/SessionConfigFactory.php

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,46 @@
99

1010
namespace Zend\Session\Service;
1111

12+
use Interop\Container\ContainerInterface;
1213
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
1314
use Zend\ServiceManager\FactoryInterface;
1415
use Zend\ServiceManager\ServiceLocatorInterface;
1516
use Zend\Session\Config\ConfigInterface;
17+
use Zend\Session\Config\SessionConfig;
1618

1719
class SessionConfigFactory implements FactoryInterface
1820
{
1921
/**
20-
* Create session configuration object
22+
* Create session configuration object (v3 usage).
2123
*
2224
* Uses "session_config" section of configuration to seed a ConfigInterface
2325
* instance. By default, Zend\Session\Config\SessionConfig will be used, but
2426
* you may also specify a specific implementation variant using the
2527
* "config_class" subkey.
2628
*
27-
* @param ServiceLocatorInterface $services
29+
* @param ContainerInterface $container
30+
* @param string $requestedName
31+
* @param null|array $options
2832
* @return ConfigInterface
2933
* @throws ServiceNotCreatedException if session_config is missing, or an
30-
* invalid config_class is used
34+
* invalid config_class is used
3135
*/
32-
public function createService(ServiceLocatorInterface $services)
36+
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
3337
{
34-
$config = $services->get('Config');
35-
if (!isset($config['session_config']) || !is_array($config['session_config'])) {
38+
$config = $container->get('config');
39+
if (! isset($config['session_config']) || ! is_array($config['session_config'])) {
3640
throw new ServiceNotCreatedException(
3741
'Configuration is missing a "session_config" key, or the value of that key is not an array'
3842
);
3943
}
40-
$class = 'Zend\Session\Config\SessionConfig';
44+
45+
$class = SessionConfig::class;
4146
$config = $config['session_config'];
4247
if (isset($config['config_class'])) {
43-
if (!class_exists($config['config_class'])) {
48+
if (! class_exists($config['config_class'])) {
4449
throw new ServiceNotCreatedException(sprintf(
45-
'Invalid configuration class "%s" specified in "config_class" session configuration; must be a valid class',
50+
'Invalid configuration class "%s" specified in "config_class" session configuration; '
51+
. 'must be a valid class',
4652
$config['config_class']
4753
));
4854
}
@@ -51,14 +57,31 @@ public function createService(ServiceLocatorInterface $services)
5157
}
5258

5359
$sessionConfig = new $class();
54-
if (!$sessionConfig instanceof ConfigInterface) {
60+
if (! $sessionConfig instanceof ConfigInterface) {
5561
throw new ServiceNotCreatedException(sprintf(
56-
'Invalid configuration class "%s" specified in "config_class" session configuration; must implement Zend\Session\Config\ConfigInterface',
57-
$class
62+
'Invalid configuration class "%s" specified in "config_class" session configuration; must implement %s',
63+
$class,
64+
ConfigInterface::class
5865
));
5966
}
6067
$sessionConfig->setOptions($config);
6168

6269
return $sessionConfig;
6370
}
71+
72+
/**
73+
* Create and return a config instance (v2 usage).
74+
*
75+
* @param ServiceLocatorInterface $services
76+
* @param null|string $canonicalName
77+
* @param string $requestedName
78+
* @return ConfigInterface
79+
*/
80+
public function createService(
81+
ServiceLocatorInterface $services,
82+
$canonicalName = null,
83+
$requestedName = ConfigInterface::class
84+
) {
85+
return $this($services, $requestedName);
86+
}
6487
}

0 commit comments

Comments
 (0)