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

Commit a7cb8c5

Browse files
author
fhein
committed
Reintroduced $this->configure. Assumed, configure may be called once
only this is important. Sorry.
1 parent 7c0e8dd commit a7cb8c5

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/ServiceManager.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
2222
use Zend\ServiceManager\Exception\ServiceNotFoundException;
2323

24-
use function \array_merge;
2524
use function \array_merge_recursive;
2625
use function \class_exists;
2726
use function \get_class;
@@ -133,6 +132,13 @@ class ServiceManager implements ServiceLocatorInterface
133132
*/
134133
protected $sharedByDefault = true;
135134

135+
/**
136+
* Service manager was already configured?
137+
*
138+
* @var bool
139+
*/
140+
protected $configured = false;
141+
136142
/**
137143
* Cached abstract factories from string.
138144
*
@@ -360,9 +366,8 @@ public function configure(array $config)
360366

361367
if (isset($config['aliases'])) {
362368
$this->aliases = $config['aliases'] + $this->aliases;
363-
}
364-
365-
if (! empty($this->aliases)) {
369+
$this->mapAliasesToTargets();
370+
} elseif (! $this->configured && ! empty($this->aliases)) {
366371
$this->mapAliasesToTargets();
367372
}
368373

@@ -391,6 +396,8 @@ public function configure(array $config)
391396
$this->resolveInitializers($config['initializers']);
392397
}
393398

399+
$this->configured = true;
400+
394401
return $this;
395402
}
396403

@@ -782,7 +789,7 @@ private function createAliasesAndFactoriesForInvokables(array $invokables)
782789
*/
783790
private function validateServiceNames(array $config)
784791
{
785-
if ($this->allowOverride) {
792+
if ($this->allowOverride || ! $this->configured) {
786793
return;
787794
}
788795

0 commit comments

Comments
 (0)