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

Commit

Permalink
Merge branch 'feature/68' into develop
Browse files Browse the repository at this point in the history
Close #69
Close #68
Close #64
  • Loading branch information
weierophinney committed Feb 11, 2016
2 parents 4f9d31b + 4def038 commit 179da18
Show file tree
Hide file tree
Showing 20 changed files with 468 additions and 213 deletions.
53 changes: 39 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ services:

env:
global:
- TESTS_ZEND_CACHE_APC_ENABLED=true
- TESTS_ZEND_CACHE_MEMCACHED_ENABLED=true
- TESTS_ZEND_CACHE_MEMCACHED_HOST='127.0.0.1'
- TESTS_ZEND_CACHE_MEMCACHED_PORT=11211
- TESTS_ZEND_CACHE_MEMCACHE_ENABLED=true
- TESTS_ZEND_CACHE_MEMCACHE_HOST=$TESTS_ZEND_CACHE_MEMCACHED_HOST
- TESTS_ZEND_CACHE_MEMCACHE_PORT=$TESTS_ZEND_CACHE_MEMCACHED_PORT
- TESTS_ZEND_CACHE_MONGODB_ENABLED=true
- TESTS_ZEND_CACHE_REDIS_ENABLED=true
- TESTS_ZEND_CACHE_REDIS_HOST='127.0.0.1'
- TESTS_ZEND_CACHE_REDIS_PORT=6379
- TESTS_ZEND_CACHE_REDIS_PASSWORD=''
- TESTS_ZEND_CACHE_REDIS_DATABASE=0
- TESTS_ZEND_CACHE_APC_ENABLED: true
- TESTS_ZEND_CACHE_MEMCACHED_ENABLED: true
- TESTS_ZEND_CACHE_MEMCACHED_HOST: "127.0.0.1"
- TESTS_ZEND_CACHE_MEMCACHED_PORT: 11211
- TESTS_ZEND_CACHE_MEMCACHE_ENABLED: true
- TESTS_ZEND_CACHE_MEMCACHE_HOST: $TESTS_ZEND_CACHE_MEMCACHED_HOST
- TESTS_ZEND_CACHE_MEMCACHE_PORT: $TESTS_ZEND_CACHE_MEMCACHED_PORT
- TESTS_ZEND_CACHE_MONGODB_ENABLED: true
- TESTS_ZEND_CACHE_REDIS_ENABLED: true
- TESTS_ZEND_CACHE_REDIS_HOST: "127.0.0.1"
- TESTS_ZEND_CACHE_REDIS_PORT: 6379
- TESTS_ZEND_CACHE_REDIS_PASSWORD: ""
- TESTS_ZEND_CACHE_REDIS_DATABASE: 0

matrix:
fast_finish: true
Expand All @@ -39,15 +39,35 @@ matrix:
env:
- EXECUTE_CS_CHECK=true
- PECL_INSTALL_APCU='apcu-4.0.8'
- php: 5.5
env:
- SERVICE_MANAGER_VERSION="^2.7.5"
- EVENT_MANAGER_VERSION="^2.6.2"
- PECL_INSTALL_APCU='apcu-4.0.8'
- php: 5.6
env:
- EXECUTE_TEST_COVERALLS=true
- PECL_INSTALL_APCU='apcu-4.0.8'
- php: 5.6
env:
- SERVICE_MANAGER_VERSION="^2.7.5"
- EVENT_MANAGER_VERSION="^2.6.2"
- PECL_INSTALL_APCU='apcu-4.0.8'
- php: 7
env:
- PECL_INSTALL_APCU='apcu'
- PECL_INSTALL_APCU_BC='apcu_bc-beta'
- php: 7
env:
- SERVICE_MANAGER_VERSION="^2.7.5"
- EVENT_MANAGER_VERSION="^2.6.2"
- PECL_INSTALL_APCU='apcu'
- PECL_INSTALL_APCU_BC='apcu_bc-beta'
- php: hhvm
- php: hhvm
env:
- SERVICE_MANAGER_VERSION="^2.7.5"
- EVENT_MANAGER_VERSION="^2.6.2"
allow_failures:
- php: 7
- php: hhvm
Expand All @@ -60,11 +80,16 @@ before_install:
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
- composer self-update
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then composer require --dev --no-update satooshi/php-coveralls ; fi
- if [[ $SERVICE_MANAGER_VERSION != '' ]]; then composer require --no-update "zendframework/zend-servicemanager:$SERVICE_MANAGER_VERSION" ; fi
- if [[ $SERVICE_MANAGER_VERSION == '' ]]; then composer require --no-update "zendframework/zend-servicemanager:^3.0.3" ; fi
- if [[ $SERVICE_MANAGER_VERSION == '' ]]; then composer remove --dev --no-update zendframework/zend-session ; fi
- if [[ $EVENT_MANAGER_VERSION != '' ]]; then composer require --no-update "zendframework/zend-eventmanager:$EVENT_MANAGER_VERSION" ; fi
- if [[ $EVENT_MANAGER_VERSION == '' ]]; then composer require --no-update "zendframework/zend-eventmanager:^3.0" ; fi

