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

Commit bf28d0f

Browse files
committed
Merging develop to master in preparation for 2.6.0
2 parents e5ca080 + 8b90a42 commit bf28d0f

10 files changed

+458
-147
lines changed

.travis.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,23 @@ matrix:
1717
- php: 5.5
1818
env:
1919
- EXECUTE_CS_CHECK=true
20+
- php: 5.5
21+
env:
22+
- SERVICE_MANAGER_VERSION="^2.7.5"
2023
- php: 5.6
2124
env:
2225
- EXECUTE_TEST_COVERALLS=true
26+
- php: 5.6
27+
env:
28+
- SERVICE_MANAGER_VERSION="^2.7.5"
2329
- php: 7
24-
- php: hhvm
30+
- php: 7
31+
env:
32+
- SERVICE_MANAGER_VERSION="^2.7.5"
33+
- php: hhvm
34+
- php: hhvm
35+
env:
36+
- SERVICE_MANAGER_VERSION="^2.7.5"
2537
allow_failures:
2638
- php: 7
2739

@@ -33,9 +45,12 @@ before_install:
3345
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
3446
- composer self-update
3547
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then composer require --dev --no-update satooshi/php-coveralls ; fi
48+
- if [[ $SERVICE_MANAGER_VERSION != '' ]]; then composer require --dev --no-update "zendframework/zend-servicemanager:$SERVICE_MANAGER_VERSION" ; fi
49+
- if [[ $SERVICE_MANAGER_VERSION == '' ]]; then composer require --dev --no-update "zendframework/zend-servicemanager:^3.0.3" ; fi
3650

3751
install:
38-
- travis_retry composer install --no-interaction --ignore-platform-reqs
52+
- if [[ $SERVICE_MANAGER_V2 != 'true' ]]; then travis_retry composer install --no-interaction --ignore-platform-reqs ; fi
53+
- if [[ $SERVICE_MANAGER_V2 == 'true' ]]; then travis_retry composer update --no-interaction --ignore-platform-reqs --prefer-lowest ; fi
3954

4055
script:
4156
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/phpunit --coverage-clover clover.xml ; fi

CHANGELOG.md

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

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

