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

Commit 7d04622

Browse files
committed
Merge branch 'feature/forwards-compat' into develop
Close #20
2 parents 7ca697a + f5779f2 commit 7d04622

10 files changed

+495
-138
lines changed

.travis.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,40 @@ cache:
1111
directories:
1212
- $HOME/.composer/cache
1313

14+
env:
15+
global:
16+
- SERVICE_MANAGER_VERSION="^3.0.3"
17+
- REMOVE_DEPENDENCIES="zendframework/zend-mvc"
18+
1419
matrix:
1520
fast_finish: true
1621
include:
1722
- php: 5.5
1823
env:
1924
- EXECUTE_CS_CHECK=true
25+
- php: 5.5
26+
env:
27+
- SERVICE_MANAGER_VERSION="^2.7.5"
28+
- REMOVE_DEPENDENCIES=""
2029
- php: 5.6
2130
env:
2231
- EXECUTE_TEST_COVERALLS=true
32+
- php: 5.6
33+
env:
34+
- SERVICE_MANAGER_VERSION="^2.7.5"
35+
- REMOVE_DEPENDENCIES=""
2336
- php: 7
37+
- php: 7
38+
env:
39+
- SERVICE_MANAGER_VERSION="^2.7.5"
40+
- REMOVE_DEPENDENCIES=""
41+
- php: hhvm
2442
- php: hhvm
43+
env:
44+
- SERVICE_MANAGER_VERSION="^2.7.5"
45+
- REMOVE_DEPENDENCIES=""
2546
allow_failures:
26-
- php: 7
47+
- php: hhvm
2748

2849
notifications:
2950
irc: "irc.freenode.org#zftalk.dev"
@@ -33,6 +54,8 @@ before_install:
3354
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
3455
- composer self-update
3556
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then composer require --dev --no-update satooshi/php-coveralls ; fi
57+
- composer require --dev --no-update "zendframework/zend-servicemanager:$SERVICE_MANAGER_VERSION"
58+
- if [[ $REMOVE_DEPENDENCIES != '' ]]; then composer remove --dev --no-update $REMOVE_DEPENDENCIES ; fi
3659

3760
install:
3861
- travis_retry composer install --no-interaction --ignore-platform-reqs

CHANGELOG.md

Lines changed: 4 additions & 3 deletions
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,5 +18,6 @@ All notable changes to this project will be documented in this file, in reverse
1818

1919
### Fixed
2020

