Skip to content

Commit 1f41f28

Browse files
committed
ZF2.5 and newer compatibility fix
1 parent 6b20a0c commit 1f41f28

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

config/module.config.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@
88
*/
99
namespace DI\ZendFramework2;
1010

11+
// compatibility with zend > 2.5
12+
$controllerType = 'ControllerLoader';
13+
if (class_exists('\Zend\Version\Version')) {
14+
$version = new \Zend\Version\Version();
15+
if ($version::compareVersion('2.5.0') <= 0) {
16+
$controllerType = 'ControllerManager';
17+
}
18+
}
19+
1120
return [
1221
'controllers' => [
1322
'invokables' => [
@@ -21,7 +30,7 @@
2130
),
2231

2332
'factories' => [
24-
'ControllerLoader' => __NAMESPACE__ . '\\Service\\ControllerLoaderFactory',
33+
$controllerType => __NAMESPACE__ . '\\Service\\ControllerLoaderFactory',
2534
'DiCache' => __NAMESPACE__ . '\\Service\\CacheFactory',
2635
],
2736
],

0 commit comments

Comments
 (0)