5+
## 2.6.0 - 2016-02-18
6+
7+
### Added
8+
9+
- Nothing.
10+
11+
### Deprecated
12+
13+
- Nothing.
14+
15+
### Removed
16+
17+
- Nothing.
18+
19+
### Fixed
20+
21+
- [#86](https://github.com/zendframework/zend-inputfilter/pull/86),
22+
[#95](https://github.com/zendframework/zend-inputfilter/pull/95), and
23+
[#96](https://github.com/zendframework/zend-inputfilter/pull/96) update the
24+
component to be forwards-compatible with zend-servicemanager v3.
25+
526
## 2.5.6 - TBD
627

728
### Added

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
}
1414
},
1515
"require": {
16-
"php": ">=5.5",
17-
"zendframework/zend-filter": "~2.5",
18-
"zendframework/zend-validator": "^2.5.3",
19-
"zendframework/zend-stdlib": "~2.5"
16+
"php": "^5.5 || ^7.0",
17+
"zendframework/zend-filter": "^2.6",
18+
"zendframework/zend-validator": "^2.6",
19+
"zendframework/zend-stdlib": "^2.7 || ^3.0"
2020
},
2121
"require-dev": {
22-
"zendframework/zend-servicemanager": "~2.5",
22+
"zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3",
2323
"fabpot/php-cs-fixer": "1.7.*",
2424
"phpunit/PHPUnit": "^4.5"
2525
},

src/Factory.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
use Traversable;
1313
use Zend\Filter\FilterChain;
14-
use Zend\ServiceManager\ServiceLocatorInterface;
14+
use Zend\ServiceManager\ServiceManager;
1515
use Zend\Stdlib\ArrayUtils;
1616
use Zend\Validator\ValidatorChain;
1717
use Zend\Validator\ValidatorInterface;
@@ -117,15 +117,7 @@ public function clearDefaultValidatorChain()
117117
public function setInputFilterManager(InputFilterPluginManager $inputFilterManager)
118118
{
119119
$this->inputFilterManager = $inputFilterManager;
120-
$serviceLocator = $this->inputFilterManager->getServiceLocator();
121-
if ($serviceLocator && $serviceLocator instanceof ServiceLocatorInterface) {
122-
if ($serviceLocator->has('ValidatorManager')) {
123-
$this->getDefaultValidatorChain()->setPluginManager($serviceLocator->get('ValidatorManager'));
124-
}
125-
if ($serviceLocator->has('FilterManager')) {
126-
$this->getDefaultFilterChain()->setPluginManager($serviceLocator->get('FilterManager'));
127-
}
128-
}
120+
$inputFilterManager->populateFactoryPluginManagers($this);
129121
return $this;
130122
}
131123

@@ -135,7 +127,7 @@ public function setInputFilterManager(InputFilterPluginManager $inputFilterManag
135127
public function getInputFilterManager()
136128
{
137129
if (null === $this->inputFilterManager) {
138-
$this->inputFilterManager = new InputFilterPluginManager;
130+
$this->inputFilterManager = new InputFilterPluginManager(new ServiceManager());
139131
}
140132

141133
return $this->inputFilterManager;

src/InputFilterAbstractServiceFactory.php

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace Zend\InputFilter;
1111

12+
use Interop\Container\ContainerInterface;
1213
use Zend\Filter\FilterPluginManager;
1314
use Zend\ServiceManager\AbstractFactoryInterface;
1415
use Zend\ServiceManager\ServiceLocatorInterface;
@@ -22,21 +23,34 @@ class InputFilterAbstractServiceFactory implements AbstractFactoryInterface
2223
protected $factory;
2324

2425
/**
25-
* @param ServiceLocatorInterface $inputFilters
26+
* @param ContainerInterface $services
27+
* @param string $rName
28+
* @param array $options
29+
* @return InputFilterInterface
30+
*/
31+
public function __invoke(ContainerInterface $services, $rName, array $options = null)
32+
{
33+
$allConfig = $services->get('config');
34+
$config = $allConfig['input_filter_specs'][$rName];
35+
$factory = $this->getInputFilterFactory($services);
36+
37+
return $factory->createInputFilter($config);
38+
}
39+
40+
/**
41+
*
42+
* @param ContainerInterface $services
2643
* @param string $cName
2744
* @param string $rName
2845
* @return bool
2946
*/
30-
public function canCreateServiceWithName(ServiceLocatorInterface $inputFilters, $cName, $rName)
47+
public function canCreate(ContainerInterface $services, $rName)
3148
{
32-
$services = $inputFilters->getServiceLocator();
33-
if (! $services instanceof ServiceLocatorInterface
34-
|| ! $services->has('Config')
35-
) {
49+
if (! $services->has('config')) {
3650
return false;
3751
}
3852

39-
$config = $services->get('Config');
53+
$config = $services->get('config');
4054
if (!isset($config['input_filter_specs'][$rName])
4155
|| !is_array($config['input_filter_specs'][$rName])
4256
) {
@@ -46,6 +60,27 @@ public function canCreateServiceWithName(ServiceLocatorInterface $inputFilters,
4660
return true;
4761
}
4862

63+
/**
64+
* Determine if we can create a service with name (v2)
65+
*
66+
* @param ServiceLocatorInterface $serviceLocator
67+
* @param $name
68+
* @param $requestedName
69+
* @return bool
70+
*/
71+
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
72+
{
73+
// v2 => need to get parent service locator
74+
$services = $serviceLocator->getServiceLocator();
75+
76+
// No parent locator => cannot create service.
77+
if (! $services) {
78+
return false;
79+
}
80+
81+
return $this->canCreate($services, $requestedName);
82+
}
83+
4984
/**
5085
* @param ServiceLocatorInterface $inputFilters
5186
* @param string $cName
@@ -54,13 +89,15 @@ public function canCreateServiceWithName(ServiceLocatorInterface $inputFilters,
5489
*/
5590
public function createServiceWithName(ServiceLocatorInterface $inputFilters, $cName, $rName)
5691
{
57-
$services = $inputFilters->getServiceLocator();
58-
$allConfig = $services->get('Config');
59-
$config = $allConfig['input_filter_specs'][$rName];
92+
// v2 => need to get parent service locator
93+
$services = $inputFilters->getServiceLocator();
6094

61-
$factory = $this->getInputFilterFactory($services);
95+
// No parent locator => cannot create service.
96+
if (! $services) {
97+
return false;
98+
}
6299

63-
return $factory->createInputFilter($config);
100+
return $this($services, $rName);
64101
}
65102

66103
/**
@@ -94,7 +131,7 @@ protected function getFilterPluginManager(ServiceLocatorInterface $services)
94131
return $services->get('FilterManager');
95132
}
96133

97-
return new FilterPluginManager();
134+
return new FilterPluginManager($services);
98135
}
99136

100137
/**
@@ -107,6 +144,6 @@ protected function getValidatorPluginManager(ServiceLocatorInterface $services)
107144
return $services->get('ValidatorManager');
108145
}
109146

110-
return new ValidatorPluginManager();
147+
return new ValidatorPluginManager($services);
111148
}
112149
}

0 commit comments

Comments
 (0)