[Advanced DI] Short guide on how to make a service alias private #5138
Labels
actionable
Clear and specific issues ready for anyone to take them.
DependencyInjection
good first issue
Ideal for your first contribution! (some Symfony experience may be required)
A colleague of mine was looking for a way to make an alias private due to the nature of how privates work, the original services are private too. He managed to trace back in the code that there's a secondary way of defining the Alias; By using
Symfony\Component\DependencyInjection\Alias::__construct($id, $public = true)
.An example can be found in the Doctrine bundle (
DoctrineExtension.php
):$container->setAlias($aliasId, new Alias($serviceId, false));
. I think this would be a useful and easy feature to document.The text was updated successfully, but these errors were encountered: