Skip to content

Commit

Permalink
Merge pull request #156 from Zheness/patch-2
Browse files Browse the repository at this point in the history
Fix creation of new object when instance already exists
  • Loading branch information
moufmouf authored Jan 2, 2019
2 parents 965154e + e5e6f64 commit b6a11bf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Mouf/MoufManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,11 @@ private function instantiateComponent($instanceName) {
throw new MoufException("Unknown parameter type ".$constructorParameterDefinition['parametertype']." for parameter in constructor of instance '".$instanceName."'");
}
}
$object = $classDescriptor->newInstanceArgs($constructorParameters);
if (!isset($this->objectInstances[$instanceName])) {
$object = $classDescriptor->newInstanceArgs($constructorParameters);
} else {
$object = $this->objectInstances[$instanceName];
}
} else {
$object = new $className();
}
Expand Down

0 comments on commit b6a11bf

Please sign in to comment.