Is it possible to extend services dynamically in a dependency injection?
<p>I am working on a Symfony2 project. Symfony has a very cool dependency injection system, but I am wondering if it's possible to dynamically extend some services...</p>

<p>For instance, I have a vendor service X, registered by a third party library/bundle. Now, I need to extend that service, let's call that one Y...
I can do that by using the same service ID in the services configuration. So that's all good...</p>

<p>But now, I need a service Z that extends from Y, without the service knowing it's actually extending from Y instead of X (since the vendor service is X), so I can use service Z as if it were X in all descending application logic without losing the functionality of Y.</p>

<p>I hope my explaination makes a little bit of sense, basically my question is: is this possible? And if so, how should I go about achieving this?</p>