Skip to content

Commit

Permalink
馃敤 Refactoring delegator
Browse files Browse the repository at this point in the history
  • Loading branch information
elie29 committed Mar 14, 2022
1 parent 5949a48 commit 6123582
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Config.php
Expand Up @@ -151,11 +151,9 @@ private function createDelegatorFactory(string $delegator, string $previous, str
string $previous,
string $name
) {
$factory = new $delegator();
$callable = function () use ($previous, $container) {
return $container->get($previous);
};
return $factory($container, $name, $callable);
$callable = $this->createCallableFrom($previous);
$delegatorInstance = new $delegator();
return $delegatorInstance($container, $name, $callable);
})->parameter('delegator', $delegator)
->parameter('previous', $previous)
->parameter('name', $name);
Expand Down Expand Up @@ -190,4 +188,11 @@ private function get(string $key): array
}
return $this->dependencies[$key];
}

private function createCallableFrom(string $previous)
{
return factory(function (ContainerInterface $container, string $previous) {
return $container->get($previous);
})->parameter('previous', $previous);
}
}

0 comments on commit 6123582

Please sign in to comment.