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

Commit

Permalink
Added the checkAbstractFactories parameter to has().
Browse files Browse the repository at this point in the history
  • Loading branch information
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/ServiceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public function setInvokableClass($name, $invokableClass, $shared = true)
$cName = $this->canonicalizeName($name);
$rName = $name;

if ($this->allowOverride === false && $this->has(array($cName, $rName))) {
if ($this->allowOverride === false && $this->has(array($cName, $rName), 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',
$cName
Expand All @@ -222,7 +222,7 @@ public function setFactory($name, $factory, $shared = true)
);
}

if ($this->allowOverride === false && $this->has(array($cName, $rName))) {
if ($this->allowOverride === false && $this->has(array($cName, $rName), 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',
$cName
Expand Down Expand Up @@ -301,7 +301,7 @@ public function setService($name, $service, $shared = true)
$cName = $this->canonicalizeName($name);
$rName = $name;

if ($this->allowOverride === false && $this->has($cName)) {
if ($this->allowOverride === false && $this->has($cName, false)) {
throw new Exception\InvalidServiceNameException(sprintf(
'%s: A service by the name "%s" or alias already exists and cannot be overridden, please use an alternate name.',
__METHOD__,
Expand Down Expand Up @@ -464,7 +464,7 @@ public function create($name)
* @param $name
* @return bool
*/
public function canCreate($name)
public function canCreate($name, $checkAbstractFactories = true)
{
if (is_array($name)) {
list($cName, $rName) = $name;
Expand Down Expand Up @@ -492,7 +492,7 @@ public function canCreate($name)
return true;
}

if ($this->canCreateFromAbstractFactory($cName, $rName)) {
if ($checkAbstractFactories && $this->canCreateFromAbstractFactory($cName, $rName)) {
return true;
}

Expand All @@ -503,7 +503,7 @@ public function canCreate($name)
* @param $name
* @return bool
*/
public function has($name, $usePeeringServiceManagers = true)
public function has($name, $checkAbstractFactories = true, $usePeeringServiceManagers = true)
{
if (is_array($name)) {
list($cName, $rName) = $name;
Expand All @@ -512,7 +512,7 @@ public function has($name, $usePeeringServiceManagers = true)
$cName = $this->canonicalizeName($rName);
}

if ($this->canCreate(array($cName, $rName))) {
if ($this->canCreate(array($cName, $rName), $checkAbstractFactories)) {
return true;
}

Expand Down Expand Up @@ -577,7 +577,7 @@ public function setAlias($alias, $nameOrAlias)
throw new Exception\InvalidServiceNameException('Invalid service name alias');
}

if ($this->allowOverride === false && $this->has(array($cAlias, $alias))) {
if ($this->allowOverride === false && $this->has(array($cAlias, $alias), true)) {
throw new Exception\InvalidServiceNameException('An alias by this name already exists');
}

Expand Down

0 comments on commit 55a06dc

Please sign in to comment.