From fd1dd3e29d21fa9f792890def5dded99056f9640 Mon Sep 17 00:00:00 2001 From: maks feltrin Date: Fri, 27 May 2016 22:48:21 +0200 Subject: [PATCH] fix performance issues using sm3 configure() using v3 configure method if available and adding all services/factories/aliases... in one go. fixes the performance issues i reported earlier: https://github.com/zendframework/zend-servicemanager/issues/122 https://github.com/zendframework/zend-expressive-zendviewrenderer/issues/25 https://github.com/zendframework/zend-form/issues/76 --- src/View/HelperConfig.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/View/HelperConfig.php b/src/View/HelperConfig.php index 48368227..311446c1 100644 --- a/src/View/HelperConfig.php +++ b/src/View/HelperConfig.php @@ -33,12 +33,15 @@ public function configureServiceManager(ServiceManager $serviceManager) { $config = $this->toArray(); - foreach ($config['factories'] as $service => $factory) { - $serviceManager->setFactory($service, $factory); - } - - foreach ($config['aliases'] as $alias => $target) { - $serviceManager->setAlias($alias, $target); + if (method_exists($serviceManager, 'configure')) { + $serviceManager->configure($config); + } else { + foreach ($config['factories'] as $service => $factory) { + $serviceManager->setFactory($service, $factory); + } + foreach ($config['aliases'] as $alias => $target) { + $serviceManager->setAlias($alias, $target); + } } return $serviceManager;