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/31'
Browse files Browse the repository at this point in the history
Close #32
Fixes #31
  • Loading branch information
weierophinney committed Feb 25, 2016
2 parents ee413e0 + 70ed87a commit 6d8beb3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
7 changes: 5 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.2 - TBD
## 2.6.2 - 2016-02-25

### Added

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

### Fixed

- Nothing.
- [#32](https://github.com/zendframework/zend-session/pull/32) provides a better
polfill for the `ValidatorChain` to ensure it can be represented in
auto-generated classmaps (e.g., via `composer dump-autoload --optimize` and/or
`composer dump-autoload --classmap-authoritative`).

## 2.6.1 - 2016-02-23

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
use Zend\Session\Storage\StorageInterface;

/**
* Validator chain for validating sessions (for use with zend-eventmanager v2)
* Abstract validator chain for validating sessions (for use with zend-eventmanager v2).
*/
class ValidatorChainEM2 extends EventManager
abstract class AbstractValidatorChainEM2 extends EventManager
{
use ValidatorChainTrait;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
use Zend\Session\Storage\StorageInterface;

/**
* Validator chain for validating sessions (for use with zend-eventmanager v3)
* Abstract validator chain for validating sessions (for use with zend-eventmanager v3)
*/
class ValidatorChainEM3 extends EventManager
abstract class AbstractValidatorChainEM3 extends EventManager
{
use ValidatorChainTrait;

Expand Down
27 changes: 20 additions & 7 deletions src/ValidatorChain.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,32 @@
use Zend\EventManager\GlobalEventManager;

/**
* Polyfill for ValidatorChain
* Polyfill for AbstractValidatorChain.
*
* The definitions for EventManagerInterface::attach differ between versions 2
* and 3 of zend-eventmanager, which makes it impossible to override the method
* in a way that is compatible with both. To get around that, we define 2
* classes, one targeting each major version of zend-eventmanager, each
* sharing the same trait, and each defining attach() per the EM version they
* target. This file then aliases the appropriate one to `ValidatorChain`,
* in a way that is compatible with both.
*
* To get around that, we define 2 abstract classes, one targeting each major
* version of zend-eventmanager, and each defining attach() per the EM version
* they target.
*
* This conditional below then aliases the appropriate one to `AbstractValidatorChain`,
* based on which version of the EM is present. Since the `GlobalEventManager`
* is only present in v2, we can use that as our test.
*/
if (class_exists(GlobalEventManager::class)) {
class_alias(Validator\ValidatorChainEM2::class, ValidatorChain::class);
class_alias(Validator\AbstractValidatorChainEM2::class, AbstractValidatorChain::class);
} else {
class_alias(Validator\ValidatorChainEM3::class, ValidatorChain::class);
class_alias(Validator\AbstractValidatorChainEM3::class, AbstractValidatorChain::class);
}

/**
* Validator chain implementation.
*
* Extends the zend-eventmanager-version-specific base class implementation
* as polyfilled above.
*/
class ValidatorChain extends AbstractValidatorChain
{
}

0 comments on commit 6d8beb3

Please sign in to comment.