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

Commit 62fd405

Browse files
committed
Merging develop to master in preparation for 2.7.0
2 parents bb8a75c + e8556b6 commit 62fd405

28 files changed

Lines changed: 1854 additions & 84 deletions

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ services:
2121
env:
2222
global:
2323
- TESTS_ZEND_CACHE_APC_ENABLED: true
24+
- TESTS_ZEND_CACHE_APCU_ENABLED=true
2425
- TESTS_ZEND_CACHE_MEMCACHED_ENABLED: true
2526
- TESTS_ZEND_CACHE_MEMCACHED_HOST: "127.0.0.1"
2627
- TESTS_ZEND_CACHE_MEMCACHED_PORT: 11211
@@ -72,6 +73,7 @@ matrix:
7273
- INSTALL_XCACHE=true
7374
- php: 7
7475
env:
76+
- EXECUTE_TEST_COVERALLS=true
7577
- PECL_INSTALL_APCU='apcu'
7678
- PECL_INSTALL_APCU_BC='apcu_bc-beta'
7779
- php: 7

CHANGELOG.md

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

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

5+
## 2.7.0 - TBD
6+
7+
### Added
8+
9+
- [#23](https://github.com/zendframework/zend-cache/issues/23)
10+
[#47](https://github.com/zendframework/zend-cache/issues/47)
11+
Added an Apcu storage adapter as future replacement for Apc
12+
- [#63](https://github.com/zendframework/zend-cache/pull/63)
13+
Implemented ClearByNamespaceInterface in Stoage\Adapter\Redis
14+
- [#94](https://github.com/zendframework/zend-cache/pull/94) adds factories for
15+
each of the `PatternPluginManager`, `AdapterPluginManager`, and storage
16+
`PluginManager`.
17+
- [#94](https://github.com/zendframework/zend-cache/pull/94) exposes the package
18+
as a standalone config-provider / ZF component, by adding:
19+
- `Zend\Cache\ConfigProvider`, which enables the
20+
`StorageCacheAbstractServiceFactory`, and maps factories for all plugin
21+
managers.
22+
- `Zend\Cache\Module`, which does the same, for zend-mvc contexts.
23+
24+
### Deprecated
25+
26+
- Nothing.
27+
28+
### Removed
29+
30+
- Nothing.
31+
32+
### Fixed
33+
34+
- [#94](https://github.com/zendframework/zend-cache/pull/94) updates the
35+
`PatternPluginManager` to accept `$options` to `get()` and `build()`, cast
36+
them to a `PatternOptions` instance, and inject them into the generated plugin
37+
instance. This change allows better standalone usage of the plugin manager.
38+
- [#94](https://github.com/zendframework/zend-cache/pull/94) updates the
39+
`StorageCacheFactory` and `StorageCacheAbstractServiceFactory` to seed the
40+
`StorageFactory` with the storage plugin manager and/or adapter plugin manager
41+
as pulled from the provided container, if present. This change enables re-use
42+
of pre-configured plugin managers (e.g., those seeded with custom plugins
43+
and/or adapters).
44+
545
## 2.6.2 - TBD
646

747
### Added

composer.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@
2222
"zendframework/zend-serializer": "^2.6",
2323
"zendframework/zend-session": "^2.6.2",
2424
"fabpot/php-cs-fixer": "1.7.*",
25-
"phpunit/PHPUnit": "~4.0"
25+
"phpunit/phpunit": "^4.5"
2626
},
2727
"suggest": {
2828
"zendframework/zend-serializer": "Zend\\Serializer component",
2929
"zendframework/zend-session": "Zend\\Session component",
30-
"ext-apcu": "APCU, to use the APC storage adapter",
30+
"ext-apc": "APC or compatible extension, to use the APC storage adapter",
31+
"ext-apcu": "APCU >= 5.1.0, to use the APCu storage adapter",
3132
"ext-dba": "DBA, to use the DBA storage adapter",
3233
"ext-memcache": "Memcache >= 2.0.0 to use the Memcache storage adapter",
3334
"ext-memcached": "Memcached >= 1.0.0 to use the Memcached storage adapter",
@@ -43,6 +44,10 @@
4344
"branch-alias": {
4445
"dev-master": "2.6-dev",
4546
"dev-develop": "2.7-dev"
47+
},
48+
"zf": {
49+
"component": "Zend\\Cache",
50+
"config-provider": "Zend\\Cache\\ConfigProvider"
4651
}
4752
},
4853
"autoload-dev": {

phpunit.xml.dist

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
4-
bootstrap="./test/bootstrap.php"
4+
bootstrap="./vendor/autoload.php"
55
colors="true">
66
<testsuites>
77
<testsuite name="zend-cache Test Suite">
@@ -35,6 +35,7 @@
3535
constants appropriate to the component you are migrating. -->
3636

3737
<env name="TESTS_ZEND_CACHE_APC_ENABLED" value="false" />
38+
<env name="TESTS_ZEND_CACHE_APCU_ENABLED" value="false" />
3839
<env name="TESTS_ZEND_CACHE_XCACHE_ENABLED" value="false" />
3940
<env name="TESTS_ZEND_CACHE_XCACHE_ADMIN_AUTH" value="false" />
4041
<env name="TESTS_ZEND_CACHE_XCACHE_ADMIN_USER" value="" />

src/ConfigProvider.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
3+
* @link http://github.com/zendframework/zend-cache for the canonical source repository
4+
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license http://framework.zend.com/license/new-bsd New BSD License
6+
*/
7+
8+
namespace Zend\Cache;
9+
10+
class ConfigProvider
11+
{
12+
/**
13+
* Return default configuration for zend-cache.
14+
*
15+
* @return array
16+
*/
17+
public function __invoke()
18+
{
19+
return [
20+
'dependencies' => $this->getDependencyConfig(),
21+
];
22+
}
23+
24+
/**
25+
* Return default service mappings for zend-cache.
26+
*
27+
* @return array
28+
*/
29+
public function getDependencyConfig()
30+
{
31+
return [
32+
'abstract_factories' => [
33+
Service\StorageCacheAbstractServiceFactory::class,
34+
],
35+
'factories' => [
36+
PatternPluginManager::class => Service\PatternPluginManagerFactory::class,
37+
Storage\AdapterPluginManager::class => Service\StorageAdapterPluginManagerFactory::class,
38+
Storage\PluginManager::class => Service\StoragePluginManagerFactory::class,
39+
],
40+
];
41+
}
42+
}

src/Module.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* @link http://github.com/zendframework/zend-cache for the canonical source repository
4+
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license http://framework.zend.com/license/new-bsd New BSD License
6+
*/
7+
8+
namespace Zend\Cache;
9+
10+
class Module
11+
{
12+
/**
13+
* Return default zend-cache configuration for zend-mvc context.
14+
*
15+
* @return array
16+
*/
17+
public function getConfig()
18+
{
19+
$provider = new ConfigProvider();
20+
return [
21+
'service_manager' => $provider->getDependencyConfig(),
22+
];
23+
}
24+
}

src/PatternFactory.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,15 @@ abstract class PatternFactory
3232
*/
3333
public static function factory($patternName, $options = [])
3434
{
35+
if ($options instanceof Pattern\PatternOptions) {
36+
$options = $options->toArray();
37+
}
38+
3539
if ($options instanceof Traversable) {
3640
$options = ArrayUtils::iteratorToArray($options);
3741
}
38-
if (is_array($options)) {
39-
$options = new Pattern\PatternOptions($options);
40-
} elseif (!$options instanceof Pattern\PatternOptions) {
42+
43+
if (! is_array($options)) {
4144
throw new Exception\InvalidArgumentException(sprintf(
4245
'%s expects an array, Traversable object, or %s\Pattern\PatternOptions object; received "%s"',
4346
__METHOD__,
@@ -47,13 +50,11 @@ public static function factory($patternName, $options = [])
4750
}
4851

4952
if ($patternName instanceof Pattern\PatternInterface) {
50-
$patternName->setOptions($options);
53+
$patternName->setOptions(new Pattern\PatternOptions($options));
5154
return $patternName;
5255
}
5356

54-
$pattern = static::getPluginManager()->get($patternName);
55-
$pattern->setOptions($options);
56-
return $pattern;
57+
return static::getPluginManager()->get($patternName, $options);
5758
}
5859

5960
/**

src/PatternPluginManager.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,38 @@ class PatternPluginManager extends AbstractPluginManager
6969
*/
7070
protected $instanceOf = Pattern\PatternInterface::class;
7171

72+
/**
73+
* Override get to inject options as PatternOptions instance.
74+
*
75+
* {@inheritDoc}
76+
*/
77+
public function get($plugin, array $options = [], $usePeeringServiceManagers = true)
78+
{
79+
if (empty($options)) {
80+
return parent::get($plugin, [], $usePeeringServiceManagers);
81+
}
82+
83+
$plugin = parent::get($plugin, [], $usePeeringServiceManagers);
84+
$plugin->setOptions(new Pattern\PatternOptions($options));
85+
return $plugin;
86+
}
87+
88+
/**
89+
* Override build to inject options as PatternOptions instance.
90+
*
91+
* {@inheritDoc}
92+
*/
93+
public function build($plugin, array $options = null)
94+
{
95+
if (empty($options)) {
96+
return parent::build($plugin);
97+
}
98+
99+
$plugin = parent::build($plugin);
100+
$plugin->setOptions(new Pattern\PatternOptions($options));
101+
return $plugin;
102+
}
103+
72104
/**
73105
* Validate the plugin is of the expected type (v3).
74106
*
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
/**
3+
* @link http://github.com/zendframework/zend-cache for the canonical source repository
4+
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license http://framework.zend.com/license/new-bsd New BSD License
6+
*/
7+
8+
namespace Zend\Cache\Service;
9+
10+
use Interop\Container\ContainerInterface;
11+
use Zend\Cache\PatternPluginManager;
12+
use Zend\ServiceManager\FactoryInterface;
13+
use Zend\ServiceManager\ServiceLocatorInterface;
14+
15+
class PatternPluginManagerFactory implements FactoryInterface
16+
{
17+
/**
18+
* zend-servicemanager v2 support for invocation options.
19+
*
20+
* @param array
21+
*/
22+
protected $creationOptions;
23+
24+
/**
25+
* {@inheritDoc}
26+
*
27+
* @return PatternPluginManager
28+
*/
29+
public function __invoke(ContainerInterface $container, $name, array $options = null)
30+
{
31+
return new PatternPluginManager($container, $options ?: []);
32+
}
33+
34+
/**
35+
* {@inheritDoc}
36+
*
37+
* @return PatternPluginManager
38+
*/
39+
public function createService(ServiceLocatorInterface $container, $name = null, $requestedName = null)
40+
{
41+
return $this($container, $requestedName ?: PatternPluginManager::class, $this->creationOptions);
42+
}
43+
44+
/**
45+
* zend-servicemanager v2 support for invocation options.
46+
*
47+
* @param array $options
48+
* @return void
49+
*/
50+
public function setCreationOptions(array $options)
51+
{
52+
$this->creationOptions = $options;
53+
}
54+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
/**
3+
* @link http://github.com/zendframework/zend-cache for the canonical source repository
4+
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license http://framework.zend.com/license/new-bsd New BSD License
6+
*/
7+
8+
namespace Zend\Cache\Service;
9+
10+
use Interop\Container\ContainerInterface;
11+
use Zend\Cache\StorageFactory;
12+
use Zend\Cache\Storage\AdapterPluginManager;
13+
use Zend\Cache\Storage\PluginManager;
14+
15+
trait PluginManagerLookupTrait
16+
{
17+
/**
18+
* Prepare the storage factory with the adapter and plugins plugin managers.
19+
*
20+
* @param ContainerInterface $container
21+
* @return void
22+
*/
23+
private function prepareStorageFactory(ContainerInterface $container)
24+
{
25+
StorageFactory::setAdapterPluginManager($this->lookupStorageAdapterPluginManager($container));
26+
StorageFactory::setPluginManager($this->lookupStoragePluginManager($container));
27+
}
28+
29+
/**
30+
* Lookup the storage adapter plugin manager.
31+
*
32+
* Returns the Zend\Cache\Storage\AdapterPluginManager service if present,
33+
* or creates a new instance otherwise.
34+
*
35+
* @param ContainerInterface $container
36+
* @return AdapterPluginManager
37+
*/
38+
private function lookupStorageAdapterPluginManager(ContainerInterface $container)
39+
{
40+
if ($container->has(AdapterPluginManager::class)) {
41+
return $container->get(AdapterPluginManager::class);
42+
}
43+
return new AdapterPluginManager($container);
44+
}
45+
46+
/**
47+
* Lookup the storage plugins plugin manager.
48+
*
49+
* Returns the Zend\Cache\Storage\PluginManager service if present, or
50+
* creates a new instance otherwise.
51+
*
52+
* @param ContainerInterface $container
53+
* @return PluginManager
54+
*/
55+
private function lookupStoragePluginManager(ContainerInterface $container)
56+
{
57+
if ($container->has(PluginManager::class)) {
58+
return $container->get(PluginManager::class);
59+
}
60+
return new PluginManager($container);
61+
}
62+
}

0 commit comments

Comments
 (0)