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

Commit

Permalink
Merge branch 'hotfix/7676'
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Feb 23, 2016
2 parents f7d28c3 + 43d09e8 commit da96976
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 22 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

## 2.6.1 - TBD
## 2.6.1 - 2016-02-23

### Added

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

### Fixed

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

## 2.6.0 - 2016-02-23

Expand Down
23 changes: 23 additions & 0 deletions src/Validator/ValidatorChainEM2.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace Zend\Session\Validator;

use Zend\EventManager\EventManager;
use Zend\Session\Storage\StorageInterface;

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

/**
* Construct the validation chain
*
* Retrieves validators from session storage and attaches them.
*
* Duplicated in ValidatorChainEM3 to prevent trait collision with parent.
*
* @param StorageInterface $storage
*/
public function __construct(StorageInterface $storage)
{
parent::__construct();

$this->storage = $storage;
$validators = $storage->getMetadata('_VALID');
if ($validators) {
foreach ($validators as $validator => $data) {
$this->attachValidator('session.validate', [new $validator($data), 'isValid'], 1);
}
}
}

/**
* Attach a listener to the session validator chain.
*
Expand Down
23 changes: 23 additions & 0 deletions src/Validator/ValidatorChainEM3.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace Zend\Session\Validator;

use Zend\EventManager\EventManager;
use Zend\Session\Storage\StorageInterface;

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

/**
* Construct the validation chain
*
* Retrieves validators from session storage and attaches them.
*
* Duplicated in ValidatorChainEM2 to prevent trait collision with parent.
*
* @param StorageInterface $storage
*/
public function __construct(StorageInterface $storage)
{
parent::__construct();

$this->storage = $storage;
$validators = $storage->getMetadata('_VALID');
if ($validators) {
foreach ($validators as $validator => $data) {
$this->attachValidator('session.validate', [new $validator($data), 'isValid'], 1);
}
}
}

/**
* Attach a listener to the session validator chain.
*
Expand Down
20 changes: 0 additions & 20 deletions src/Validator/ValidatorChainTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,6 @@ trait ValidatorChainTrait
*/
protected $storage;

/**
* Construct the validation chain
*
* Retrieves validators from session storage and attaches them.
*
* @param StorageInterface $storage
*/
public function __construct(StorageInterface $storage)
{
parent::__construct();

$this->storage = $storage;
$validators = $storage->getMetadata('_VALID');
if ($validators) {
foreach ($validators as $validator => $data) {
$this->attachValidator('session.validate', [new $validator($data), 'isValid'], 1);
}
}
}

/**
* Retrieve session storage object
*
Expand Down

0 comments on commit da96976

Please sign in to comment.