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

Commit da96976

Browse files
committed
Merge branch 'hotfix/7676'
Close #30 Fixes zendframework/zendframework#7676
2 parents f7d28c3 + 43d09e8 commit da96976

File tree

4 files changed

+52
-22
lines changed

4 files changed

+52
-22
lines changed

CHANGELOG.md

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

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

5-
## 2.6.1 - TBD
5+
## 2.6.1 - 2016-02-23
66

77
### Added
88

@@ -18,7 +18,11 @@ All notable changes to this project will be documented in this file, in reverse
1818

1919
### Fixed
2020

21-
- Nothing.
21+
- [#29](https://github.com/zendframework/zend-session/pull/29) extracts the
22+
constructor defined in `Zend\Session\Validator\ValidatorChainTrait` and pushes
23+
it into each of the `ValidatorChainEM2` and `ValidatorChainEM3`
24+
implementations, to prevent colliding constructor definitions due to
25+
inheritance + trait usage.
2226

2327
## 2.6.0 - 2016-02-23
2428

src/Validator/ValidatorChainEM2.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace Zend\Session\Validator;
1010

1111
use Zend\EventManager\EventManager;
12+
use Zend\Session\Storage\StorageInterface;
1213

1314
/**
1415
* Validator chain for validating sessions (for use with zend-eventmanager v2)
@@ -17,6 +18,28 @@ class ValidatorChainEM2 extends EventManager
1718
{
1819
use ValidatorChainTrait;
1920

21+
/**
22+
* Construct the validation chain
23+
*
24+
* Retrieves validators from session storage and attaches them.
25+
*
26+
* Duplicated in ValidatorChainEM3 to prevent trait collision with parent.
27+
*
28+
* @param StorageInterface $storage
29+
*/
30+
public function __construct(StorageInterface $storage)
31+
{
32+
parent::__construct();
33+
34+
$this->storage = $storage;
35+
$validators = $storage->getMetadata('_VALID');
36+
if ($validators) {
37+
foreach ($validators as $validator => $data) {
38+
$this->attachValidator('session.validate', [new $validator($data), 'isValid'], 1);
39+
}
40+
}
41+
}
42+
2043
/**
2144
* Attach a listener to the session validator chain.
2245
*

src/Validator/ValidatorChainEM3.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace Zend\Session\Validator;
1010

1111
use Zend\EventManager\EventManager;
12+
use Zend\Session\Storage\StorageInterface;
1213

1314
/**
1415
* Validator chain for validating sessions (for use with zend-eventmanager v3)
@@ -17,6 +18,28 @@ class ValidatorChainEM3 extends EventManager
1718
{
1819
use ValidatorChainTrait;
1920

21+
/**
22+
* Construct the validation chain
23+
*
24+
* Retrieves validators from session storage and attaches them.
25+
*
26+
* Duplicated in ValidatorChainEM2 to prevent trait collision with parent.
27+
*
28+
* @param StorageInterface $storage
29+
*/
30+
public function __construct(StorageInterface $storage)
31+
{
32+
parent::__construct();
33+
34+
$this->storage = $storage;
35+
$validators = $storage->getMetadata('_VALID');
36+
if ($validators) {
37+
foreach ($validators as $validator => $data) {
38+
$this->attachValidator('session.validate', [new $validator($data), 'isValid'], 1);
39+
}
40+
}
41+
}
42+
2043
/**
2144
* Attach a listener to the session validator chain.
2245
*

src/Validator/ValidatorChainTrait.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,6 @@ trait ValidatorChainTrait
2020
*/
2121
protected $storage;
2222

23-
/**
24-
* Construct the validation chain
25-
*
26-
* Retrieves validators from session storage and attaches them.
27-
*
28-
* @param StorageInterface $storage
29-
*/
30-
public function __construct(StorageInterface $storage)
31-
{
32-
parent::__construct();
33-
34-
$this->storage = $storage;
35-
$validators = $storage->getMetadata('_VALID');
36-
if ($validators) {
37-
foreach ($validators as $validator => $data) {
38-
$this->attachValidator('session.validate', [new $validator($data), 'isValid'], 1);
39-
}
40-
}
41-
}
42-
4323
/**
4424
* Retrieve session storage object
4525
*

0 commit comments

Comments
 (0)