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

Commit

Permalink
Skip validation if overrides are allowed at construction time.
Browse files Browse the repository at this point in the history
  • Loading branch information
fhein committed Jan 29, 2018
1 parent 5aa73cc commit d2b4709
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions src/ServiceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function __construct(array $config = [])
$this->resolveAbstractFactories(null);
}

$this->configure($config);
$this->configureSkippingOverrideValidation($config);
}

/**
Expand Down Expand Up @@ -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:
*
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -382,8 +399,6 @@ public function configure(array $config)
}

$this->configured = true;

return $this;
}

/**
Expand Down

0 comments on commit d2b4709

Please sign in to comment.