Skip to content

Commit

Permalink
fix performance issues using sm3 configure()
Browse files Browse the repository at this point in the history
using v3 configure method if available and adding all services/factories/aliases... in one go.

fixes the performance issues i reported earlier:
zendframework/zend-servicemanager#122
zendframework/zend-expressive-zendviewrenderer#25
zendframework#76
  • Loading branch information
pine3ree committed May 27, 2016
1 parent c9c0287 commit fd1dd3e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/View/HelperConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit fd1dd3e

Please sign in to comment.