diff --git a/src/ServiceManager.php b/src/ServiceManager.php index 2ab0dbed..e68986fe 100644 --- a/src/ServiceManager.php +++ b/src/ServiceManager.php @@ -170,7 +170,7 @@ public function __construct(array $config = []) $this->resolveAbstractFactories(null); } - $this->configure($config); + $this->configureSkippingOverrideValidation($config); } /** @@ -291,7 +291,27 @@ public function getAllowOverride() } /** - * Configure the service manager + * Configure the service manager applying validation that overrides + * are allowed + * + * @see configureSkippingOverrideValidation below + * + * @param array $config + * @return self + * @throws ContainerModificationsNotAllowedException if the allow + * override flag has been toggled off, and a service instance + * exists for a given service. + */ + public function configure(array $config) + { + $this->validateOverrides($config); + $this->configureSkippingOverrideValidation($config); + return $this; + } + + /** + * Configure the service manager without applying validation that override + * is allowed (called by __construct directly) * * Valid top keys are: * @@ -325,15 +345,12 @@ public function getAllowOverride() * should be shared by default. * * @param array $config - * @return self * @throws ContainerModificationsNotAllowedException if the allow * override flag has been toggled off, and a service instance * exists for a given service. */ - public function configure(array $config) + private function configureSkippingOverrideValidation($config) { - $this->validateOverrides($config); - if (isset($config['services'])) { $this->services = $config['services'] + $this->services; } @@ -382,8 +399,6 @@ public function configure(array $config) } $this->configured = true; - - return $this; } /**