-
-
Notifications
You must be signed in to change notification settings - Fork 327
Closed
Labels
Milestone
Description
Following #214 (Extend and decorate definitions) this issue is targeted at decorating a previous definition using a callable.
Here is an example using a new DI\decorate() function:
// Add custom behavior
LoggerInterface::class => DI\decorate(function (LoggerInterface $logger) {
$logger->setSomething('foo');
}),
// Return another object
LoggerInterface::class => DI\decorate(function (LoggerInterface $logger) {
return new Wrapper($logger);
}),It could also be implemented using factory() but it's less explicit:
LoggerInterface::class => DI\factory(function (LoggerInterface $logger) {
return new Wrapper($logger);
}),