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

Commit 179da18

Browse files
committed
Merge branch 'feature/68' into develop
Close #69 Close #68 Close #64
2 parents 4f9d31b + 4def038 commit 179da18

20 files changed

+468
-213
lines changed

.travis.yml

+39-14
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ services:
1818

1919
env:
2020
global:
21-
- TESTS_ZEND_CACHE_APC_ENABLED=true
22-
- TESTS_ZEND_CACHE_MEMCACHED_ENABLED=true
23-
- TESTS_ZEND_CACHE_MEMCACHED_HOST='127.0.0.1'
24-
- TESTS_ZEND_CACHE_MEMCACHED_PORT=11211
25-
- TESTS_ZEND_CACHE_MEMCACHE_ENABLED=true
26-
- TESTS_ZEND_CACHE_MEMCACHE_HOST=$TESTS_ZEND_CACHE_MEMCACHED_HOST
27-
- TESTS_ZEND_CACHE_MEMCACHE_PORT=$TESTS_ZEND_CACHE_MEMCACHED_PORT
28-
- TESTS_ZEND_CACHE_MONGODB_ENABLED=true
29-
- TESTS_ZEND_CACHE_REDIS_ENABLED=true
30-
- TESTS_ZEND_CACHE_REDIS_HOST='127.0.0.1'
31-
- TESTS_ZEND_CACHE_REDIS_PORT=6379
32-
- TESTS_ZEND_CACHE_REDIS_PASSWORD=''
33-
- TESTS_ZEND_CACHE_REDIS_DATABASE=0
21+
- TESTS_ZEND_CACHE_APC_ENABLED: true
22+
- TESTS_ZEND_CACHE_MEMCACHED_ENABLED: true
23+
- TESTS_ZEND_CACHE_MEMCACHED_HOST: "127.0.0.1"
24+
- TESTS_ZEND_CACHE_MEMCACHED_PORT: 11211
25+
- TESTS_ZEND_CACHE_MEMCACHE_ENABLED: true
26+
- TESTS_ZEND_CACHE_MEMCACHE_HOST: $TESTS_ZEND_CACHE_MEMCACHED_HOST
27+
- TESTS_ZEND_CACHE_MEMCACHE_PORT: $TESTS_ZEND_CACHE_MEMCACHED_PORT
28+
- TESTS_ZEND_CACHE_MONGODB_ENABLED: true
29+
- TESTS_ZEND_CACHE_REDIS_ENABLED: true
30+
- TESTS_ZEND_CACHE_REDIS_HOST: "127.0.0.1"
31+
- TESTS_ZEND_CACHE_REDIS_PORT: 6379
32+
- TESTS_ZEND_CACHE_REDIS_PASSWORD: ""
33+
- TESTS_ZEND_CACHE_REDIS_DATABASE: 0
3434

3535
matrix:
3636
fast_finish: true
@@ -39,15 +39,35 @@ matrix:
3939
env:
4040
- EXECUTE_CS_CHECK=true
4141
- PECL_INSTALL_APCU='apcu-4.0.8'
42+
- php: 5.5
43+
env:
44+
- SERVICE_MANAGER_VERSION="^2.7.5"
45+
- EVENT_MANAGER_VERSION="^2.6.2"
46+
- PECL_INSTALL_APCU='apcu-4.0.8'
4247
- php: 5.6
4348
env:
4449
- EXECUTE_TEST_COVERALLS=true
4550
- PECL_INSTALL_APCU='apcu-4.0.8'
51+
- php: 5.6
52+
env:
53+
- SERVICE_MANAGER_VERSION="^2.7.5"
54+
- EVENT_MANAGER_VERSION="^2.6.2"
55+
- PECL_INSTALL_APCU='apcu-4.0.8'
4656
- php: 7
4757
env:
4858
- PECL_INSTALL_APCU='apcu'
4959
- PECL_INSTALL_APCU_BC='apcu_bc-beta'
60+
- php: 7
61+
env:
62+
- SERVICE_MANAGER_VERSION="^2.7.5"
63+
- EVENT_MANAGER_VERSION="^2.6.2"
64+
- PECL_INSTALL_APCU='apcu'
65+
- PECL_INSTALL_APCU_BC='apcu_bc-beta'
5066
- php: hhvm
67+
- php: hhvm
68+
env:
69+
- SERVICE_MANAGER_VERSION="^2.7.5"
70+
- EVENT_MANAGER_VERSION="^2.6.2"
5171
allow_failures:
5272
- php: 7
5373
- php: hhvm
@@ -60,11 +80,16 @@ before_install:
6080
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
6181
- composer self-update
6282
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then composer require --dev --no-update satooshi/php-coveralls ; fi
83+
- if [[ $SERVICE_MANAGER_VERSION != '' ]]; then composer require --no-update "zendframework/zend-servicemanager:$SERVICE_MANAGER_VERSION" ; fi
84+
- if [[ $SERVICE_MANAGER_VERSION == '' ]]; then composer require --no-update "zendframework/zend-servicemanager:^3.0.3" ; fi
85+
- if [[ $SERVICE_MANAGER_VERSION == '' ]]; then composer remove --dev --no-update zendframework/zend-session ; fi
86+
- if [[ $EVENT_MANAGER_VERSION != '' ]]; then composer require --no-update "zendframework/zend-eventmanager:$EVENT_MANAGER_VERSION" ; fi
87+
- if [[ $EVENT_MANAGER_VERSION == '' ]]; then composer require --no-update "zendframework/zend-eventmanager:^3.0" ; fi
6388

