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

Commit 65b6f01

Browse files
committed
Update zend-mvc v2 to use zend-servicemanager-di
zend-servicemanager-di contains tests and code to ensure it works against both v2 and v3 versions of zend-servicemanager, unlike the code currently in zend-mvc. Updating to use it is backwards compatible, assuming the following: - zend-servicemanager-di is tested against both v2 and v3 of zend-servicemanager, demonstrating that the various classes it contains that overlap with zend-servicemanager v2 pose no conflicts. - each of DiAbstractServiceFactoryFactory, DiFactory, DiServiceInitializerFactory, and DiStrictAbstractServiceFactory from zend-mvc v2 return artifacts from the `Zend\ServiceManager\Di` namespace, allowing them to simply extend the relevant factories that exist in zend-servicemanager-di. - DiStrictAbstractServiceFactoryFactory can be left intact, ensuring it returns the `Zend\Mvc\Service\DiStrictAbstractServiceFactory` instance, and thus preserving the inheritance tree. All of the DI-related factories in zend-mvc are now marked deprecated as well, with annotations detailing how to upgrade code to work with zend-servicemanager-di to make it forwards-compatible.
1 parent d374f7c commit 65b6f01

7 files changed

+203
-363
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"php": "^5.5 || ^7.0",
1717
"zendframework/zend-eventmanager": "^2.6.2 || ^3.0",
1818
"zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3",
19+
"zendframework/zend-servicemanager-di": "^1.0.1",
1920
"zendframework/zend-hydrator": "^1.1 || ^2.1",
2021
"zendframework/zend-form": "^2.7",
2122
"zendframework/zend-stdlib": "^2.7.5 || ^3.0",

composer.lock

Lines changed: 153 additions & 102 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Service/DiAbstractServiceFactoryFactory.php

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,43 +9,17 @@
99

1010
namespace Zend\Mvc\Service;
1111

12-
use Interop\Container\ContainerInterface;
13-
use Zend\ServiceManager\Di\DiAbstractServiceFactory;
14-
use Zend\ServiceManager\FactoryInterface;
15-
use Zend\ServiceManager\ServiceLocatorInterface;
16-
use Zend\ServiceManager\ServiceManager;
12+
use Zend\ServiceManager\Di\DiAbstractServiceFactoryFactory as OriginalFactory;
1713

18-
class DiAbstractServiceFactoryFactory implements FactoryInterface
14+
/**
15+
* Since 2.7.9, this class now extends the version defined in zend-servicemanager-di,
16+
* ensuring backwards compatibility with zend-servicemanger v2 and forwards
17+
* compatibility with zend-servicemanager v3.
18+
*
19+
* @deprecated Since 2.7.9. The factory is now defined in zend-servicemanager-di,
20+
* and removed in 3.0.0. Use Zend\ServiceManager\Di\DiAbstractServiceFactoryFactory
21+
* from zend-servicemanager-di instead if you rely on this feature.
22+
*/
23+
class DiAbstractServiceFactoryFactory extends OriginalFactory
1924
{
20-
/**
21-
* Class responsible for instantiating a DiAbstractServiceFactory
22-
*
23-
* @param ContainerInterface $container
24-
* @param string $name
25-
* @param null|array $options
26-
* @return DiAbstractServiceFactory
27-
*/
28-
public function __invoke(ContainerInterface $container, $name, array $options = null)
29-
{
30-
$factory = new DiAbstractServiceFactory($container->get('Di'), DiAbstractServiceFactory::USE_SL_BEFORE_DI);
31-
32-
if ($serviceLocator instanceof ServiceManager) {
33-
$serviceLocator->addAbstractFactory($factory, false);
34-
}
35-
36-
return $factory;
37-
}
38-
39-
/**
40-
* Create and return DiAbstractServiceFactory instance
41-
*
42-
* For use with zend-servicemanager v2; proxies to __invoke().
43-
*
44-
* @param ServiceLocatorInterface $container
45-
* @return DiAbstractServiceFactory
46-
*/
47-
public function createService(ServiceLocatorInterface $container)
48-
{
49-
return $this($container, DiAbstractServiceFactory::class);
50-
}
5125
}

0 commit comments

Comments
 (0)