This repository was archived by the owner on Feb 6, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change 34
34
use function spl_object_hash ;
35
35
use function sprintf ;
36
36
use function trigger_error ;
37
+ use Zend \Stdlib \ArrayUtils ;
37
38
38
39
/**
39
40
* Service Manager.
@@ -362,7 +363,7 @@ public function configure(array $config)
362
363
}
363
364
364
365
if (isset ($ config ['delegators ' ])) {
365
- $ this ->delegators = array_merge_recursive ($ this ->delegators , $ config ['delegators ' ]);
366
+ $ this ->delegators = ArrayUtils:: merge ($ this ->delegators , $ config ['delegators ' ]);
366
367
}
367
368
368
369
if (isset ($ config ['shared ' ])) {
@@ -383,7 +384,7 @@ public function configure(array $config)
383
384
// If lazy service configuration was provided, reset the lazy services
384
385
// delegator factory.
385
386
if (isset ($ config ['lazy_services ' ]) && ! empty ($ config ['lazy_services ' ])) {
386
- $ this ->lazyServices = array_merge_recursive ($ this ->lazyServices , $ config ['lazy_services ' ]);
387
+ $ this ->lazyServices = ArrayUtils:: merge ($ this ->lazyServices , $ config ['lazy_services ' ]);
387
388
$ this ->lazyServicesDelegator = null ;
388
389
}
389
390
Original file line number Diff line number Diff line change 10
10
use DateTime ;
11
11
use PHPUnit \Framework \TestCase ;
12
12
use Psr \Container \ContainerInterface ;
13
+ use ReflectionObject ;
13
14
use stdClass ;
14
15
use Zend \ServiceManager \Factory \AbstractFactoryInterface ;
15
16
use Zend \ServiceManager \Factory \FactoryInterface ;
@@ -363,4 +364,34 @@ public function testResolvedAliasNoMatchingAbstractFactoryReturnsFalse()
363
364
364
365
self ::assertFalse ($ serviceManager ->has ('Alias ' ));
365
366
}
367
+
368
+ /**
369
+ * Hotfix #279
370
+ * @see https://github.com/zendframework/zend-servicemanager/issues/279
371
+ */
372
+ public function testConfigureMultipleTimes ()
373
+ {
374
+ $ config = [
375
+ 'delegators ' => [
376
+ 'Foo ' => 'FooDelegator ' ,
377
+ ],
378
+ 'lazy_services ' => [
379
+ 'class_map ' => [
380
+ 'Foo ' => 'Foo ' ,
381
+ ],
382
+ ]
383
+ ];
384
+
385
+ $ serviceManager = new ServiceManager ($ config );
386
+ $ serviceManager ->configure ($ config );
387
+
388
+ $ ref = new ReflectionObject ($ serviceManager );
389
+ $ delegatorsProperty = $ ref ->getProperty ('delegators ' );
390
+ $ delegatorsProperty ->setAccessible (true );
391
+ $ lazyServicesProperty = $ ref ->getProperty ('lazyServices ' );
392
+ $ lazyServicesProperty ->setAccessible (true );
393
+
394
+ self ::assertSame ($ config ['delegators ' ], $ delegatorsProperty ->getValue ($ serviceManager ));
395
+ self ::assertSame ($ config ['lazy_services ' ], $ lazyServicesProperty ->getValue ($ serviceManager ));
396
+ }
366
397
}
You can’t perform that action at this time.
0 commit comments