diff --git a/developer_manual/basics/dependency_injection.rst b/developer_manual/basics/dependency_injection.rst index 653b7090e..d3efaf34f 100644 --- a/developer_manual/basics/dependency_injection.rst +++ b/developer_manual/basics/dependency_injection.rst @@ -393,3 +393,14 @@ What not to inject: * It is a `pure function `_ .. _`reflection`: https://www.php.net/manual/en/book.reflection.php + + +Accessing the container from anywhere +------------------------------------ + +Sometimes it can be hard to inject some service inside legacy code, in these case +you can use :code:`OCP\Server::get(MyService::class)`. This should only be used in +the last resort, as this makes your code more complicated to unit test and is +considered an anti-pattern. + +