21-
- [#5](https://github.com/zendframework/zend-navigation/pull/5) updates the
22-
component to the v3 version of zend-servicemanager.
21+
- [#5](https://github.com/zendframework/zend-navigation/pull/5) and
22+
[#20](https://github.com/zendframework/zend-navigation/pull/20) update the
23+
code to be forwards compatible with zend-servicemanager v3.

composer.json

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,20 @@
1313
}
1414
},
1515
"require": {
16-
"php": ">=5.5",
17-
"zendframework/zend-stdlib": "dev-develop as 2.8.0"
16+
"php": "^5.5 || ^7.0",
17+
"zendframework/zend-stdlib": "^2.7 || ^3.0"
1818
},
1919
"require-dev": {
20-
"zendframework/zend-config": "dev-develop as 2.6.0",
21-
"zendframework/zend-console": "~2.5",
22-
"zendframework/zend-http": "~2.5",
23-
"zendframework/zend-i18n": "dev-develop as 2.6.0",
24-
"zendframework/zend-log": "~2.5",
25-
"zendframework/zend-modulemanager": "dev-develop as 2.7.0",
26-
"zendframework/zend-mvc": "dev-develop as 2.7.0",
27-
"zendframework/zend-permissions-acl": "~2.5",
28-
"zendframework/zend-servicemanager": "dev-develop as 2.7.0",
29-
"zendframework/zend-uri": "~2.5",
30-
"zendframework/zend-view": "dev-develop as 2.6.0",
20+
"zendframework/zend-config": "^2.6",
21+
"zendframework/zend-console": "^2.6",
22+
"zendframework/zend-http": "^2.5.4",
23+
"zendframework/zend-i18n": "^2.6",
24+
"zendframework/zend-log": "^2.7.1",
25+
"zendframework/zend-mvc": "^2.6.3",
26+
"zendframework/zend-permissions-acl": "^2.6",
27+
"zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3",
28+
"zendframework/zend-uri": "^2.5",
29+
"zendframework/zend-view": "^2.6.3",
3130
"fabpot/php-cs-fixer": "1.7.*",
3231
"phpunit/PHPUnit": "~4.0"
3332
},

src/Service/AbstractNavigationFactory.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
use Zend\Mvc\Router\RouteStackInterface as Router;
1717
use Zend\Navigation\Exception;
1818
use Zend\Navigation\Navigation;
19-
use Zend\ServiceManager\Factory\FactoryInterface;
19+
use Zend\ServiceManager\FactoryInterface;
20+
use Zend\ServiceManager\ServiceLocatorInterface;
2021

2122
/**
2223
* Abstract navigation factory
@@ -29,14 +30,31 @@ abstract class AbstractNavigationFactory implements FactoryInterface
2930
protected $pages;
3031

3132
/**
33+
* Create and return a new Navigation instance (v3).
34+
*
3235
* @param ContainerInterface $container
33-
* @return \Zend\Navigation\Navigation
36+
* @param string $requestedName
37+
* @param null|array $options
38+
* @return Navigation
3439
*/
3540
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
3641
{
3742
return new Navigation($this->getPages($container));
3843
}
3944

45+
/**
46+
* Create and return a new Navigation instance (v2).
47+
*
48+
* @param ContainerInterface $container
49+
* @param null|string $name
50+
* @param null|string $requestedName
51+
* @return Navigation
52+
*/
53+
public function createService(ServiceLocatorInterface $container, $name = null, $requestedName = null)
54+
{
55+
return $this($container, $requestedName);
56+
}
57+
4058
/**
4159
* @abstract
4260
* @return string

src/Service/NavigationAbstractServiceFactory.php

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

1212
use Interop\Container\ContainerInterface;
1313
use Zend\Navigation\Navigation;
14-
use Zend\ServiceManager\Factory\AbstractFactoryInterface;
14+
use Zend\ServiceManager\AbstractFactoryInterface;
15+
use Zend\ServiceManager\ServiceLocatorInterface;
1516

1617
/**
1718
* Navigation abstract service factory
@@ -43,13 +44,14 @@ final class NavigationAbstractServiceFactory implements AbstractFactoryInterface
4344
protected $config;
4445

4546
/**
46-
* Can we create a navigation by the requested name?
47+
* Can we create a navigation by the requested name? (v3)
4748
*
4849
* @param ContainerInterface $container
49-
* @param string $requestedName Name by which service was requested, must start with Zend\Navigation\
50+
* @param string $requestedName Name by which service was requested, must
51+
* start with Zend\Navigation\
5052
* @return bool
5153
*/
52-
public function canCreateServiceWithName(ContainerInterface $container, $requestedName)
54+
public function canCreate(ContainerInterface $container, $requestedName)
5355
{
5456
if (0 !== strpos($requestedName, self::SERVICE_PREFIX)) {
5557
return false;
@@ -59,8 +61,25 @@ public function canCreateServiceWithName(ContainerInterface $container, $request
5961
return $this->hasNamedConfig($requestedName, $config);
6062
}
6163

64+
/**
65+
* Can we create a navigation by the requested name? (v2)
66+
*
67+
* @param ServiceLocatorInterface $container
68+
* @param string $name Normalized name by which service was requested;
69+
* ignored.
70+
* @param string $requestedName Name by which service was requested, must
71+
* start with Zend\Navigation\
72+
* @return bool
73+
*/
74+
public function canCreateServiceWithName(ServiceLocatorInterface $container, $name, $requestedName)
75+
{
76+
return $this->canCreate($container, $requestedName);
77+
}
78+
6279
/**
6380
* {@inheritDoc}
81+
*
82+
* @return Navigation
6483
*/
6584
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
6685
{
@@ -69,6 +88,21 @@ public function __invoke(ContainerInterface $container, $requestedName, array $o
6988
return $factory($container, $requestedName);
7089
}
7190

91+
/**
92+
* Can we create a navigation by the requested name? (v2)
93+
*
94+
* @param ServiceLocatorInterface $container
95+
* @param string $name Normalized name by which service was requested;
96+
* ignored.
97+
* @param string $requestedName Name by which service was requested, must
98+
* start with Zend\Navigation\
99+
* @return Navigation
100+
*/
101+
public function createServiceWithName(ServiceLocatorInterface $container, $name, $requestedName)
102+
{
103+
return $this($container, $requestedName);
104+
}
105+
72106
/**
73107
* Get navigation configuration, if any
74108
*

0 commit comments

Comments
 (0)