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

Commit

Permalink
Merge pull request #53 from pine3ree/patch-1
Browse files Browse the repository at this point in the history
factory sharing for pimple container
  • Loading branch information
weierophinney committed Mar 17, 2016
2 parents 8f3a07d + aa115bd commit 45b2eaa
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/ExpressiveInstaller/Resources/config/container-pimple.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@

// Inject factories
foreach ($config['dependencies']['factories'] as $name => $object) {
$container[$name] = function ($c) use ($object) {
$factory = new $object();
return $factory($c);
$container[$name] = function ($c) use ($object, $name) {
if ($c->has($object)) {
$factory = $c->get($object);
} else {
$factory = new $object();
$c[$object] = $factory;
}

return $factory($c, $name);
};
}
// Inject invokables
Expand Down

0 comments on commit 45b2eaa

Please sign in to comment.