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

Commit

Permalink
Merge branch 'hotfix/3322'
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Jan 4, 2013
7 parents 8c8a195 + c36f6c0 + 3ead99d + be05873 + 34e7aec + 2fcaf1c + 3ead5ab commit 754bd9a
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/ServiceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,8 @@ public function retrieveFromPeeringManagerFirst()
public function setInvokableClass($name, $invokableClass, $shared = true)
{
$cName = $this->canonicalizeName($name);
$rName = $name;

if ($this->has(array($cName, $rName), false)) {
if ($this->has(array($cName, $name), false)) {
if ($this->allowOverride === false) {
throw new Exception\InvalidServiceNameException(sprintf(
'A service by the name or alias "%s" already exists and cannot be overridden; please use an alternate name',
Expand Down Expand Up @@ -257,15 +256,14 @@ public function setInvokableClass($name, $invokableClass, $shared = true)
public function setFactory($name, $factory, $shared = true)
{
$cName = $this->canonicalizeName($name);
$rName = $name;

if (!is_string($factory) && !$factory instanceof FactoryInterface && !is_callable($factory)) {
throw new Exception\InvalidArgumentException(
'Provided abstract factory must be the class name of an abstract factory or an instance of an AbstractFactoryInterface.'
);
}

if ($this->has(array($cName, $rName), false)) {
if ($this->has(array($cName, $name), false)) {
if ($this->allowOverride === false) {
throw new Exception\InvalidServiceNameException(sprintf(
'A service by the name or alias "%s" already exists and cannot be overridden, please use an alternate name',
Expand Down Expand Up @@ -411,7 +409,6 @@ public function setShared($name, $isShared)
public function get($name, $usePeeringServiceManagers = true)
{
$cName = $this->canonicalizeName($name);
$rName = $name;
$isAlias = false;

if ($this->hasAlias($cName)) {
Expand All @@ -433,8 +430,8 @@ public function get($name, $usePeeringServiceManagers = true)
$instance = $this->retrieveFromPeeringManager($name);
}
if (!$instance) {
if ($this->canCreate(array($cName, $rName))) {
$instance = $this->create(array($cName, $rName));
if ($this->canCreate(array($cName, $name))) {
$instance = $this->create(array($cName, $name));
} elseif ($usePeeringServiceManagers && !$retrieveFromPeeringManagerFirst) {
$instance = $this->retrieveFromPeeringManager($name);
}
Expand Down

0 comments on commit 754bd9a

Please sign in to comment.