6489
install:
6590
- travis_retry composer install --no-interaction --ignore-platform-reqs
6691
- if [[ $PECL_INSTALL_APCU != '' ]]; then echo "yes\nno\n" | pecl install $PECL_INSTALL_APCU || return 0 ; fi
67-
92+
6893
# see https://pear.php.net/bugs/bug.php?id=21007
6994
# pecl install adds the "extension=*.so" directive on top of php.ini which results in wrong extension order
7095
# -> Attach another ini file loading the extension kind of solves the issue.

CHANGELOG.md

+7-5
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-
## 3.0.0 - TBD
5+
## 2.6.0 - TBD
66

77
### Added
88

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

1919
### Fixed
2020

21-
- [#22](https://github.com/zendframework/zend-cache/pull/22) updates the
22-
component to the v3 version of zend-servicemanager.
23-
- [#22](https://github.com/zendframework/zend-cache/pull/22) updates the
24-
component to the v3 version of zend-eventmanager.
21+
- [#22](https://github.com/zendframework/zend-cache/pull/22),
22+
[#64](https://github.com/zendframework/zend-cache/pull/64),
23+
[#68](https://github.com/zendframework/zend-cache/pull/68), and
24+
[#69](https://github.com/zendframework/zend-cache/pull/69) update the
25+
component to be forwards-compatible with zend-eventmanager,
26+
zend-servicemanager, and zend-stdlib v3.
2527

2628
## 2.5.4 - TBD
2729

composer.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
}
1414
},
1515
"require": {
16-
"php": ">=5.5",
17-
"zendframework/zend-stdlib": "~2.5",
18-
"zendframework/zend-servicemanager": "dev-develop as 2.7.0",
19-
"zendframework/zend-eventmanager": "dev-develop as 2.7.0"
16+
"php": "^5.5 || ^7.0",
17+
"zendframework/zend-stdlib": "^2.7 || ^3.0",
18+
"zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3",
19+
"zendframework/zend-eventmanager": "^2.6.2 || ^3.0"
2020
},
2121
"require-dev": {
22-
"zendframework/zend-serializer": "dev-develop as 2.6.0",
23-
"zendframework/zend-session": "~2.5",
22+
"zendframework/zend-serializer": "^2.6",
23+
"zendframework/zend-session": "^2.5",
2424
"fabpot/php-cs-fixer": "1.7.*",
2525
"phpunit/PHPUnit": "~4.0"
2626
},
@@ -42,7 +42,7 @@
4242
"extra": {
4343
"branch-alias": {
4444
"dev-master": "2.5-dev",
45-
"dev-develop": "3.0-dev"
45+
"dev-develop": "2.6-dev"
4646
}
4747
},
4848
"autoload-dev": {

src/PatternPluginManager.php

+63-8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use Zend\ServiceManager\AbstractPluginManager;
1313
use Zend\ServiceManager\Factory\InvokableFactory;
14+
use Zend\ServiceManager\Exception\InvalidServiceException;
1415

1516
/**
1617
* Plugin manager implementation for cache pattern adapters
@@ -23,31 +24,85 @@ class PatternPluginManager extends AbstractPluginManager
2324
{
2425
protected $aliases = [
2526
'callback' => Pattern\CallbackCache::class,
27+
'Callback' => Pattern\CallbackCache::class,
2628
'capture' => Pattern\CaptureCache::class,
29+
'Capture' => Pattern\CaptureCache::class,
2730
'class' => Pattern\ClassCache::class,
31+
'Class' => Pattern\ClassCache::class,
2832
'object' => Pattern\ObjectCache::class,
33+
'Object' => Pattern\ObjectCache::class,
2934
'output' => Pattern\OutputCache::class,
30-
'page' => Pattern\PageCache::class,
35+
'Output' => Pattern\OutputCache::class,
3136
];
3237

3338
protected $factories = [
34-
Pattern\CallbackCache::class => InvokableFactory::class,
35-
Pattern\CaptureCache::class => InvokableFactory::class,
36-
Pattern\ClassCache::class => InvokableFactory::class,
37-
Pattern\ObjectCache::class => InvokableFactory::class,
38-
Pattern\OutputCache::class => InvokableFactory::class,
39-
Pattern\PageCache::class => InvokableFactory::class,
39+
Pattern\CallbackCache::class => InvokableFactory::class,
40+
Pattern\CaptureCache::class => InvokableFactory::class,
41+
Pattern\ClassCache::class => InvokableFactory::class,
42+
Pattern\ObjectCache::class => InvokableFactory::class,
43+
Pattern\OutputCache::class => InvokableFactory::class,
44+
45+
// v2 normalized FQCNs
46+
'zendcachepatterncallbackcache' => InvokableFactory::class,
47+
'zendcachepatterncapturecache' => InvokableFactory::class,
48+
'zendcachepatternclasscache' => InvokableFactory::class,
49+
'zendcachepatternobjectcache' => InvokableFactory::class,
50+
'zendcachepatternoutputcache' => InvokableFactory::class,
4051
];
4152

4253
/**
4354
* Don't share by default
4455
*
45-
* @var array
56+
* @var boolean
57+
*/
58+
protected $shareByDefault = false;
59+
60+
/**
61+
* Don't share by default
62+
*
63+
* @var boolean
4664
*/
4765
protected $sharedByDefault = false;
4866

4967
/**
5068
* @var string
5169
*/
5270
protected $instanceOf = Pattern\PatternInterface::class;
71+
72+
/**
73+
* Validate the plugin is of the expected type (v3).
74+
*
75+
* Validates against `$instanceOf`.
76+
*
77+
* @param mixed $instance
78+
* @throws InvalidServiceException
79+
*/
80+
public function validate($instance)
81+
{
82+
if (! $instance instanceof $this->instanceOf) {
83+
throw new InvalidServiceException(sprintf(
84+
'%s can only create instances of %s; %s is invalid',
85+
get_class($this),
86+
$this->instanceOf,
87+
(is_object($instance) ? get_class($instance) : gettype($instance))
88+
));
89+
}
90+
}
91+
92+
/**
93+
* Validate the plugin is of the expected type (v2).
94+
*
95+
* Proxies to `validate()`.
96+
*
97+
* @param mixed $plugin
98+
* @throws Exception\RuntimeException if invalid
99+
*/
100+
public function validatePlugin($plugin)
101+
{
102+
try {
103+
$this->validate($plugin);
104+
} catch (InvalidServiceException $e) {
105+
throw new Exception\RuntimeException($e->getMessage(), $e->getCode(), $e);
106+
}
107+
}
53108
}

src/Service/StorageCacheAbstractServiceFactory.php

+19-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
namespace Zend\Cache\Service;
1111

1212
use Zend\Cache\StorageFactory;
13-
use Zend\ServiceManager\Factory\AbstractFactoryInterface;
13+
use Zend\ServiceManager\AbstractFactoryInterface;
1414
use Interop\Container\ContainerInterface;
15+
use Zend\ServiceManager\ServiceLocatorInterface;
1516

1617
/**
1718
* Storage cache factory for multiple caches.
@@ -35,7 +36,7 @@ class StorageCacheAbstractServiceFactory implements AbstractFactoryInterface
3536
* @param string $requestedName
3637
* @return boolean
3738
*/
38-
public function canCreateServiceWithName(ContainerInterface $container, $requestedName)
39+
public function canCreate(ContainerInterface $container, $requestedName)
3940
{
4041
$config = $this->getConfig($container);
4142
if (empty($config)) {
@@ -44,6 +45,17 @@ public function canCreateServiceWithName(ContainerInterface $container, $request
4445
return (isset($config[$requestedName]) && is_array($config[$requestedName]));
4546
}
4647

48+
/**
49+
* @param ServiceLocatorInterface $serviceLocator
50+
* @param string $name
51+
* @param string $requestedName
52+
* @return boolean
53+
*/
54+
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
55+
{
56+
return $this->canCreate($serviceLocator, $requestedName);
57+
}
58+
4759
/**
4860
* Create an object
4961
*
@@ -58,6 +70,11 @@ public function __invoke(ContainerInterface $container, $requestedName, array $o
5870
return StorageFactory::factory($config[$requestedName]);
5971
}
6072

73+
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
74+
{
75+
return $this($serviceLocator, $requestedName);
76+
}
77+
6178
/**
6279
* Retrieve cache configuration, if any
6380
*

src/Service/StorageCacheFactory.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99

1010
namespace Zend\Cache\Service;
1111

12+
use Zend\Cache\Storage\StorageInterface;
1213
use Zend\Cache\StorageFactory;
13-
use Zend\ServiceManager\Factory\FactoryInterface;
14+
use Zend\ServiceManager\FactoryInterface;
1415
use Interop\Container\ContainerInterface;
16+
use Zend\ServiceManager\ServiceLocatorInterface;
1517

1618
/**
1719
* Storage cache factory.
@@ -24,4 +26,9 @@ public function __invoke(ContainerInterface $container, $requestedName, array $o
2426
$cacheConfig = isset($config['cache']) ? $config['cache'] : [];
2527
return StorageFactory::factory($cacheConfig);
2628
}
29+
30+
public function createService(ServiceLocatorInterface $serviceLocator)
31+
{
32+
return $this($serviceLocator, StorageInterface::class);
33+
}
2734
}

0 commit comments

Comments
 (0)