install:
- travis_retry composer install --no-interaction --ignore-platform-reqs
- if [[ $PECL_INSTALL_APCU != '' ]]; then echo "yes\nno\n" | pecl install $PECL_INSTALL_APCU || return 0 ; fi

# see https://pear.php.net/bugs/bug.php?id=21007
# pecl install adds the "extension=*.so" directive on top of php.ini which results in wrong extension order
# -> Attach another ini file loading the extension kind of solves the issue.
Expand Down
12 changes: 7 additions & 5 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.

## 3.0.0 - TBD
## 2.6.0 - TBD

### Added

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

### Fixed

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

## 2.5.4 - TBD

Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
}
},
"require": {
"php": ">=5.5",
"zendframework/zend-stdlib": "~2.5",
"zendframework/zend-servicemanager": "dev-develop as 2.7.0",
"zendframework/zend-eventmanager": "dev-develop as 2.7.0"
"php": "^5.5 || ^7.0",
"zendframework/zend-stdlib": "^2.7 || ^3.0",
"zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3",
"zendframework/zend-eventmanager": "^2.6.2 || ^3.0"
},
"require-dev": {
"zendframework/zend-serializer": "dev-develop as 2.6.0",
"zendframework/zend-session": "~2.5",
"zendframework/zend-serializer": "^2.6",
"zendframework/zend-session": "^2.5",
"fabpot/php-cs-fixer": "1.7.*",
"phpunit/PHPUnit": "~4.0"
},
Expand All @@ -42,7 +42,7 @@
"extra": {
"branch-alias": {
"dev-master": "2.5-dev",
"dev-develop": "3.0-dev"
"dev-develop": "2.6-dev"
}
},
"autoload-dev": {
Expand Down
71 changes: 63 additions & 8 deletions src/PatternPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use Zend\ServiceManager\AbstractPluginManager;
use Zend\ServiceManager\Factory\InvokableFactory;
use Zend\ServiceManager\Exception\InvalidServiceException;

/**
* Plugin manager implementation for cache pattern adapters
Expand All @@ -23,31 +24,85 @@ class PatternPluginManager extends AbstractPluginManager
{
protected $aliases = [
'callback' => Pattern\CallbackCache::class,
'Callback' => Pattern\CallbackCache::class,
'capture' => Pattern\CaptureCache::class,
'Capture' => Pattern\CaptureCache::class,
'class' => Pattern\ClassCache::class,
'Class' => Pattern\ClassCache::class,
'object' => Pattern\ObjectCache::class,
'Object' => Pattern\ObjectCache::class,
'output' => Pattern\OutputCache::class,
'page' => Pattern\PageCache::class,
'Output' => Pattern\OutputCache::class,
];

protected $factories = [
Pattern\CallbackCache::class => InvokableFactory::class,
Pattern\CaptureCache::class => InvokableFactory::class,
Pattern\ClassCache::class => InvokableFactory::class,
Pattern\ObjectCache::class => InvokableFactory::class,
Pattern\OutputCache::class => InvokableFactory::class,
Pattern\PageCache::class => InvokableFactory::class,
Pattern\CallbackCache::class => InvokableFactory::class,
Pattern\CaptureCache::class => InvokableFactory::class,
Pattern\ClassCache::class => InvokableFactory::class,
Pattern\ObjectCache::class => InvokableFactory::class,
Pattern\OutputCache::class => InvokableFactory::class,

// v2 normalized FQCNs
'zendcachepatterncallbackcache' => InvokableFactory::class,
'zendcachepatterncapturecache' => InvokableFactory::class,
'zendcachepatternclasscache' => InvokableFactory::class,
'zendcachepatternobjectcache' => InvokableFactory::class,
'zendcachepatternoutputcache' => InvokableFactory::class,
];

/**
* Don't share by default
*
* @var array
* @var boolean
*/
protected $shareByDefault = false;

/**
* Don't share by default
*
* @var boolean
*/
protected $sharedByDefault = false;

/**
* @var string
*/
protected $instanceOf = Pattern\PatternInterface::class;

/**
* Validate the plugin is of the expected type (v3).
*
* Validates against `$instanceOf`.
*
* @param mixed $instance
* @throws InvalidServiceException
*/
public function validate($instance)
{
if (! $instance instanceof $this->instanceOf) {
throw new InvalidServiceException(sprintf(
'%s can only create instances of %s; %s is invalid',
get_class($this),
$this->instanceOf,
(is_object($instance) ? get_class($instance) : gettype($instance))
));
}
}

/**
* Validate the plugin is of the expected type (v2).
*
* Proxies to `validate()`.
*
* @param mixed $plugin
* @throws Exception\RuntimeException if invalid
*/
public function validatePlugin($plugin)
{
try {
$this->validate($plugin);
} catch (InvalidServiceException $e) {
throw new Exception\RuntimeException($e->getMessage(), $e->getCode(), $e);
}
}
}
21 changes: 19 additions & 2 deletions src/Service/StorageCacheAbstractServiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
namespace Zend\Cache\Service;

use Zend\Cache\StorageFactory;
use Zend\ServiceManager\Factory\AbstractFactoryInterface;
use Zend\ServiceManager\AbstractFactoryInterface;
use Interop\Container\ContainerInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

/**
* Storage cache factory for multiple caches.
Expand All @@ -35,7 +36,7 @@ class StorageCacheAbstractServiceFactory implements AbstractFactoryInterface
* @param string $requestedName
* @return boolean
*/
public function canCreateServiceWithName(ContainerInterface $container, $requestedName)
public function canCreate(ContainerInterface $container, $requestedName)
{
$config = $this->getConfig($container);
if (empty($config)) {
Expand All @@ -44,6 +45,17 @@ public function canCreateServiceWithName(ContainerInterface $container, $request
return (isset($config[$requestedName]) && is_array($config[$requestedName]));
}

/**
* @param ServiceLocatorInterface $serviceLocator
* @param string $name
* @param string $requestedName
* @return boolean
*/
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
{
return $this->canCreate($serviceLocator, $requestedName);
}

/**
* Create an object
*
Expand All @@ -58,6 +70,11 @@ public function __invoke(ContainerInterface $container, $requestedName, array $o
return StorageFactory::factory($config[$requestedName]);
}

public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
{
return $this($serviceLocator, $requestedName);
}

/**
* Retrieve cache configuration, if any
*
Expand Down
9 changes: 8 additions & 1 deletion src/Service/StorageCacheFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@

namespace Zend\Cache\Service;

use Zend\Cache\Storage\StorageInterface;
use Zend\Cache\StorageFactory;
use Zend\ServiceManager\Factory\FactoryInterface;
use Zend\ServiceManager\FactoryInterface;
use Interop\Container\ContainerInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

/**
* Storage cache factory.
Expand All @@ -24,4 +26,9 @@ public function __invoke(ContainerInterface $container, $requestedName, array $o
$cacheConfig = isset($config['cache']) ? $config['cache'] : [];
return StorageFactory::factory($cacheConfig);
}

public function createService(ServiceLocatorInterface $serviceLocator)
{
return $this($serviceLocator, StorageInterface::class);
}
}
Loading

0 comments on commit 179da18

Please sign in to comment.